C2CTarget.mesa
Copyright Ó 1987, 1988, 1989, 1990, 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, 1987
Christian Jacobi, January 29, 1993 10:55 am PST
DIRECTORY
Rope;
Defining the target architecture.
Target is aimed at the Sun4 (SPARC processor).
It is also working for Sun3, or, M68000, or, AMD29000 based architectures, but presenting slightly too strict alignments.
There are multiple C2CTarget definitions (sources) defining multiple target architectures. C2C generates code for a particular target architecture by selecting the particular C2CTarget module and recompiling all of it. All C2CTarget definitions are supposed to export the same abstractions, only the values might be different.
When editing C2CTarget, please do it for all versions on all target architectures.
C2CTarget: CEDAR DEFINITIONS =
BEGIN
The following conventions hold
Local variables have a size and are aligned at a multiple of bitsPerWord bits
Global variables have a size and are aligned at a multiple of bitsPerWord bits
for Sparc: The type double is never generated,
soo double will not cause any alignment constraints.
Some numbers are real constants for speed reasons...
logically they should be READONLY VAR's
ROPE: TYPE = Rope.ROPE;
bigEndian: BOOL = TRUE;
runtimePrefix: READONLY ROPE;
prefix put in front of runtime system names
bitsPerWord: NAT = 32;
This number is nicely parametrized, but not completely honest on all places.
word: READONLY ROPE; --= "word"
Type for an arithmetic memory unit and pointers.
One of "int", "unsigned", or "long int"... which is best to hold pointers
wordCast: READONLY ROPE; --= "(word)"
Cast into word type
signedWord: READONLY ROPE;
unsignedWord: READONLY ROPE;
signedWordCast: READONLY ROPE;
unsignedWordCast: READONLY ROPE;
wordPtr: READONLY ROPE;
Type for a pointer to word
wordPtrCast: READONLY ROPE;
Cast into word pointer type
hasBytes: BOOL = TRUE;
Byte adressing is possible and pointers can be cast between word pointers
and byte pointers without loss, if alignment fits both.
byte: READONLY ROPE;
byteCast: READONLY ROPE;
bytePtr: READONLY ROPE;
Type for a pointer to a byte
bytePtrCast: READONLY ROPE;
Cast into pointer to a byte
unsignedByteCast: READONLY ROPE;
signedByte: READONLY ROPE;
signedByteCast: READONLY ROPE;
hasHalfWords: BOOL = TRUE;
bitsPerHalfWord: NAT = 16;
halfWord: READONLY ROPE;
halfWordCast: READONLY ROPE;
halfWordPtr: READONLY ROPE;
Type for a pointer to a half word
halfWordPtrCast: READONLY ROPE;
Cast into pointer to a half word
unsignedHalfCast: READONLY ROPE;
signedHalf: READONLY ROPE;
signedHalfCast: READONLY ROPE;
bitsPerDoubleWord: NAT = 64;
bitsPerAddressUnit: NAT = 8;
addressUnitsPerWord: NAT = 4;
charsPerWordInString: NAT = 4; --like bytesPerWord, but independent of having bytes
bestAlignment: NAT = 32;
If something is aligned to bestAlignment, its adress can be used for any size object
maxBitsForReturns: READONLY INT;
maxBitsForSimpleStructs: READONLY INT;
maxBitsForValueParams: READONLY INT;
maxWordsForInlineFillWords: READONLY INT;
firstOfINT: READONLY CARD;
maxBitsForFastLiterals: READONLY INT;
--as RISC machines often do not have load-literal instructions with full word range
maxBitsForFastAnd: READONLY INT;
--literals of that many bits can be packed into an and instruction
idMaxLength: READONLY NAT;
Id's shorter than idMaxLength are always distingushed
BitsToWords: PROC [b: INT] RETURNS [w: INT];
rounds bits up to full number of words
RoundUpToWordBoundary: PROC [b: INT] RETURNS [bits: INT];
rounds bits up to full number of words
RoundUpToBestAlignment: PROC [b: INT] RETURNS [bits: INT];
rounds bits up to full number of units with the best alignment
RoundUpCharsToWords: PROC [cn: INT] RETURNS [chars: INT];
rounds char number up to full number of words
PointeeBits: PROC [usedBits: INT] RETURNS [INT];
--pointee: the guy sombody is pointing at
--finds bits of unit a pointer is pointing at
TemporaryBits: PROC [usedBits: INT] RETURNS [INT];
--finds bits to be used for a temporary
--= MAX[bitsPerWord, PointeeBits[usedBits]]
definitions: READONLY ROPE;
these definitions will define the types and constants otherwise mentioned
rightShiftSignedIsOk: READONLY BOOL;
--fills left with sign bits
maskNShiftLikeSun: BOOL = TRUE;
True for sun4 and mips
Check this eventually; maybe we could get rid of it
takingAddressIsExpensive: BOOL;
--true in architectures which put local variables in register
consecutiveStringsAllocedAdj: READONLY BOOL;
--true for C compilers that allocate space for consecutive string literals consecutively.
END.