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...
21 import AbsCSyn ( MagicId(..), kindFromMagicId, node, infoptr )
22 import PrelInfo ( showPrimOp, PrimOp
23 IF_ATTACK_PRAGMAS(COMMA tagOf_PrimOp)
24 IF_ATTACK_PRAGMAS(COMMA pprPrimOp)
26 import CLabel ( CLabel, mkAsmTempLabel )
33 Here is the tag at the nodes of our @StixTree@. Notice its
34 relationship with @PrimOp@ in prelude/PrimOp.
40 -- Segment (text or data)
44 -- We can tag the leaves with constants/immediates.
46 | StInt Integer -- ** add Kind at some point
48 | StString FAST_STRING
49 | StLitLbl Unpretty -- literal labels (will be _-prefixed on some machines)
50 | StLitLit FAST_STRING -- innards from CLitLit
51 | StCLbl CLabel -- labels that we might index into
53 -- Abstract registers of various kinds
57 -- A typed offset from a base location
59 | StIndex PrimRep StixTree StixTree -- kind, base, offset
61 -- An indirection from an address to its contents.
63 | StInd PrimRep StixTree
65 -- Assignment is typed to determine size and register placement
67 | StAssign PrimRep StixTree StixTree -- dst, src
69 -- A simple assembly label that we might jump to.
73 -- A function header and footer
78 -- An unconditional jump. This instruction is terminal.
79 -- Dynamic targets are allowed
83 -- A fall-through, from slow to fast
85 | StFallThrough CLabel
87 -- A conditional jump. This instruction can be non-terminal :-)
88 -- Only static, local, forward labels are allowed
90 | StCondJump CLabel StixTree
92 -- Raw data (as in an info table).
94 | StData PrimRep [StixTree]
96 -- Primitive Operations
98 | StPrim PrimOp [StixTree]
100 -- Calls to C functions
102 | StCall FAST_STRING PrimRep [StixTree]
104 -- Comments, of course
106 | StComment FAST_STRING -- For assembly comments
110 sStLitLbl :: FAST_STRING -> StixTree
111 sStLitLbl s = StLitLbl (uppPStr s)
114 Stix registers can have two forms. They {\em may} or {\em may not}
115 map to real, machine level registers.
119 data StixReg = StixMagicId MagicId -- Regs which are part of the abstract machine model
121 | StixTemp Unique PrimRep -- "Regs" which model local variables (CTemps) in
127 We hope that every machine supports the idea of data segment and text
128 segment (or that it has no segments at all, and we can lump these together).
132 data CodeSegment = DataSegment | TextSegment deriving (Eq)
134 type StixTreeList = [StixTree] -> [StixTree]
138 -- Stix Trees for STG registers
142 stgBaseReg, stgStkOReg, stgNode, stgTagReg, stgRetReg, stgSpA, stgSuA,
143 stgSpB, stgSuB, stgHp, stgHpLim, stgLivenessReg{-, stgActivityReg-}, stgStdUpdRetVecReg,
144 stgStkStubReg :: StixTree
146 stgBaseReg = StReg (StixMagicId BaseReg)
147 stgStkOReg = StReg (StixMagicId StkOReg)
148 stgNode = StReg (StixMagicId node)
149 stgInfoPtr = StReg (StixMagicId infoptr)
150 stgTagReg = StReg (StixMagicId TagReg)
151 stgRetReg = StReg (StixMagicId RetReg)
152 stgSpA = StReg (StixMagicId SpA)
153 stgSuA = StReg (StixMagicId SuA)
154 stgSpB = StReg (StixMagicId SpB)
155 stgSuB = StReg (StixMagicId SuB)
156 stgHp = StReg (StixMagicId Hp)
157 stgHpLim = StReg (StixMagicId HpLim)
158 stgLivenessReg = StReg (StixMagicId LivenessReg)
159 --stgActivityReg = StReg (StixMagicId ActivityReg)
160 stgStdUpdRetVecReg = StReg (StixMagicId StdUpdRetVecReg)
161 stgStkStubReg = StReg (StixMagicId StkStubReg)
163 getUniqLabelNCG :: UniqSM CLabel
165 getUnique `thenUs` \ u ->
166 returnUs (mkAsmTempLabel u)