SPARCArchitecture.mesa
Copyright Ó 1989, 1990 by Xerox Corporation. All rights reserved.
Peter B. Kessler, April 9, 1990 3:25:39 pm PDT
Architectural information about the SPARC, for the PrincOps compiler (sigh).
DIRECTORY
TargetArchitecture;
SPARCArchitecture: CEDAR DEFINITIONS ~ {
Types.
Miscellaneous
SPARCAddress: TYPE[SIZE[CARD32]];
nullSPARCAddress: SPARCAddress ~ LOOPHOLE[FIRST[CARD32]];
SPARCContents: TYPE[SIZE[CARD32]];
SPARCInstruction: TYPE[SIZE[CARD32]];
nullSPARCInstruction: SPARCInstruction ~ LOOPHOLE[CARD32[0]];
Instruction Formats
Format1: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ← Op.call,
disp30MS (0:2..15): Unbiased30MS ←,
disp30LS (0:16..31): Unbiased30LS ←
];
Format2Imm22: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
rd (0:2..6): Register ←,
op2 (0:7..9): Op2 ←,
imm22MS (0:10..15): Imm22MS ←,
imm22LS (0:16..31): Imm22LS ←
];
Format2Disp22: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
a (0:2..2): Annul ←,
cond (0:3..6): Cond ←,
op2 (0:7..9): Op2 ←,
disp22MS (0:10..15): Unbiased22MS ←,
disp22LS (0:16..31): Unbiased22LS ←
];
Format3asi: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
rd (0:2..6): Register ←,
op3 (0:7..12): Op3 ←,
rs1MS (0:13..15): RegisterMS ←,
rs1LS (0:16..17): RegisterLS ←,
i (0:18..18): I ← I.useRS2,
asi (0:19..26): ASI ←,
rs2 (0:27..31): Register ←
];
Format3Simm13: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
rd (0:2..6): Register ←,
op3 (0:7..12): Op3 ←,
rs1MS (0:13..15): RegisterMS ←,
rs1LS (0:16..17): RegisterLS ←,
i (0:18..18): I ← I.useSimm13,
simm13 (0:19..31): Unbiased13 ←
];
Format3OpF: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
rd (0:2..6): Register ←,
op3 (0:7..12): Op3 ←,
rs1MS (0:13..15): RegisterMS ←,
rs1LS (0:16..17): RegisterLS ←,
opf (0:18..26): OpF ←,
rs2 (0:27..31): Register ←
];
Format3TiccRs2: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
pad1 (0:2..2): Ignored1 ← Ignored1.ignored,
cond (0:3..6): Cond ←,
op3 (0:7..12): Op3 ←,
rs1MS (0:13..15): RegisterMS ←,
rs1LS (0:16..17): RegisterLS ←,
i (0:18..18): I ← I.useRS2,
pad2 (0:19..26): Ignored8 ← Ignored8.ignored,
rs2 (0:27..31): Register ←
];
Format3TiccSimm13: TYPE ~ MACHINE DEPENDENT RECORD [
op (0:0..1): Op ←,
pad1 (0:2..2): Ignored1 ← Ignored1.ignored,
cond (0:3..6): Cond ←,
op3 (0:7..12): Op3 ←,
rs1MS (0:13..15): RegisterMS ←,
rs1LS (0:16..17): RegisterLS ←,
i (0:18..18): I ← I.useSimm13,
simm13 (0:19..31): Unbiased13 ←
];
FormatUnknown: TYPE ~ RECORD [
bits: SPARCInstruction ←
];
Subsidiary types
Op: TYPE ~ MACHINE DEPENDENT {
branch (00B), call (01B), other2 (02B), other3 (03B)
};
Op2: TYPE ~ MACHINE DEPENDENT {
unimplemented0 (00B), bicc (02B), sethi (04B), fbfcc (06B), cbccc (07B)
};
Op3: TYPE ~ MACHINE DEPENDENT {
use Op10Op3 and Op11Op3 to get values for fields of this type. Sigh.
first (000B), last (077B)
};
Op10Op3: TYPE ~ MACHINE DEPENDENT {
Fill this in as you need it.
add (000B), or (002B), sub (004B),
jmpl (070B), rett (071B),
save (074B), restore (075B),
unimplemented77 (077B)
};
Op11Op3: TYPE ~ MACHINE DEPENDENT {
Fill this in as you need it.
ld (000B), st (004B), unimplemented77 (077B)
};
Register: TYPE ~ MACHINE DEPENDENT {
global0 (0), global1, global2, global3, global4, global5, global6, global7,
out0 (8), out1, out2, out3, out4, out5, out6, out7,
local0 (16), local1, local2, local3, local4, local5, local6, local7,
in0 (24), in1, in2, in3, in4, in5, in6, in7
};
stackPointer: Register ~ Register.out6;
stackPointerOffset: NAT ~ 16 * BYTES[TargetArchitecture.Contents];
When you use sp-relative addressing, you have to avoid the 16 word area at the bottom of the stack in which the system saves in and local registers whenever it wants to.
stackAllocationForCallee: NAT ~ 8 * BYTES[TargetArchitecture.Contents];
If you might be changing a leaf frame to a (non-aggregate-returning) caller frame, you have to allocate at least this much space, into which the callee may store register arguments.
stackAllocationUnit: NAT ~ 2 * BYTES[TargetArchitecture.Contents];
The stack has to be double-word aligned.
framePointer: Register ~ Register.in6;
returnAddress: Register ~ Register.in7;
FloatingRegister: TYPE ~ MACHINE DEPENDENT {
float0 (0), float1, float2, float3, float4, float5, float6, float7,
float8, float9, float10, float11, float12, float13, float14, float15,
float16, float17, float18, float19, float20, float21, float22, float23,
float24, float25, float26, float27, float28, float29, float30, float31
};
RegisterClass: TYPE ~ MACHINE DEPENDENT {
none (LOOPHOLE[TargetArchitecture.RegisterClass.none]),
globals, globalsAndIns, globalsInsAndFloats, globalsInsFloatsOutsAndLocals,
nextAvailable,
all (LOOPHOLE[TargetArchitecture.RegisterClass.all])
} ← nullRegisterClass;
nullRegisterClass: RegisterClass ~ RegisterClass.none;
Annul: TYPE ~ MACHINE DEPENDENT {
execute (0), annul (1)
};
Cond: TYPE ~ MACHINE DEPENDENT {
never (00H), equal (01H), lessOrEqual (02H), less (03H),
lessOrEqualUnsigned (04H), carrySet (05H), negative (06H), overflowSet (07H),
always (08H), notEqual (09H), greater (0AH), greaterOrEqual (0BH),
greaterUnsigned (0CH), carryClear (0DH), positive (0EH), overflowClear (0FH)
};
In the PrincOps compiler, you can't have enumerations (or even subranges) like this, so we have to do our own, dynamic, type-checking. Sigh.
Disp30: TYPE ~ INT32;  -- this is not a biased subrange, now!
firstDisp30: Disp30 ~ -536870912;
lastDisp30: Disp30 ~ +536870911;
Disp30: TYPE ~ INT [-536870912..536870911]; -- in Mimosa.
Imm22: TYPE ~ CARD32;
firstImm22: Imm22 ~ 0;
lastImm22: Imm22 ~ 4194303;
Imm22: TYPE ~ NAT [0..4194303];  -- in Mimosa.
Imm22MS: TYPE ~ CARDINAL [0..63];
Imm22LS: TYPE ~ CARDINAL [0..65535];
Disp22: TYPE ~ INT32;  -- this is not a biased subrange, now!
firstDisp22: Disp22 ~ -2097152;
lastDisp22: Disp22 ~ +2097151;
Disp22: TYPE ~ INT [-2097152..2097151]; -- in Mimosa.
Simm13: TYPE ~ INTEGER [-4096..4095];
firstSimm13: Simm13 ~ -4096;
lastSimm13: Simm13 ~ 4095;
Imm10: TYPE ~ CARDINAL [0..1023];
firstImm10: Imm10 ~ 0;
lastImm10: Imm10 ~ 1023;
Types for signed bitfields in instruction records.
These are unbiased types, which is what you want in the instruction fields.
For signed fields, you have to undo the biasing that Mesa put on types.
Unbiased30: TYPE ~ CARD32;
firstUnbiased30: Unbiased30 ~ 0;
lastUnbiased30: Unbiased30 ~ 1073741823;
Unbiased30MS: TYPE ~ CARDINAL [0..16383];
Unbiased30LS: TYPE ~ CARDINAL [0..65535];
Unbiased30: TYPE ~ MACHINE DEPENDENT {zero (0), (1073741823)}; -- in Mimosa.
Unbiased22: TYPE ~ CARD32;
firstUnbiased22: Unbiased22 ~ 0;
lastUnbiased22: Unbiased22 ~ 4194303;
Unbiased22: TYPE ~ MACHINE DEPENDENT {zero (0), (4194303)}; -- in Mimosa.
Unbiased22MS: TYPE ~ CARDINAL [0..63];
Unbiased22LS: TYPE ~ CARDINAL [0..65535];
Unbiased13: TYPE ~ CARDINAL [0..8191];
Unbiased13: TYPE ~ MACHINE DEPENDENT {zero (0), (8191)}; -- in Mimosa.
firstUnbiased13: Unbiased13 ~ 0;
lastUnbiased13: Unbiased13 ~ 8191;
RegisterMS: TYPE ~ CARDINAL [0..7];
RegisterLS: TYPE ~ CARDINAL [0..3];
I: TYPE ~ MACHINE DEPENDENT {
useRS2 (0), useSimm13 (1)
};
ASI: TYPE ~ CARDINAL [0..255];
OpF: TYPE ~ MACHINE DEPENDENT {
unimplemented000 (000B), unimplemented777 (0777B)
};
Ignored1: TYPE ~ MACHINE DEPENDENT {
ignored (0), (1)
} ← Ignored1.ignored;
Ignored8: TYPE ~ MACHINE DEPENDENT {
ignored (0), (255)
} ← Ignored8.ignored;
Miscellaneous
Format: TYPE ~ {
format1, format2, format3, format2imm22, format2disp22, format3asi, format3simm13, format3opf
};
Miscellaneous
ProcessorRegister: TYPE ~ {pc, npc --and probably others-- };
Procedures.
Code Assembly.
Noop: PROCEDURE [] RETURNS [SPARCInstruction];
Ld: PROCEDURE [base: Register, offset: Simm13, dest: Register]
RETURNS [SPARCInstruction];
St: PROCEDURE [source: Register, base: Register, offset: Simm13]
RETURNS [SPARCInstruction];
Sethi: PROCEDURE [hi: Imm22, dest: Register] RETURNS [SPARCInstruction];
BAa: PROCEDURE [pc: SPARCAddress, to: SPARCAddress]
RETURNS [SPARCInstruction];
! CantReach
SaveConst: PROCEDURE [source: Register, constant: Simm13, dest: Register]
RETURNS [SPARCInstruction];
RestoreConst: PROCEDURE [source: Register, constant: Simm13, dest: Register]
RETURNS [SPARCInstruction];
AddConst: PROCEDURE [source: Register, constant: Simm13, dest: Register]
RETURNS [SPARCInstruction];
SubConst: PROCEDURE [source: Register, constant: Simm13, dest: Register]
RETURNS [SPARCInstruction];
OrConst: PROCEDURE [source: Register, constant: Simm13, dest: Register]
RETURNS [SPARCInstruction];
Call: PROCEDURE [pc: SPARCAddress, to: SPARCAddress]
RETURNS [SPARCInstruction];
JmplConst: PROCEDURE [source: Register, constant: Simm13, dest: Register]
RETURNS [SPARCInstruction];
Relocate: PROCEDURE [
instruction: SPARCInstruction,
from: SPARCAddress,
to: SPARCAddress]
RETURNS [SPARCInstruction];
Relocates an instruction from the given address to another address.
! CantRelocate
Instruction Classification.
IsDelayedControlTransfer: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
IsNoopInstruction: PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
Checks whether the instruction is a noop.
NeedsRelocation: PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
Checks whether the instruction has pc-relative operands.
IsCallInstruction: PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
Checks whether the instruction is a call instruction.
IsDelayedBranchInstruction: PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
Checks whether the instruction is a delayed branch instruction.
IsJmplO7Instruction: PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
Checks whether the instruction is a jmpl with %o7 as the link register.
IsJmplG0Instruction: PROCEDURE [instruction: SPARCInstruction]
RETURNS [BOOLEAN];
Checks whether the instruction is a jmpl with %g0 as the link register.
Field accessors for instructions.
GetFormat: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Format];
GetOp: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Op];
GetDisp30: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Disp30];
GetRd: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Register];
GetOp2: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Op2];
GetImm22: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Imm22];
GetAnnul: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Annul];
GetCond: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Cond];
GetDisp22: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Disp22];
GetRs1: PUBLIC PROCEDURE [instinstruction: SPARCInstruction]
RETURNS [Register];
RegisterFromRegisterML: PUBLIC PROCEDURE [
registerMS: RegisterMS, registerLS: RegisterLS]
RETURNS [Register];
GetI: PUBLIC PROCEDURE [instinstruction: SPARCInstruction]
RETURNS [I];
GetASI: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [ASI];
GetRs2: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Register];
GetSimm13: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Simm13];
GetOpF: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [OpF];
GetOp3: PUBLIC PROCEDURE [instruction: SPARCInstruction]
RETURNS [Op3];
Op10Op3FromOp3: PUBLIC PROCEDURE [op3: Op3] RETURNS [Op10Op3];
Op11Op3FromOp3: PUBLIC PROCEDURE [op3: Op3] RETURNS [Op11Op3];
Disp30FromUnbiased30: PUBLIC PROCEDURE [
unbiased30MS: Unbiased30MS, unbiased30LS: Unbiased30LS]
RETURNS [Disp30];
Disp22FromUnbiased22: PUBLIC PROCEDURE [
unbiased22MS: Unbiased22MS, unbiased22LS: Unbiased22LS]
RETURNS [Disp22];
Imm22FromImm22ML: PUBLIC PROCEDURE [imm22MS: Imm22MS, imm22LS: Imm22LS]
RETURNS [Imm22];
Imm22MSFromImm22: PUBLIC PROCEDURE [imm22: Imm22]
RETURNS [Imm22MS];
Imm22LSFromImm22: PUBLIC PROCEDURE [imm22: Imm22]
RETURNS [Imm22LS];
Simm13FromUnbiased13: PUBLIC PROCEDURE [unbiased13: Unbiased13]
RETURNS [Simm13];
Hi: PUBLIC PROCEDURE [value: CARD32] RETURNS [Imm22];
Lo: PUBLIC PROCEDURE [value: CARD32] RETURNS [Imm10];
HiLo: PUBLIC PROCEDURE[hi: Imm22, lo: Imm10] RETURNS [CARD32];
Field assigners for instructions.
SetOp: PUBLIC PROCEDURE [instruction: SPARCInstruction, op: Op]
RETURNS [SPARCInstruction];
SetDisp30: PUBLIC PROCEDURE [instruction: SPARCInstruction, disp30: Disp30]
RETURNS [SPARCInstruction];
SetRd: PUBLIC PROCEDURE [instruction: SPARCInstruction, rd: Register]
RETURNS [SPARCInstruction];
SetOp2: PUBLIC PROCEDURE [instruction: SPARCInstruction, op2: Op2]
RETURNS [SPARCInstruction];
SetImm22: PUBLIC PROCEDURE [instruction: SPARCInstruction, imm22: Imm22]
RETURNS [SPARCInstruction];
SetAnnul: PUBLIC PROCEDURE [instruction: SPARCInstruction, annul: Annul]
RETURNS [SPARCInstruction];
SetCond: PUBLIC PROCEDURE [instruction: SPARCInstruction, cond: Cond]
RETURNS [SPARCInstruction];
SetDisp22: PUBLIC PROCEDURE [instruction: SPARCInstruction, disp22: Disp22]
RETURNS [SPARCInstruction];
SetRs1: PUBLIC PROCEDURE [instruction: SPARCInstruction, rs1: Register]
RETURNS [SPARCInstruction];
RegisterMSFromRegister: PUBLIC PROCEDURE [register: Register]
RETURNS [RegisterMS];
RegisterLSFromRegister: PUBLIC PROCEDURE [register: Register]
RETURNS [RegisterLS];
SetI: PUBLIC PROCEDURE [instruction: SPARCInstruction, i: I]
RETURNS [SPARCInstruction];
SetASI: PUBLIC PROCEDURE [instruction: SPARCInstruction, asi: ASI]
RETURNS [SPARCInstruction];
SetRs2: PUBLIC PROCEDURE [instruction: SPARCInstruction, rs2: Register]
RETURNS [SPARCInstruction];
SetSimm13: PUBLIC PROCEDURE [instruction: SPARCInstruction, simm13: Simm13]
RETURNS [SPARCInstruction];
SetOpF: PUBLIC PROCEDURE [instruction: SPARCInstruction, opf: OpF]
RETURNS [SPARCInstruction];
SetOp3: PUBLIC PROCEDURE [instruction: SPARCInstruction, op3: Op3]
RETURNS [SPARCInstruction];
Op3FromOp10Op3: PUBLIC PROCEDURE [op10Op3: Op10Op3] RETURNS [Op3];
Op3FromOp11Op3: PUBLIC PROCEDURE [op11Op3: Op11Op3] RETURNS [Op3];
Unbiased30FromDisp30: PUBLIC PROCEDURE [disp30: Disp30] RETURNS [Unbiased30];
Unbiased30MSFromDisp30: PUBLIC PROCEDURE [disp30: Disp30]
RETURNS [Unbiased30MS];
Unbiased30LSFromDisp30: PUBLIC PROCEDURE [disp30: Disp30]
RETURNS [Unbiased30LS];
Unbiased22FromDisp22: PUBLIC PROCEDURE [disp22: Disp22] RETURNS [Unbiased22];
Unbiased22MSFromDisp22: PUBLIC PROCEDURE [disp22: Disp22]
RETURNS [Unbiased22MS];
Unbiased22LSFromDisp22: PUBLIC PROCEDURE [disp22: Disp22]
RETURNS [Unbiased22LS];
Unbiased22MSFromImm22: PUBLIC PROCEDURE [imm22: Imm22]
RETURNS [Unbiased22MS];
Unbiased22LSFromImm22: PUBLIC PROCEDURE [imm22: Imm22]
RETURNS [Unbiased22LS];
Unbiased13FromSimm13: PUBLIC PROCEDURE [simm13: Simm13] RETURNS [Unbiased13];
Miscellaneous.
IsNullSPARCAddress: PROCEDURE [address: SPARCAddress]
RETURNS
[BOOLEAN];
Tests if its argument is the null SPARCAddress.
SPARCAddressFromDisplacement: PROCEDURE [
address: SPARCAddress, displacement: TargetArchitecture.Displacement]
RETURNS [SPARCAddress];
DisplacementFromSPARCAddresses: PROCEDURE [
here: SPARCAddress, there: SPARCAddress]
RETURNS [TargetArchitecture.Displacement];
IsNullSPARCInstruction: PROCEDURE [instruction: SPARCInstruction]
RETURNS
[BOOLEAN];
Tests if its argument is the null SPARCInstruction.
NextSPARCInstruction: PROCEDURE [pc: SPARCAddress]
RETURNS [SPARCAddress];
Returns the address of the next instruction.
PrevSPARCInstruction: PROCEDURE [pc: SPARCAddress]
RETURNS [SPARCAddress];
Returns a pointer to the previous instruction.
SPARCAddressFromTargetAddress: PROCEDURE [address: TargetArchitecture.Address]
RETURNS [SPARCAddress];
TargetAddressFromSPARCAddress: PROCEDURE [
sparcAddress: SPARCAddress]
RETURNS [TargetArchitecture.Address];
SPARCContentsFromTargetContents: PROCEDURE [
contents: TargetArchitecture.Contents]
RETURNS [SPARCContents];
TargetContentsFromSPARCContents: PROCEDURE [
contents: SPARCContents]
RETURNS [TargetArchitecture.Contents];
SPARCInstructionFromTargetInstruction: PROCEDURE [
instruction: TargetArchitecture.Instruction]
RETURNS [SPARCInstruction];
TargetInstructionFromSPARCInstruction: PROCEDURE [
instruction: SPARCInstruction]
RETURNS [TargetArchitecture.Instruction];
SPARCRegisterClassFromTargetRegisterClass: PROCEDURE [
registerClass: TargetArchitecture.RegisterClass]
RETURNS [RegisterClass];
TargetRegisterClassFromSPARCRegisterClass: PROCEDURE [
registerClass: RegisterClass]
RETURNS [TargetArchitecture.RegisterClass];
Errors.
CantRelocate: ERROR;
Given for attempts to relocate an instruction too far, etc.
CantReach: ERROR;
Given for attempts to generate pc-relative instructions that don't reach.
NullSPARCAddress: ERROR;
Given during code generation when null addresses are supplied.
NullSPARCInstruction: ERROR;
Given when supplied instruction is the null instruction.
}.