diff options
author | Peter Wortmann <scpmw@leeds.ac.uk> | 2013-06-26 15:45:16 +0100 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2013-06-27 13:39:11 -0700 |
commit | a948fe838bc79363d7565033d6ee42bf24d52fdc (patch) | |
tree | 22660c80d3c6d3b8438641d62ec1c996bda2780f /compiler/llvmGen/LlvmCodeGen/Regs.hs | |
parent | fa6cbdfb6e5d572dc74622d1c12e259c208321ab (diff) | |
download | haskell-a948fe838bc79363d7565033d6ee42bf24d52fdc.tar.gz |
Major Llvm refactoring
This combined patch reworks the LLVM backend in a number of ways:
1. Most prominently, we introduce a LlvmM monad carrying the contents of
the old LlvmEnv around. This patch completely removes LlvmEnv and
refactors towards standard library monad combinators wherever possible.
2. Support for streaming - we can now generate chunks of Llvm for Cmm as
it comes in. This might improve our speed.
3. To allow streaming, we need a more flexible way to handle forward
references. The solution (getGlobalPtr) unifies LlvmCodeGen.Data
and getHsFunc as well.
4. Skip alloca-allocation for registers that are actually never written.
LLVM will automatically eliminate these, but output is smaller and
friendlier to human eyes this way.
5. We use LlvmM to collect references for llvm.used. This allows places
other than cmmProcLlvmGens to generate entries.
Diffstat (limited to 'compiler/llvmGen/LlvmCodeGen/Regs.hs')
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen/Regs.hs | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/Regs.hs b/compiler/llvmGen/LlvmCodeGen/Regs.hs index dad355d8c5..1b87929499 100644 --- a/compiler/llvmGen/LlvmCodeGen/Regs.hs +++ b/compiler/llvmGen/LlvmCodeGen/Regs.hs @@ -4,7 +4,7 @@ module LlvmCodeGen.Regs ( lmGlobalRegArg, lmGlobalRegVar, alwaysLive, - stgTBAA, top, base, stack, heap, rx, other, tbaa, getTBAA + stgTBAA, baseN, stackN, heapN, rxN, otherN, tbaa, getTBAA ) where #include "HsVersions.h" @@ -15,6 +15,7 @@ import CmmExpr import DynFlags import FastString import Outputable ( panic ) +import Unique -- | Get the LlvmVar function variable storing the real register lmGlobalRegVar :: DynFlags -> GlobalReg -> LlvmVar @@ -76,48 +77,38 @@ lmGlobalReg dflags suf reg alwaysLive :: [GlobalReg] alwaysLive = [BaseReg, Sp, Hp, SpLim, HpLim, node] --- | STG Type Based Alias Analysis metadata -stgTBAA :: [MetaDecl] +-- | STG Type Based Alias Analysis hierarchy +stgTBAA :: [(Unique, LMString, Maybe Unique)] stgTBAA - = [ MetaUnamed topN $ MetaStr (fsLit "top") - , MetaUnamed stackN $ MetaStruct [MetaStr (fsLit "stack"), MetaNode topN] - , MetaUnamed heapN $ MetaStruct [MetaStr (fsLit "heap"), MetaNode topN] - , MetaUnamed rxN $ MetaStruct [MetaStr (fsLit "rx"), MetaNode heapN] - , MetaUnamed baseN $ MetaStruct [MetaStr (fsLit "base"), MetaNode topN] + = [ (topN, fsLit "top", Nothing) + , (stackN, fsLit "stack", Just topN) + , (heapN, fsLit "heap", Just topN) + , (rxN, fsLit "rx", Just heapN) + , (baseN, fsLit "base", Just topN) -- FIX: Not 100% sure about 'others' place. Might need to be under 'heap'. -- OR I think the big thing is Sp is never aliased, so might want -- to change the hieracy to have Sp on its own branch that is never -- aliased (e.g never use top as a TBAA node). - , MetaUnamed otherN $ MetaStruct [MetaStr (fsLit "other"), MetaNode topN] + , (otherN, fsLit "other", Just topN) ] -- | Id values -topN, stackN, heapN, rxN, baseN, otherN:: Int -topN = 0 -stackN = 1 -heapN = 2 -rxN = 3 -baseN = 4 -otherN = 5 - --- | The various TBAA types -top, heap, stack, rx, base, other :: MetaAnnot -top = MetaAnnot tbaa (MetaNode topN) -heap = MetaAnnot tbaa (MetaNode heapN) -stack = MetaAnnot tbaa (MetaNode stackN) -rx = MetaAnnot tbaa (MetaNode rxN) -base = MetaAnnot tbaa (MetaNode baseN) -other = MetaAnnot tbaa (MetaNode otherN) +topN, stackN, heapN, rxN, baseN, otherN :: Unique +topN = getUnique (fsLit "LlvmCodeGen.Regs.topN") +stackN = getUnique (fsLit "LlvmCodeGen.Regs.stackN") +heapN = getUnique (fsLit "LlvmCodeGen.Regs.heapN") +rxN = getUnique (fsLit "LlvmCodeGen.Regs.rxN") +baseN = getUnique (fsLit "LlvmCodeGen.Regs.baseN") +otherN = getUnique (fsLit "LlvmCodeGen.Regs.otherN") -- | The TBAA metadata identifier tbaa :: LMString tbaa = fsLit "tbaa" -- | Get the correct TBAA metadata information for this register type -getTBAA :: GlobalReg -> MetaAnnot -getTBAA BaseReg = base -getTBAA Sp = stack -getTBAA Hp = heap -getTBAA (VanillaReg _ _) = rx -getTBAA _ = top - +getTBAA :: GlobalReg -> Unique +getTBAA BaseReg = baseN +getTBAA Sp = stackN +getTBAA Hp = heapN +getTBAA (VanillaReg _ _) = rxN +getTBAA _ = topN |