CodeDefs.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Sweet, June 20, 1980 3:57 PM
Satterthwaite, May 27, 1986 2:14:24 pm PDT
Russ Atkinson (RRA) March 6, 1985 11:02:19 pm PST
DIRECTORY
Alloc USING [Base, Notifier],
Literals USING [LTIndex, LTNull, STIndex],
PrincOps USING [MaxFrameSize],
SourceMap USING [Loc],
Symbols USING [BTIndex, ContextLevel, HTIndex, ISEIndex, ISENull, lZ, RecordSEIndex],
SymbolSegment USING [Tables],
Table USING [Selector];
CodeDefs: DEFINITIONS = {
OPEN Symbols;
Byte: TYPE = [0..256);
bitsPerWord: NAT = 16;
OpWordCount: TYPE = CARDINAL; -- size of operands for builtins
Base: TYPE = Alloc.Base;
Limit: CARDINAL = 77777B;
Lexeme: TYPE = MACHINE DEPENDENT RECORD [
lexvalue(0): SELECT lextag(0): * FROM
se => [lexsei(1): ISEIndex],
literal => [
index(1): SELECT littag(1: 0..0): * FROM
word => [lexlti(1: 1..15): Literals.LTIndex],
string => [lexsti(1: 1..15): Literals.STIndex]
ENDCASE],
bdo => [lexbdoi(1): VarIndex],
stack => [lexsti(1): StackIndex]
ENDCASE];
NullLex: Lexeme.se = Lexeme[se[Symbols.ISENull]];
MoveDirection: TYPE = {load, store};
VarSpace: TYPE = {faddr, frame, frameup, caddr, code, link, linkup, stack, const, pdesc};
VarTag: TYPE = {o, bo, bdo, ind};
VarComponent: TYPE = RECORD [
wSize: CARDINAL ← 0 | TRASH,
bSize: [0..bitsPerWord) ← 0 | TRASH,
space: SELECT tag: VarSpace FROM
frame => [
immutable: BOOLFALSE,
level: ContextLevel ← lZ,
wd: CARDINAL ← 0,
bd: [0..bitsPerWord) ← 0],
code => [
bd: [0..bitsPerWord) ← 0,
wd: CARDINAL ← 0,
lti: Literals.LTIndex ← Literals.LTNull],
faddr => [wd: CARDINAL, level: ContextLevel],
frameup => [
level: ContextLevel ← lZ,
pwSize: [1..2] ← 1,
immutable: BOOLFALSE,
wd: CARDINAL ← 0,
delta: [0..PrincOps.MaxFrameSize) ← 0],
caddr, link => [wd: CARDINAL],
linkup => [
wd: CARDINAL,
delta: [0..PrincOps.MaxFrameSize) ← 0],
stack => [
bd: [0..bitsPerWord) ← 0,
wd: CARDINAL ← 0,
sti: StackIndex],
const => [bd: [0..bitsPerWord) ← 0, d1, d2: UNSPECIFIEDTRASH],
pdesc => [ep: CARDINAL]
ENDCASE];
VarItem: TYPE = RECORD [ -- not many around simultaneously
free: BOOLFALSE, -- required by allocator
body: SELECT tag: VarTag FROM
o => [var: VarComponent],
bo => [offset, base: VarComponent],
bdo => [offset, base, disp: VarComponent],
ind => [
offset, base, index: VarComponent,
simple: BOOL,
packinfo: SELECT packtag: * FROM
packed => [grain: [1..bitsPerWord)],
notPacked => [eWords: [0..PrincOps.MaxFrameSize)]
ENDCASE]
ENDCASE];
VarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem;
OVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.o;
BoVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.bo;
BdoVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.bdo;
IndVarIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO VarItem.ind;
VarNull: VarIndex = VarIndex.FIRST;
RelativePC: TYPE = [0..177777B];
CCInfoType: TYPE = {generating, binding, coding};
CodeChunkType: TYPE = {code, label, jump, other};
CCItem: TYPE = RECORD [
free: BOOL,
flink, blink: CCIndex,
ccvalue: SELECT cctag: CodeChunkType FROM
code => [
realinst: BOOL,
inst: Byte,
isize: [0..7],
fill: [0..3],
parameters: ARRAY [1..1) OF WORD],
label => [
labelseen: BOOL,
labelinfo: SELECT OVERLAID CCInfoType FROM
generating => [fillword, jumplist: JumpCCIndex],
binding => [minPC, maxPC: RelativePC],
coding => [fillword, pc: RelativePC],
ENDCASE],
jump => [
jsize: [0..7],
jparam: Byte,
fixedup, completed: BOOL,
forward: BOOL,
jtype: JumpType,
destlabel: LabelCCIndex,
jumpinfo: SELECT OVERLAID CCInfoType FROM
generating => [fillword, thread: JumpCCIndex],
binding => [minPC, maxPC: RelativePC],
coding => [fillword, pc: RelativePC]
ENDCASE],
other => [obody: SELECT otag: * FROM
table => [
btab: BOOL,
tablecodebytes: [0..7],
taboffset: INTEGER],
markbody => [
start: BOOL,
index: BTIndex],
relSource => [relLoc: RelSourceLoc],  -- relative to proc body
absSource => [loc: SourceMap.Loc]
ENDCASE]
ENDCASE];
RelSourceLoc: TYPE = [0..7777B];
CCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem;
CCNull: CCIndex = CCIndex.FIRST;
JumpCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.jump;
JumpCCNull: JumpCCIndex = LOOPHOLE[CCNull];
LabelCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.label;
LabelCCNull: LabelCCIndex = LOOPHOLE[CCNull];
CodeCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.code;
CodeCCNull: CodeCCIndex = LOOPHOLE[CCNull];
OtherCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.other;
TableCCIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO CCItem.other.table;
TableCCNull: TableCCIndex = LOOPHOLE[CCNull];
CJItem: TYPE = RECORD [
inst: CCIndex,
variant: SELECT tag:* FROM
fallIn => [lc: LabelCCIndex],
jumpIn => [jc: JumpCCIndex]
ENDCASE];
CompareClass: TYPE = {word, byte};
JumpType: TYPE = {
JumpE, JumpN, JumpL, JumpGE, JumpG, JumpLE,
UJumpL, UJumpGE, UJumpG, UJumpLE, ZJumpE, ZJumpN,
Jump, JumpA, JumpC, JumpCA, JumpRet,
NILJumpE, NILJumpN, PAIRJumpL, PAIRJumpG,
BYTEJumpE, BYTEJumpN, BITJumpE, BITJumpN};
LabelInfoRecord: TYPE = RECORD [
free: BOOLFALSE,
thread: LabelInfoIndex,
catchLevel: [0..37777b],
body: SELECT tag:* FROM
named => [hti: HTIndex, cci: LabelCCIndex],
loop => [exit, loop: LabelCCIndex],
stmt => [retry, continue: LabelCCIndex]
ENDCASE];
LabelInfoIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO LabelInfoRecord;
NamedLabelInfoIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO LabelInfoRecord.named;
LabelInfoNull: LabelInfoIndex = LabelInfoIndex.FIRST;
StackIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO StackItem;
StackNull: StackIndex = StackIndex.FIRST;
StackItem: TYPE = RECORD [
free: BOOLFALSE,
uplink, downlink: StackIndex ← StackNull,
data: SELECT tag:* FROM
mark => [label: LabelCCIndex],
onStack => [
alsoLink: BOOLFALSE,
tLevel: Symbols.ContextLevel ← lZ,
tOffset: TempAddr ← TRASH],
inTemp => [
tLevel: Symbols.ContextLevel,
tOffset: TempAddr],
inLink => [link: Byte]
ENDCASE];
if alsoTemp for onStack element, it has been previously dumped
by the stack machinery into the given temp.
StackPos: TYPE = [0..16);
StackLocRec: TYPE = RECORD [SELECT tag:* FROM
onStack => [depth: CARDINAL],
inTemp => [
tSize: TempSize,
tLevel: Symbols.ContextLevel,
tOffset: TempAddr],
inLink => [link: [0..256)],
mixed => []
ENDCASE];
StackLocRec semantics:
obtained by lr: StackLocRec ← Stack.Loc[s, count];
Tag  Meaning
onStack  The "count" words are all on the stack.
There are "depth" words above them in the model
inTemp  The "count" words are in contiguous temporaries
inLink  "count" = 1 and value is in link "link"
mixed  None of the above
EvalStackSize: CARDINAL = 14;
MaxParmsInStack: CARDINAL = EvalStackSize - 3;
TempAddr: TYPE = [0..PrincOps.MaxFrameSize);
TempSize: TYPE = [0..PrincOps.MaxFrameSize);
TempStateRecord: TYPE = RECORD[pendtemplist, heaplist: ISEIndex];
FrameStateRecord: TYPE = RECORD[
pendtemplist, heaplist: ISEIndex,
tempctxlvl: ContextLevel,
firstTemp, tempstart, framesz: INTEGER];
CaseCVState: TYPE = {single, singleLoaded, multi, none};
StoreOptions: TYPE = RECORD [
expr: BOOLFALSE,
init: BOOLFALSE,
counted: BOOLFALSE,
composite: BOOLFALSE];
ConsDestination: TYPE = RECORD [
bd: [0..bitsPerWord) ← TRASH,
bSize: [0..bitsPerWord) ← TRASH,
inFrame: BOOLFALSE, -- can store directly into frame
fLevel: Symbols.ContextLevel ← TRASH,
pLength: [1..2] ← 1,
ignoreSafen: BOOLFALSE,
fOffset: CARDINALTRASH, -- offset of first word of record
pLoaded: BOOLFALSE, -- pointer already on virtual stack
pSti: StackIndex ← TRASH, -- the sti of the pointer if pLoaded
pDelta: INTEGER ← 0, -- word offset into record of pointer
pLink: BOOLFALSE, -- pointer also in a link
pLevel: Symbols.ContextLevel ← lZ, -- if not lZ, then ptr is in temp
pOffset: TempAddr ← TRASH, -- frame offset of temp or link
remaining: CARDINAL ← 0,
wSize: CARDINALTRASH,
options: StoreOptions ← []];
StatementStateRecord: TYPE = RECORD [
retLabel, comRetLabel: LabelCCIndex,
outRecord: RecordSEIndex,
pendtemplist: ISEIndex,
stkPtr: UNSPECIFIED,
inlineFileLoc: SourceMap.Loc];
ChunkIndex: TYPE = Base RELATIVE POINTER [0..Limit);
codeType: Table.Selector = SymbolSegment.Tables.LAST+1;
AddressNotify, CallsNotify, ConstructorNotify, CountingNotify,
CrossJumpNotify, ExpressionNotify, FinalNotify,
FlowNotify, FlowExpressionNotify, OutCodeNotify, PeepholeNotify,
StatementNotify, SelectionNotify, StoreNotify, TempNotify,
VarBasicsNotify, VarMoveNotify, VarUtilsNotify:
Alloc.Notifier;
}.