C2CDefs.mesa
Copyright Ó 1987, 1988, 1990, 1991, 1993 by Xerox Corporation. All rights reserved.
Christian Jacobi, 1987
Christian Jacobi, January 25, 1993 7:09 pm PST
DIRECTORY
IntCodeDefs USING [Node],
Rope USING [ROPE];
C2CDefs: CEDAR DEFINITIONS =
BEGIN
Precedence: TYPE = {
--special, low
notExpressionPrecedence,
--standard C precedences
commaPrecedence, assignPrecedence, questionColonPrecedence, logicalOrPrecedence, logicalAndPrecedence, bitOrPrecedence, bitXorPrecedence, bitAndPrecedence, equalityPrecedence, orderPrecedence, shiftPrecedence, additionPrecedence, multiplicationPrecedence, unaryPrecedence, primaryPrecedence,
--special, high
identPrecedence, parenPrecedence, allwaysPutParanthesisPrecedence
};
lowestCPrecedence: Precedence = commaPrecedence;
Code: TYPE = REF CodeRep;
CodeRep: TYPE;
CodeOrRope: TYPE = REF;
CodeCont: TYPE = RECORD [
sc: Code ¬ NIL, --statement code
ec: Code ¬ NIL, --expression code
xbc: Code ¬ NIL --bit address code; used only in getBitAdr mode; NIL means "0"
];
Mode: TYPE = REF ModeRep;
ModeRep: TYPE = ModeRec; -- Should be opaque, but debugging opaque types is to painfull
AddressMode: TYPE = {
dummy, 
--On proposal: a dummy location
--On generation: DO NOT USE
skip, 
--On proposal: Does not return a value
--On generation: Need not return a value
value, 
--not necessarily addressable, assignable (fits into single word)
--requested even without proposal, but only if size is known
plain, 
--addressable, assignable if single arithmetic unit, no odd bit numbers
--Requestor is responsible for alignment correctness
assBitAddr, 
--for arbitrary bit position
--On generation: Returned code has no value itself but assigns address into the reserved AdressContainer
getBitAddr, 
--for arbitrary bit position
--returns word address in ec; bit address in xbc; NIL for 0 bit address.
getAddr, 
--On generation: Returned code is address of node
--Requestor is responsible for alignment correctness
--Requestor guarantees:
-- either: argument could be gotten also using plain [to find alignment]
-- or: argument appears on right side of mesa addr [alignment does not matter]
assAddr, 
--On generation: Returned code has no value itself but its address is assigned into a template
--Requestor is responsible for alignment correctness
--Requestor guarantees:
-- either: argument could be gotten also using plain [to find alignment]
-- or: argument appears on right side of mesa addr [alignment does not matter]
assUnits, 
--On generation: Returned code has no value itself but is assigned into a template;
-- template must be addressable
-- size [of template] assumed to be defined with ContainerSize
-- size must fit pointeebits
-- if smaller value assigned: right adjusted, 0 or sign extend depending on type
-- currently only single word implemented
assBits, 
--On generation: Returned code has no value itself but is assigned into a template;
-- template is bit address described by AdressContainer
-- size assumed to be defined with ContainerSize
-- size must be exact; other bits won't be touched; left adjusted in templates
maskNShift, 
--bit position, no word boundary crossing
--generation mostly defaults to value
lHSMaskNShift, 
--Used for lhs of assignment to packed array
-- unit size is multiple of element size
-- base must be addressable
--Used for lhs of packed record
-- base must be addressed plain assumed full word indexing
--template is rhs, must be evaluated only once; right adjusted left filled with zeros
--may generate statement code
--lHSMaskNShiftNode optionally available
bad
--never occurs...
};
AddressContainer: TYPE = RECORD [words, bits: Rope.ROPE ¬ NIL];
noAddress: AddressContainer = AddressContainer[NIL, NIL];
ModeRec used to be declared in private interface
ModeRec: TYPE = <<PRIVATE>> RECORD [
am: AddressMode ¬ bad,
ac: AddressContainer ¬ [NIL, NIL],
baseSz: INT ¬ -1,
containerSz: INT ¬ -1,
unitSz: INT ¬ -1, --used for lHSMaskNShift only
lHSMaskNShiftNode: IntCodeDefs.Node ¬ NIL, --used for lHSMaskNShift only
lhs: BOOL, -- TRUE iff node is used as lhs
expr: BOOL, -- TRUE iff node is used in expression mode
-- [FALSE iff in statement mode]
illegal: BOOL ¬ FALSE --for detection of caching error
];
END.