file CodeDefs.mesa
last modified by Sweet, 10-Nov-81 22:58:49
last modified by Satterthwaite, April 16, 1986 1:15:20 pm PST
DIRECTORY
Alloc: TYPE USING [Base, Notifier],
Literals: TYPE USING [LTIndex, LTNull, STIndex],
PrincOps: TYPE USING [MaxFrameSize, MaxParamsInStack, stackDepth],
SourceMap: TYPE USING [Loc],
Symbols:
TYPE
USING [
BTIndex, CCBTIndex, ContextLevel, HTIndex, ISEIndex, ISENull, lZ,
RecordSEIndex],
SymbolSegment USING [Tables],
Table: TYPE USING [Selector];
CodeDefs:
DEFINITIONS = {
OPEN Symbols;
codeType: Table.Selector = SymbolSegment.Tables.LAST+1;
BYTE: TYPE = [0..256);
wordlength: CARDINAL = 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..wordlength) ← 0 | TRASH,
space:
SELECT tag: VarSpace
FROM
frame => [
immutable: BOOL ← FALSE,
level: ContextLevel ← lZ,
wd: CARDINAL ← 0,
bd: [0..wordlength) ← 0],
code => [
bd: [0..wordlength) ← 0,
wd: CARDINAL ← 0,
lti: Literals.LTIndex ← Literals.LTNull],
faddr => [wd: CARDINAL, level: ContextLevel],
frameup => [
level: ContextLevel ← lZ,
pwSize: [1..2] ← 1,
immutable: BOOL ← FALSE,
wd: CARDINAL ← 0,
delta: [0..PrincOps.MaxFrameSize) ← 0],
caddr, link => [wd: CARDINAL],
linkup => [
wd: CARDINAL,
delta: [0..PrincOps.MaxFrameSize) ← 0],
stack => [
bd: [0..wordlength) ← 0,
wd: CARDINAL ← 0,
sti: StackIndex],
const => [bd: [0..wordlength) ← 0, d1, d2: UNSPECIFIED ← TRASH],
pdesc => [ep: CARDINAL]
ENDCASE];
VarItem:
TYPE =
RECORD [
-- not many around simultaneously
free: BOOL ← FALSE, -- 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..wordlength)],
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..77777b];
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,
isize: [0..7],
lco: BOOL ← FALSE,
fill: [0..1],
inst: BYTE,
parameters: ARRAY [1..1) OF WORD],
label => [
offsetLoaded: BOOL,
labelinfo:
SELECT
OVERLAID CCInfoType
FROM
generating => [
labelseen: BOOL, ei: EnableIndex,
catch: BOOL, jumplist: JumpCCIndex],
binding => [minPC, maxPC: RelativePC],
coding => [filltoword, pc: RelativePC],
ENDCASE],
jump => [
jsize: [0..7],
jtype: JumpType,
jparam: BYTE,
fixedup, completed: BOOL,
destlabel: LabelCCIndex,
forward: BOOL,
jumpinfo:
SELECT
OVERLAID CCInfoType
FROM
generating => [ei: EnableIndex, thread: JumpCCIndex],
binding => [minPC, maxPC: RelativePC],
coding => [filltoword, pc: RelativePC]
ENDCASE],
other => [obody:
SELECT otag: *
FROM
table => [
tableSize: [0..37777b],
btab: BOOL,
taboffset: NAT],
markbody => [
start: BOOL,
index: BTIndex],
markCatch => [
start: BOOL,
index: EnableIndex],
source => [loc: SourceMap.Loc]
ENDCASE]
ENDCASE];
TableCodeBytes: CARDINAL = 3; -- for JIB or JIW
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];
EnableItem:
TYPE =
RECORD [
free: BOOL,
next: EnableIndex,
bti: Symbols.CCBTIndex,
startPC, bytes: CARDINAL];
EnableIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO EnableItem;
EINull: EnableIndex = EnableIndex.FIRST;
JumpType:
TYPE = {
JumpE, JumpN, JumpL, JumpGE, JumpG, JumpLE,
UJumpL, UJumpGE, UJumpG, UJumpLE, ZJumpE, ZJumpN,
Jump, JumpA, JumpEnable, JumpC, JumpCA, JumpRet,
BYTEJumpE, BYTEJumpN, JumpLIO, JumpCatch};
LabelInfoRecord:
TYPE =
RECORD [
free: BOOL ← FALSE,
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;
DataStackIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO StackItem.data;
StackNull: StackIndex = StackIndex.FIRST;
StackItem:
TYPE =
RECORD [
free: BOOL ← FALSE,
uplink, downlink: StackIndex ← StackNull,
info:
SELECT tag:*
FROM
mark => [label: LabelCCIndex],
data => [
loaded: BOOL ← TRUE,
backup: StackBackup ← [none[]]]
ENDCASE];
loaded = FALSE and backup = none is a NO-NO.
StackBackup:
TYPE =
RECORD [
SELECT where: StackBackupLoc
FROM
none => [],
frame => [tLevel: Symbols.ContextLevel, tOffset: TempAddr],
link => [link: BYTE],
const => [value: CARDINAL],
faddr => [tLevel: Symbols.ContextLevel, tOffset: TempAddr]
ENDCASE];
StackBackupLoc: TYPE = {none, frame, link, const, faddr};
StackPos: TYPE = [0..16);
StackLocRec:
TYPE =
RECORD [
SELECT tag:*
FROM
onStack => [depth: CARDINAL],
stored => [],
contig => [place: StackBackup],
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
none Not a legal case
frame contig The "count" words are in contiguous temporaries
link contig "count" = 1 and value is in link "link"
const contig "count" = 1 and value is "value"
stored The "count" words are recoverable, but not contiguous
mixed "loaded" are on stack others not
EvalStackSize: CARDINAL = PrincOps.stackDepth;
MaxParmsInStack: CARDINAL = PrincOps.MaxParamsInStack;
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: BOOL ← FALSE,
init: BOOL ← FALSE,
counted: BOOL ← FALSE,
composite: BOOL ← FALSE];
ConsDestination:
TYPE =
RECORD [
bd: [0..wordlength) ← TRASH,
bSize: [0..wordlength) ← TRASH,
inFrame: BOOL ← FALSE, -- can store directly into frame
fLevel: Symbols.ContextLevel ← TRASH,
pLength: [1..2] ← 1,
ignoreSafen: BOOL ← FALSE,
fOffset: CARDINAL ← TRASH, -- offset of first word of record
pLoaded: BOOL ← FALSE, -- pointer already on virtual stack
pSti: StackIndex ← TRASH, -- the sti of the pointer if pLoaded
pDelta: INTEGER ← 0, -- word offset into record of pointer
remaining: CARDINAL ← 0,
wSize: CARDINAL ← TRASH,
options: StoreOptions ← [],
pBackup: StackBackup ← [none[]],
pzBackup: StackBackup ← [none[]]];
StatementStateRecord:
TYPE =
RECORD [
retLabel, comRetLabel: LabelCCIndex,
outRecord: RecordSEIndex,
pendtemplist: ISEIndex,
stkPtr: UNSPECIFIED,
inlineFileLoc: SourceMap.Loc];
ChunkIndex: TYPE = Base RELATIVE POINTER [0..Limit);
AddressNotify, CallsNotify, ConstructorNotify, CountingNotify,
CrossJumpNotify, DJumpsNotify, ExpressionNotify, FinalNotify,
FlowNotify, FlowExpressionNotify, OutCodeNotify, PeepholeNotify,
SelectionNotify, StatementNotify, StoreNotify, TempNotify,
VarBasicsNotify, VarMoveNotify, VarUtilsNotify:
Alloc.Notifier;