2 % (c) The AQUA Project, Glasgow University, 1993-1996
6 #include "HsVersions.h"
9 CodeSegment(..), StixReg(..), StixTree(..), StixTreeList(..),
12 stgBaseReg, stgStkOReg, stgNode, stgTagReg, stgRetReg,
13 stgSpA, stgSuA, stgSpB, stgSuB, stgHp, stgHpLim, stgLivenessReg,
14 stgStdUpdRetVecReg, stgStkStubReg,
20 import AbsCSyn ( node, infoptr, MagicId(..) )
21 import AbsCUtils ( magicIdPrimRep )
22 import CLabel ( mkAsmTempLabel )
23 import UniqSupply ( returnUs, thenUs, getUnique, SYN_IE(UniqSM) )
24 import Unpretty ( uppPStr, Unpretty(..) )
27 Here is the tag at the nodes of our @StixTree@. Notice its
28 relationship with @PrimOp@ in prelude/PrimOp.
32 = -- Segment (text or data)
36 -- We can tag the leaves with constants/immediates.
38 | StInt Integer -- ** add Kind at some point
40 | StString FAST_STRING
41 | StLitLbl Unpretty -- literal labels
42 -- (will be _-prefixed on some machines)
43 | StLitLit FAST_STRING -- innards from CLitLit
44 | StCLbl CLabel -- labels that we might index into
46 -- Abstract registers of various kinds
50 -- A typed offset from a base location
52 | StIndex PrimRep StixTree StixTree -- kind, base, offset
54 -- An indirection from an address to its contents.
56 | StInd PrimRep StixTree
58 -- Assignment is typed to determine size and register placement
60 | StAssign PrimRep StixTree StixTree -- dst, src
62 -- A simple assembly label that we might jump to.
66 -- A function header and footer
71 -- An unconditional jump. This instruction is terminal.
72 -- Dynamic targets are allowed
76 -- A fall-through, from slow to fast
78 | StFallThrough CLabel
80 -- A conditional jump. This instruction can be non-terminal :-)
81 -- Only static, local, forward labels are allowed
83 | StCondJump CLabel StixTree
85 -- Raw data (as in an info table).
87 | StData PrimRep [StixTree]
89 -- Primitive Operations
91 | StPrim PrimOp [StixTree]
93 -- Calls to C functions
95 | StCall FAST_STRING PrimRep [StixTree]
97 -- Assembly-language comments
99 | StComment FAST_STRING
101 sStLitLbl :: FAST_STRING -> StixTree
102 sStLitLbl s = StLitLbl (uppPStr s)
105 Stix registers can have two forms. They {\em may} or {\em may not}
106 map to real, machine-level registers.
110 = StixMagicId MagicId -- Regs which are part of the abstract machine model
112 | StixTemp Unique PrimRep -- "Regs" which model local variables (CTemps) in
116 We hope that every machine supports the idea of data segment and text
117 segment (or that it has no segments at all, and we can lump these
121 data CodeSegment = DataSegment | TextSegment deriving Eq
123 type StixTreeList = [StixTree] -> [StixTree]
126 Stix Trees for STG registers:
128 stgBaseReg, stgStkOReg, stgNode, stgTagReg, stgRetReg, stgSpA,
129 stgSuA, stgSpB, stgSuB, stgHp, stgHpLim, stgLivenessReg,
130 stgStdUpdRetVecReg, stgStkStubReg :: StixTree
132 stgBaseReg = StReg (StixMagicId BaseReg)
133 stgStkOReg = StReg (StixMagicId StkOReg)
134 stgNode = StReg (StixMagicId node)
135 stgInfoPtr = StReg (StixMagicId infoptr)
136 stgTagReg = StReg (StixMagicId TagReg)
137 stgRetReg = StReg (StixMagicId RetReg)
138 stgSpA = StReg (StixMagicId SpA)
139 stgSuA = StReg (StixMagicId SuA)
140 stgSpB = StReg (StixMagicId SpB)
141 stgSuB = StReg (StixMagicId SuB)
142 stgHp = StReg (StixMagicId Hp)
143 stgHpLim = StReg (StixMagicId HpLim)
144 stgLivenessReg = StReg (StixMagicId LivenessReg)
145 stgStdUpdRetVecReg = StReg (StixMagicId StdUpdRetVecReg)
146 stgStkStubReg = StReg (StixMagicId StkStubReg)
148 getUniqLabelNCG :: UniqSM CLabel
150 = getUnique `thenUs` \ u ->
151 returnUs (mkAsmTempLabel u)