2 % (c) The AQUA Project, Glasgow University, 1993-1995
6 #include "HsVersions.h"
9 CodeSegment(..), StixReg(..), StixTree(..), StixTreeList(..),
12 stgBaseReg, stgStkOReg, stgNode, stgTagReg, stgRetReg,
13 stgSpA, stgSuA, stgSpB, stgSuB, stgHp, stgHpLim, stgLivenessReg,
15 stgStdUpdRetVecReg, stgStkStubReg,
18 -- And for self-sufficiency, by golly...
19 MagicId, CLabel, PrimKind, PrimOp, Unique,
20 SplitUniqSupply, SUniqSM(..)
23 import AbsCSyn ( MagicId(..), kindFromMagicId, node, infoptr )
24 import AbsPrel ( showPrimOp, PrimOp
25 IF_ATTACK_PRAGMAS(COMMA tagOf_PrimOp)
26 IF_ATTACK_PRAGMAS(COMMA pprPrimOp)
28 import CLabelInfo ( CLabel, mkAsmTempLabel )
30 import PrimKind ( PrimKind(..) )
37 Here is the tag at the nodes of our @StixTree@. Notice its
38 relationship with @PrimOp@ in prelude/PrimOps.
44 -- Segment (text or data)
48 -- We can tag the leaves with constants/immediates.
50 | StInt Integer -- ** add Kind at some point
51 #if __GLASGOW_HASKELL__ <= 22
56 | StString FAST_STRING
57 | StLitLbl Unpretty -- literal labels (will be _-prefixed on some machines)
58 | StLitLit FAST_STRING -- innards from CLitLit
59 | StCLbl CLabel -- labels that we might index into
61 -- Abstract registers of various kinds
65 -- A typed offset from a base location
67 | StIndex PrimKind StixTree StixTree -- kind, base, offset
69 -- An indirection from an address to its contents.
71 | StInd PrimKind StixTree
73 -- Assignment is typed to determine size and register placement
75 | StAssign PrimKind StixTree StixTree -- dst, src
77 -- A simple assembly label that we might jump to.
81 -- A function header and footer
86 -- An unconditional jump. This instruction is terminal.
87 -- Dynamic targets are allowed
91 -- A fall-through, from slow to fast
93 | StFallThrough CLabel
95 -- A conditional jump. This instruction can be non-terminal :-)
96 -- Only static, local, forward labels are allowed
98 | StCondJump CLabel StixTree
100 -- Raw data (as in an info table).
102 | StData PrimKind [StixTree]
104 -- Primitive Operations
106 | StPrim PrimOp [StixTree]
108 -- Calls to C functions
110 | StCall FAST_STRING PrimKind [StixTree]
112 -- Comments, of course
114 | StComment FAST_STRING -- For assembly comments
118 sStLitLbl :: FAST_STRING -> StixTree
119 sStLitLbl s = StLitLbl (uppPStr s)
122 Stix registers can have two forms. They {\em may} or {\em may not}
123 map to real, machine level registers.
127 data StixReg = StixMagicId MagicId -- Regs which are part of the abstract machine model
129 | StixTemp Unique PrimKind -- "Regs" which model local variables (CTemps) in
135 We hope that every machine supports the idea of data segment and text
136 segment (or that it has no segments at all, and we can lump these together).
140 data CodeSegment = DataSegment | TextSegment deriving (Eq)
142 type StixTreeList = [StixTree] -> [StixTree]
146 -- Stix Trees for STG registers
150 stgBaseReg, stgStkOReg, stgNode, stgTagReg, stgRetReg, stgSpA, stgSuA,
151 stgSpB, stgSuB, stgHp, stgHpLim, stgLivenessReg{-, stgActivityReg-}, stgStdUpdRetVecReg,
152 stgStkStubReg :: StixTree
154 stgBaseReg = StReg (StixMagicId BaseReg)
155 stgStkOReg = StReg (StixMagicId StkOReg)
156 stgNode = StReg (StixMagicId node)
157 stgInfoPtr = StReg (StixMagicId infoptr)
158 stgTagReg = StReg (StixMagicId TagReg)
159 stgRetReg = StReg (StixMagicId RetReg)
160 stgSpA = StReg (StixMagicId SpA)
161 stgSuA = StReg (StixMagicId SuA)
162 stgSpB = StReg (StixMagicId SpB)
163 stgSuB = StReg (StixMagicId SuB)
164 stgHp = StReg (StixMagicId Hp)
165 stgHpLim = StReg (StixMagicId HpLim)
166 stgLivenessReg = StReg (StixMagicId LivenessReg)
167 --stgActivityReg = StReg (StixMagicId ActivityReg)
168 stgStdUpdRetVecReg = StReg (StixMagicId StdUpdRetVecReg)
169 stgStkStubReg = StReg (StixMagicId StkStubReg)
171 getUniqLabelNCG :: SUniqSM CLabel
173 getSUnique `thenSUs` \ u ->
174 returnSUs (mkAsmTempLabel u)