IntCodeTargetImpl.mesa
Copyright Ó 1986, 1987, 1991 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) December 4, 1987 3:35:18 pm PST
JKF July 27, 1988 8:17:08 am PDT
DIRECTORY
IntCodeTarget USING [BitOrder],
Rope USING [ROPE],
Target: TYPE MachineParms USING [BitOrder, bitOrder, bitsPerAU, bitsPerByte, bitsPerWord];
IntCodeTargetImpl: CEDAR PROGRAM
EXPORTS IntCodeTarget
= BEGIN
ROPE: TYPE = Rope.ROPE;
This file has definitions that allow us to be parameterized according to the target. Most of the variables are not constants to allow us to share more code without recompilation.
Machine description
name: PUBLIC ROPE ¬ "Sun-3/4";
Gives a human-readable name for the target machine. Useful for messages.
Addressing units
bitsPerAU: PUBLIC NAT ¬ Target.bitsPerAU;
logBitsPerAU: PUBLIC NAT ¬ ExactLog2[bitsPerAU];
bytesPerAU: PUBLIC NAT ¬ Target.bitsPerAU/Target.bitsPerByte;
logBytesPerAU: PUBLIC NAT ¬ ExactLog2[bytesPerAU];
Bit order
bitOrder: PUBLIC IntCodeTarget.BitOrder ¬ SELECT Target.bitOrder FROM
$msBit => $msBit,
$lsBit => $lsBit,
ENDCASE => ERROR;
Arguments & returns
maxBitsArgumentRecord: PUBLIC NAT ¬ 16*Target.bitsPerWord;
gives the max # of direct argument words
minBitsPerArgument: PUBLIC NAT ¬ Target.bitsPerWord;
logMinBitsPerArgument: PUBLIC NAT ¬ ExactLog2[minBitsPerArgument];
Gives the minimum # of bits for an argument
(to get the bits for an argument, round up & shift by logMinBitsPerArgument)
maxBitsReturnRecord: PUBLIC NAT ¬ 1*Target.bitsPerWord;
gives the max # of direct return words
minBitsPerReturn: PUBLIC NAT ¬ Target.bitsPerWord;
logMinBitsPerReturn: PUBLIC NAT ¬ ExactLog2[minBitsPerReturn];
Gives the minimum # of bits for an return value
Global frame
bitsPerGlobal: PUBLIC NAT ¬ Target.bitsPerWord;
logBitsPerGlobal: PUBLIC NAT ¬ ExactLog2[bitsPerGlobal];
Gives the minimum # of bits for an global variable
(can be different than locals)
firstGlobalOffset: PUBLIC NAT ¬ 4*Target.bitsPerWord;
First offset usable for global variables (in bits)
(what should this be?)
directGlobals: PUBLIC BOOL ¬ FALSE;
TRUE => target supports direct use of global variables
FALSE => target requires global frame pointer
Local frame & stack
lastRegister: PUBLIC NAT ¬ 0;
Gives # of registers to be used for local variables
lastStack: PUBLIC NAT ¬ 0;
Gives last stack location to be used for passing arguments
bitsPerLocal: PUBLIC NAT ¬ Target.bitsPerWord;
logBitsPerLocal: PUBLIC NAT ¬ ExactLog2[bitsPerLocal];
Gives the minimum # of bits for a local variable
bitsPerLink: PUBLIC NAT ¬ Target.bitsPerWord;
logBitsPerLink: PUBLIC NAT ¬ ExactLog2[bitsPerLink];
Gives the minimum # of bits for a link
(uniform for static link, global link, & frame extension if any).
ExactLog2: PROC [n: NAT] RETURNS [log2: NAT ¬ 2] = {
RETURN [SELECT n FROM
1 => 0, 2 => 1, 4 => 2, 8 => 3, 16 => 4, 32 => 5, 64 => 6, 128 => 7,
256 => 8, 512 => 9, 1024 => 10, 2048 => 11, 4096 => 12, 8192 => 13, 16384 => 14
ENDCASE => ERROR];
};
END.