SPARCArchitectureImpl.mesa
Copyright Ó 1989, 1991 by Xerox Corporation. All rights reserved.
Peter B. Kessler, April 9, 1990 3:31:21 pm PDT
Operations the debugger performs on the SPARC.
DIRECTORY
TargetArchitecture,
SPARCArchitecture,
RuntimeError;
SPARCArchitectureImpl: CEDAR PROGRAM
IMPORTS TargetArchitecture, SPARCArchitecture, RuntimeError
EXPORTS SPARCArchitecture
~ {
Code Assembly.
Noop: PUBLIC PROCEDURE []
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
This is a ``SETHI 0, %g0'', the recommended noop, since is doesn't increase the execution time of a load if it follows one.
format2Imm22: SPARCArchitecture.Format2Imm22 ~ [
op: SPARCArchitecture.Op.branch,
rd: SPARCArchitecture.Register.global0,
op2: SPARCArchitecture.Op2.sethi,
imm22MS: SPARCArchitecture.Imm22MS[0],
imm22LS: SPARCArchitecture.Imm22LS[0]
];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format2Imm22];
RETURN [instruction];
};
Ld: PUBLIC PROCEDURE [
base: SPARCArchitecture.Register,
offset: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other3,
rd: dest,
op3: SPARCArchitecture.Op3FromOp11Op3[op11Op3: SPARCArchitecture.Op11Op3.ld],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: base],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: base],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: offset]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
St: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
base: SPARCArchitecture.Register,
offset: SPARCArchitecture.Simm13]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other3,
rd: source,
op3: SPARCArchitecture.Op3FromOp11Op3[op11Op3: SPARCArchitecture.Op11Op3.st],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: base],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: base],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: offset]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
Sethi: PUBLIC PROCEDURE [
hi: SPARCArchitecture.Imm22, dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ~ [
op: SPARCArchitecture.Op.branch,
rd: dest,
op2: SPARCArchitecture.Op2.sethi,
imm22MS: SPARCArchitecture.Imm22MSFromImm22[hi],
imm22LS: SPARCArchitecture.Imm22LSFromImm22[hi]
];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format2Imm22];
RETURN [instruction];
};
BAa: PUBLIC PROCEDURE [
pc: SPARCArchitecture.SPARCAddress, to: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
displacement: TargetArchitecture.Displacement ~
SPARCArchitecture.DisplacementFromSPARCAddresses[here: pc, there: to];
instruction: SPARCArchitecture.SPARCInstruction ¬
SPARCArchitecture.nullSPARCInstruction;
IF pc.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
IF to.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
IF displacement NOT IN [SPARCArchitecture.firstDisp22 .. SPARCArchitecture.lastDisp22] THEN {
ERROR SPARCArchitecture.CantReach;
};
{
disp22: SPARCArchitecture.Disp22 ~
displacement / BYTES[SPARCArchitecture.SPARCInstruction];
format2Disp22: SPARCArchitecture.Format2Disp22 ~ [
op: SPARCArchitecture.Op.branch,
a: SPARCArchitecture.Annul.annul,
cond: SPARCArchitecture.Cond.always,
op2: SPARCArchitecture.Op2.bicc,
disp22MS: SPARCArchitecture.Unbiased22MSFromDisp22[disp22: disp22],
disp22LS: SPARCArchitecture.Unbiased22LSFromDisp22[disp22: disp22]
];
instruction ¬ LOOPHOLE[format2Disp22];
};
RETURN [instruction];
};
SaveConst: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
constant: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other2,
rd: dest,
op3: SPARCArchitecture.Op3FromOp10Op3[op10Op3: SPARCArchitecture.Op10Op3.save],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: source],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: source],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: constant]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
RestoreConst: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
constant: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other2,
rd: dest,
op3: SPARCArchitecture.Op3FromOp10Op3[op10Op3: SPARCArchitecture.Op10Op3.restore],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: source],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: source],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: constant]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
AddConst: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
constant: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other2,
rd: dest,
op3: SPARCArchitecture.Op3FromOp10Op3[op10Op3: SPARCArchitecture.Op10Op3.add],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: source],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: source],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: constant]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
SubConst: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
constant: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other2,
rd: dest,
op3: SPARCArchitecture.Op3FromOp10Op3[op10Op3: SPARCArchitecture.Op10Op3.sub],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: source],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: source],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: constant]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
OrConst: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
constant: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other2,
rd: dest,
op3: SPARCArchitecture.Op3FromOp10Op3[op10Op3: SPARCArchitecture.Op10Op3.or],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: source],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: source],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: constant]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
Call: PUBLIC PROCEDURE [
pc: SPARCArchitecture.SPARCAddress, to: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
displacement: TargetArchitecture.Displacement ~
SPARCArchitecture.DisplacementFromSPARCAddresses[here: pc, there: to];
disp30: SPARCArchitecture.Disp30 ~
displacement / BYTES[SPARCArchitecture.SPARCInstruction];
format1: SPARCArchitecture.Format1 ~ [
op: SPARCArchitecture.Op.call,
disp30MS: SPARCArchitecture.Unbiased30MSFromDisp30[disp30: disp30],
disp30LS: SPARCArchitecture.Unbiased30LSFromDisp30[disp30: disp30]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format1];
IF pc.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
IF to.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
IF (displacement MOD BYTES[SPARCArchitecture.SPARCInstruction]) # 0 THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [instruction];
};
JmplConst: PUBLIC PROCEDURE [
source: SPARCArchitecture.Register,
constant: SPARCArchitecture.Simm13,
dest: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3simm13: SPARCArchitecture.Format3Simm13 ~ [
op: SPARCArchitecture.Op.other2,
rd: dest,
op3: SPARCArchitecture.Op3FromOp10Op3[op10Op3: SPARCArchitecture.Op10Op3.jmpl],
rs1MS: SPARCArchitecture.RegisterMSFromRegister[register: source],
rs1LS: SPARCArchitecture.RegisterLSFromRegister[register: source],
i: SPARCArchitecture.I.useSimm13,
simm13: SPARCArchitecture.Unbiased13FromSimm13[simm13: constant]];
instruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[format3simm13];
RETURN [instruction];
};
Relocate: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction,
from: SPARCArchitecture.SPARCAddress,
to: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
Relocates an instruction from the given address to another address.
relocated: SPARCArchitecture.SPARCInstruction ¬ instruction;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
IF from.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
IF to.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
SELECT instruction.GetOp2[] FROM
SPARCArchitecture.Op2.bicc,
SPARCArchitecture.Op2.fbfcc,
SPARCArchitecture.Op2.cbccc => {
RelocateFormat2: PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction,
from: SPARCArchitecture.SPARCAddress,
to: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
relocated: SPARCArchitecture.SPARCInstruction ¬ instruction;
instructionDisp22: SPARCArchitecture.Disp22 ~ instruction.GetDisp22[];
byteDisplacement: TargetArchitecture.Displacement ~
instructionDisp22 * BYTES[SPARCArchitecture.SPARCInstruction];
targetAddress: SPARCArchitecture.SPARCAddress ~
SPARCArchitecture.SPARCAddressFromDisplacement[
address: from, displacement: byteDisplacement];
relocationDisplacement: TargetArchitecture.Displacement ~
SPARCArchitecture.DisplacementFromSPARCAddresses
[here: to, there: targetAddress];
relocationDisp22: SPARCArchitecture.Disp22 ~
relocationDisplacement / BYTES[SPARCArchitecture.SPARCInstruction];
IF relocationDisp22 NOT IN
[SPARCArchitecture.firstDisp22..SPARCArchitecture.lastDisp22] THEN {
ERROR SPARCArchitecture.CantRelocate;
};
IF relocationDisplacement MOD BYTES[SPARCArchitecture.SPARCInstruction]
# 0 THEN {
ERROR SPARCArchitecture.CantRelocate;
};
relocated ¬ instruction.SetDisp22[disp22: relocationDisp22];
RETURN [relocated];
};
relocated ¬ RelocateFormat2[instruction: instruction, from: from, to: to];
};
ENDCASE => {
NULL;
};
};
SPARCArchitecture.Op.call => {
RelocateFormat1: PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction,
from: SPARCArchitecture.SPARCAddress,
to: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
relocated: SPARCArchitecture.SPARCInstruction ¬ instruction;
instructionDisp30: SPARCArchitecture.Disp30 ~ instruction.GetDisp30[];
byteDisplacement: TargetArchitecture.Displacement ~
instructionDisp30 * BYTES[SPARCArchitecture.SPARCInstruction];
targetAddress: SPARCArchitecture.SPARCAddress ~
SPARCArchitecture.SPARCAddressFromDisplacement[
address: from, displacement: byteDisplacement];
relocationDisplacement: TargetArchitecture.Displacement ~
SPARCArchitecture.DisplacementFromSPARCAddresses
[here: to, there: targetAddress];
relocationDisp30: SPARCArchitecture.Disp30 ~
relocationDisplacement / BYTES[SPARCArchitecture.SPARCInstruction];
IF relocationDisp30 NOT IN
[SPARCArchitecture.firstDisp30..SPARCArchitecture.lastDisp30] THEN {
ERROR SPARCArchitecture.CantRelocate;
};
IF relocationDisplacement MOD BYTES[SPARCArchitecture.SPARCInstruction]
# 0 THEN {
ERROR SPARCArchitecture.CantRelocate;
};
relocated ¬ instruction.SetDisp30[disp30: relocationDisp30];
RETURN [relocated];
};
relocated ¬ RelocateFormat1[instruction: instruction, from: from, to: to];
};
SPARCArchitecture.Op.other2 => {
NULL;
};
SPARCArchitecture.Op.other3 => {
NULL;
};
ENDCASE => ERROR;
RETURN [relocated];
};
Instruction Classification.
IsDelayedControlTransfer: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction at the given pc has a delay slot.
hasDelayInstruction: BOOLEAN ¬ FALSE;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
SELECT instruction.GetOp2[] FROM
SPARCArchitecture.Op2.bicc,
SPARCArchitecture.Op2.fbfcc,
SPARCArchitecture.Op2.cbccc => {
hasDelayInstruction ¬ TRUE;
};
ENDCASE => {
hasDelayInstruction ¬ FALSE;
};
};
SPARCArchitecture.Op.call => {
hasDelayInstruction ¬ TRUE;
};
SPARCArchitecture.Op.other2 => {
op3: SPARCArchitecture.Op3 ~ instruction.GetOp3[];
SELECT op3.Op10Op3FromOp3[] FROM
SPARCArchitecture.Op10Op3.jmpl,
SPARCArchitecture.Op10Op3.rett => {
hasDelayInstruction ¬ TRUE;
};
ENDCASE => {
hasDelayInstruction ¬ FALSE;
};
};
SPARCArchitecture.Op.other3 => {
hasDelayInstruction ¬ FALSE;
};
ENDCASE => ERROR;
RETURN [hasDelayInstruction];
};
noopInstruction: SPARCArchitecture.SPARCInstruction ~ SPARCArchitecture.Noop[];
A sample noop instruction.
IsNoopInstruction: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction at the given pc is a noop.
isNoopInstruction: BOOLEAN ~ instruction = noopInstruction;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [isNoopInstruction];
};
NeedsRelocation: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction at the given pc has pc-relative operands.
needsRelocation: BOOLEAN ¬ FALSE;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
SELECT instruction.GetOp2[] FROM
SPARCArchitecture.Op2.bicc,
SPARCArchitecture.Op2.fbfcc,
SPARCArchitecture.Op2.cbccc => {
needsRelocation ¬ TRUE;
};
ENDCASE => {
needsRelocation ¬ FALSE;
};
};
SPARCArchitecture.Op.call => {
needsRelocation ¬ TRUE;
};
SPARCArchitecture.Op.other2 => {
needsRelocation ¬ FALSE;
};
SPARCArchitecture.Op.other3 => {
needsRelocation ¬ FALSE;
};
ENDCASE => ERROR;
RETURN [needsRelocation];
};
IsCallInstruction: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction is a call instruction.
isCallInstruction: BOOLEAN ¬ FALSE;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
isCallInstruction ¬ FALSE;
};
SPARCArchitecture.Op.call => {
isCallInstruction ¬ TRUE;
};
SPARCArchitecture.Op.other2 => {
isCallInstruction ¬ FALSE;
};
SPARCArchitecture.Op.other3 => {
isCallInstruction ¬ FALSE;
};
ENDCASE => ERROR;
RETURN [isCallInstruction];
};
IsDelayedBranchInstruction: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction is a delayed branch instruction.
isDelayedBranchInstruction: BOOLEAN ¬ FALSE;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
SELECT instruction.GetOp2[] FROM
SPARCArchitecture.Op2.bicc,
SPARCArchitecture.Op2.fbfcc,
SPARCArchitecture.Op2.cbccc => {
isDelayedBranchInstruction ¬ TRUE;
};
ENDCASE => {
isDelayedBranchInstruction ¬ FALSE;
};
};
SPARCArchitecture.Op.call => {
isDelayedBranchInstruction ¬ FALSE;
};
SPARCArchitecture.Op.other2 => {
isDelayedBranchInstruction ¬ FALSE;
};
SPARCArchitecture.Op.other3 => {
isDelayedBranchInstruction ¬ FALSE;
};
ENDCASE => ERROR;
RETURN [isDelayedBranchInstruction];
};
IsJmplO7Instruction: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction is a jmpl with %o7 as the link register.
isJmplO7Instruction: BOOLEAN ¬ FALSE;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
isJmplO7Instruction ¬ FALSE;
};
SPARCArchitecture.Op.call => {
isJmplO7Instruction ¬ FALSE;
};
SPARCArchitecture.Op.other2 => {
op3: SPARCArchitecture.Op3 ~ instruction.GetOp3[];
SELECT op3.Op10Op3FromOp3[] FROM
SPARCArchitecture.Op10Op3.jmpl => {
isJmplO7Instruction ¬ instruction.GetRd[] = SPARCArchitecture.Register.out7;
};
ENDCASE => {
isJmplO7Instruction ¬ FALSE;
};
};
SPARCArchitecture.Op.other3 => {
isJmplO7Instruction ¬ FALSE;
};
ENDCASE => ERROR;
RETURN [isJmplO7Instruction];
};
IsJmplG0Instruction: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Checks whether the instruction is a jmpl with %g0 as the link register.
isJmplG0Instruction: BOOLEAN ¬ FALSE;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => {
isJmplG0Instruction ¬ FALSE;
};
SPARCArchitecture.Op.call => {
isJmplG0Instruction ¬ FALSE;
};
SPARCArchitecture.Op.other2 => {
op3: SPARCArchitecture.Op3 ~ instruction.GetOp3[];
SELECT op3.Op10Op3FromOp3[] FROM
SPARCArchitecture.Op10Op3.jmpl => {
isJmplG0Instruction ¬ instruction.GetRd[] = SPARCArchitecture.Register.global0;
};
ENDCASE => {
isJmplG0Instruction ¬ FALSE;
};
};
SPARCArchitecture.Op.other3 => {
isJmplG0Instruction ¬ FALSE;
};
ENDCASE => ERROR;
RETURN [isJmplG0Instruction];
};
Field accessors for instructions.
GetFormat: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Format] ~ {
format: SPARCArchitecture.Format ~
SELECT instruction.GetOp[] FROM
SPARCArchitecture.Op.branch => SPARCArchitecture.Format.format2,
SPARCArchitecture.Op.call => SPARCArchitecture.Format.format1,
SPARCArchitecture.Op.other2 => SPARCArchitecture.Format.format2,
SPARCArchitecture.Op.other3 => SPARCArchitecture.Format.format3,
ENDCASE => ERROR;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [format];
};
GetOp: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Op] ~ {
format1: SPARCArchitecture.Format1 ~ LOOPHOLE[instruction];
op: SPARCArchitecture.Op ~ format1.op;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [op];
};
GetDisp30: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Disp30] ~ {
format1: SPARCArchitecture.Format1 ~ LOOPHOLE[instruction];
disp30: SPARCArchitecture.Disp30 ~
SPARCArchitecture.Disp30FromUnbiased30[
unbiased30MS: format1.disp30MS, unbiased30LS: format1.disp30LS];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [disp30];
};
GetRd: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Register] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ~ LOOPHOLE[instruction];
rd: SPARCArchitecture.Register ~ format2Imm22.rd;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [rd];
};
GetOp2: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Op2] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ~ LOOPHOLE[instruction];
op2: SPARCArchitecture.Op2 ~ format2Imm22.op2;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [op2];
};
GetImm22: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Imm22] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ~ LOOPHOLE[instruction];
imm22: SPARCArchitecture.Imm22 ~ SPARCArchitecture.Imm22FromImm22ML[
imm22MS: format2Imm22.imm22MS, imm22LS: format2Imm22.imm22LS];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [imm22];
};
GetAnnul: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Annul] ~ {
format2Disp22: SPARCArchitecture.Format2Disp22 ~ LOOPHOLE[instruction];
annul: SPARCArchitecture.Annul ~ format2Disp22.a;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [annul];
};
GetCond: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Cond] ~ {
format2Disp22: SPARCArchitecture.Format2Disp22 ~ LOOPHOLE[instruction];
cond: SPARCArchitecture.Cond ~ format2Disp22.cond;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [cond];
};
GetDisp22: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Disp22] ~ {
format2Disp22: SPARCArchitecture.Format2Disp22 ~ LOOPHOLE[instruction];
disp22: SPARCArchitecture.Disp22 ~
SPARCArchitecture.Disp22FromUnbiased22[
unbiased22MS: format2Disp22.disp22MS, unbiased22LS: format2Disp22.disp22LS];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [disp22];
};
GetRs1: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Register] ~ {
format3asi: SPARCArchitecture.Format3asi ~ LOOPHOLE[instruction];
rs1: SPARCArchitecture.Register ~ SPARCArchitecture.RegisterFromRegisterML[registerMS: format3asi.rs1MS, registerLS: format3asi.rs1LS];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [rs1];
};
RegisterFromRegisterML: PUBLIC PROCEDURE [
registerMS: SPARCArchitecture.RegisterMS,
registerLS: SPARCArchitecture.RegisterLS]
RETURNS [SPARCArchitecture.Register] ~ {
register: SPARCArchitecture.Register ~ VAL[
(registerMS * (LAST[SPARCArchitecture.RegisterLS] + 1)) + registerLS
];
RETURN [register];
};
GetI: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.I] ~ {
format3asi: SPARCArchitecture.Format3asi ~ LOOPHOLE[instruction];
i: SPARCArchitecture.I ~ format3asi.i;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [i];
};
GetASI: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.ASI] ~ {
format3asi: SPARCArchitecture.Format3asi ~ LOOPHOLE[instruction];
asi: SPARCArchitecture.ASI ~ format3asi.asi;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [asi];
};
GetRs2: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Register] ~ {
format3asi: SPARCArchitecture.Format3asi ~ LOOPHOLE[instruction];
rs2: SPARCArchitecture.Register ~ format3asi.rs2;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [rs2];
};
GetSimm13: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Simm13] ~ {
format3Simm13: SPARCArchitecture.Format3Simm13 ~ LOOPHOLE[instruction];
simm13: SPARCArchitecture.Simm13 ~
SPARCArchitecture.Simm13FromUnbiased13[unbiased13: format3Simm13.simm13];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [simm13];
};
GetOpF: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.OpF] ~ {
format3OpF: SPARCArchitecture.Format3OpF ~ LOOPHOLE[instruction];
opf: SPARCArchitecture.OpF ~ format3OpF.opf;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [opf];
};
GetOp3: PUBLIC PROCEDURE [instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [SPARCArchitecture.Op3] ~ {
format3TiccRs2: SPARCArchitecture.Format3TiccRs2 ~ LOOPHOLE[instruction];
op3: SPARCArchitecture.Op3 ~ format3TiccRs2.op3;
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [op3];
};
Op10Op3FromOp3: PUBLIC PROCEDURE [op3: SPARCArchitecture.Op3]
RETURNS [SPARCArchitecture.Op10Op3] ~ {
op10Op3: SPARCArchitecture.Op10Op3 ~ VAL[ORD[op3]];
RETURN [op10Op3];
};
Op11Op3FromOp3: PUBLIC PROCEDURE [op3: SPARCArchitecture.Op3]
RETURNS [SPARCArchitecture.Op11Op3] ~ {
op11Op3: SPARCArchitecture.Op11Op3 ~ VAL[ORD[op3]];
RETURN [op11Op3];
};
Disp30FromUnbiased30: PUBLIC PROCEDURE [
unbiased30MS: SPARCArchitecture.Unbiased30MS,
unbiased30LS: SPARCArchitecture.Unbiased30LS]
RETURNS [SPARCArchitecture.Disp30] ~ {
unbiased30: SPARCArchitecture.Unbiased30 ~
(unbiased30MS * (CARD32[LAST[SPARCArchitecture.Unbiased30LS]] + 1))
+ unbiased30LS;
disp30: SPARCArchitecture.Disp30 ~
IF unbiased30 <= SPARCArchitecture.Unbiased30[SPARCArchitecture.lastDisp30]
THEN unbiased30
ELSE -(SPARCArchitecture.lastUnbiased30 + 1 - unbiased30);
Since SPARCArchitecture.Disp30 isn't a biased subrange any more, this can just sign-extend the unbiased the representation.
IF unbiased30 NOT IN
[SPARCArchitecture.firstUnbiased30 .. SPARCArchitecture.lastUnbiased30] THEN {
ERROR RuntimeError.BoundsFault
};
RETURN [disp30];
};
Disp22FromUnbiased22: PUBLIC PROCEDURE [
unbiased22MS: SPARCArchitecture.Unbiased22MS,
unbiased22LS: SPARCArchitecture.Unbiased22LS]
RETURNS [SPARCArchitecture.Disp22] ~ {
unbiased22: SPARCArchitecture.Unbiased22 ~
(unbiased22MS * (CARD32[LAST[SPARCArchitecture.Unbiased22LS]] + 1))
+ unbiased22LS;
disp22: SPARCArchitecture.Disp22 ~
IF unbiased22 <= SPARCArchitecture.Unbiased22[SPARCArchitecture.lastDisp22]
THEN unbiased22
ELSE -(SPARCArchitecture.lastUnbiased22 + 1 - unbiased22);
Since SPARCArchitecture.Disp22 isn't a biased subrange any more, this can just sign-extend the unbiased the representation.
IF unbiased22 NOT IN
[SPARCArchitecture.firstUnbiased22 .. SPARCArchitecture.lastUnbiased22] THEN {
ERROR RuntimeError.BoundsFault
};
RETURN [disp22];
};
Imm22FromImm22ML: PUBLIC PROCEDURE [
imm22MS: SPARCArchitecture.Imm22MS,
imm22LS: SPARCArchitecture.Imm22LS]
RETURNS [SPARCArchitecture.Imm22] ~ {
imm22: SPARCArchitecture.Imm22 ~
(imm22MS * (CARD32[LAST[SPARCArchitecture.Imm22LS]] + 1)) + imm22LS;
IF NOT imm22 IN [SPARCArchitecture.firstImm22 .. SPARCArchitecture.lastImm22] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [imm22];
};
Imm22MSFromImm22: PUBLIC PROCEDURE [imm22: SPARCArchitecture.Imm22]
RETURNS [SPARCArchitecture.Imm22MS] ~ {
imm22MS: SPARCArchitecture.Imm22MS ~
imm22 / (CARD32[LAST[SPARCArchitecture.Imm22LS]] + 1);
IF NOT imm22 IN [SPARCArchitecture.firstImm22 .. SPARCArchitecture.lastImm22] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [imm22MS];
};
Imm22LSFromImm22: PUBLIC PROCEDURE [imm22: SPARCArchitecture.Imm22]
RETURNS [SPARCArchitecture.Imm22LS] ~ {
imm22LS: SPARCArchitecture.Imm22LS ~
imm22 MOD (CARD32[LAST[SPARCArchitecture.Imm22LS]] + 1);
IF NOT imm22 IN [SPARCArchitecture.firstImm22 .. SPARCArchitecture.lastImm22] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [imm22LS];
};
Simm13FromUnbiased13: PUBLIC PROCEDURE [unbiased13: SPARCArchitecture.Unbiased13]
RETURNS [SPARCArchitecture.Simm13] ~ {
biased: INT32 ~ IF unbiased13 <= SPARCArchitecture.lastSimm13
THEN unbiased13
ELSE -(SPARCArchitecture.lastUnbiased13 + 1 - unbiased13);
simm13: SPARCArchitecture.Simm13 ~ biased;
RETURN [simm13];
};
Hi: PUBLIC PROCEDURE [value: CARD32] RETURNS [SPARCArchitecture.Imm22] ~ {
hi: SPARCArchitecture.Imm22 ~ value / (CARD32[SPARCArchitecture.lastImm10] + 1);
RETURN [hi];
};
Lo: PUBLIC PROCEDURE [value: CARD32] RETURNS [SPARCArchitecture.Imm10] ~ {
lo: SPARCArchitecture.Imm10 ~ value MOD (CARD32[SPARCArchitecture.lastImm10] + 1);
RETURN [lo];
};
HiLo: PUBLIC PROCEDURE[hi: SPARCArchitecture.Imm22, lo: SPARCArchitecture.Imm10]
RETURNS [CARD32] ~ {
hiLo: CARD32 ~ (hi * (CARD32[SPARCArchitecture.lastImm10] + 1)) + lo;
IF hi NOT IN [SPARCArchitecture.firstImm22 .. SPARCArchitecture.lastImm22] THEN {
ERROR RuntimeError.BoundsFault;
};
IF lo NOT IN [SPARCArchitecture.firstImm22 .. SPARCArchitecture.lastImm22] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [hiLo];
};
Field assigners for instructions.
SetOp: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, op: SPARCArchitecture.Op]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format1: SPARCArchitecture.Format1 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format1.op ¬ op;
RETURN [LOOPHOLE[format1]];
};
SetDisp30: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, disp30: SPARCArchitecture.Disp30]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format1: SPARCArchitecture.Format1 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
IF disp30 NOT IN [SPARCArchitecture.firstDisp30 ..SPARCArchitecture.lastDisp30] THEN {
ERROR RuntimeError.BoundsFault;
};
format1.disp30MS ¬ SPARCArchitecture.Unbiased30MSFromDisp30[disp30: disp30];
format1.disp30LS ¬ SPARCArchitecture.Unbiased30LSFromDisp30[disp30: disp30];
RETURN [LOOPHOLE[format1]];
};
SetRd: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, rd: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format2Imm22.rd ¬ rd;
RETURN [LOOPHOLE[format2Imm22]];
};
SetOp2: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, op2: SPARCArchitecture.Op2]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format2Imm22.op2 ¬ op2;
RETURN [LOOPHOLE[format2Imm22]];
};
SetImm22: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, imm22: SPARCArchitecture.Imm22]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Imm22: SPARCArchitecture.Format2Imm22 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
IF imm22 NOT IN [SPARCArchitecture.firstImm22 .. SPARCArchitecture.lastImm22] THEN {
ERROR RuntimeError.BoundsFault;
};
format2Imm22.imm22MS ¬ SPARCArchitecture.Unbiased22MSFromImm22[imm22: imm22];
format2Imm22.imm22LS ¬ SPARCArchitecture.Unbiased22LSFromImm22[imm22: imm22];
RETURN [LOOPHOLE[format2Imm22]];
};
SetAnnul: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, annul: SPARCArchitecture.Annul]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Disp22: SPARCArchitecture.Format2Disp22 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format2Disp22.a ¬ annul;
RETURN [LOOPHOLE[format2Disp22]];
};
SetCond: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, cond: SPARCArchitecture.Cond]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Disp22: SPARCArchitecture.Format2Disp22 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format2Disp22.cond ¬ cond;
RETURN [LOOPHOLE[format2Disp22]];
};
SetDisp22: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, disp22: SPARCArchitecture.Disp22]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format2Disp22: SPARCArchitecture.Format2Disp22 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
IF disp22 NOT IN [SPARCArchitecture.firstDisp22 .. SPARCArchitecture.lastDisp22] THEN {
ERROR RuntimeError.BoundsFault;
};
format2Disp22.disp22MS ¬ SPARCArchitecture.Unbiased22MSFromDisp22[disp22: disp22];
format2Disp22.disp22LS ¬ SPARCArchitecture.Unbiased22LSFromDisp22[disp22: disp22];
RETURN [LOOPHOLE[format2Disp22]];
};
SetRs1: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, rs1: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3asi: SPARCArchitecture.Format3asi ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3asi.rs1MS ¬ SPARCArchitecture.RegisterMSFromRegister[register: rs1];
format3asi.rs1LS ¬ SPARCArchitecture.RegisterLSFromRegister[register: rs1];
RETURN [LOOPHOLE[format3asi]];
};
RegisterMSFromRegister: PUBLIC PROCEDURE [register: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.RegisterMS] ~ {
registerMS: SPARCArchitecture.RegisterMS ~
ORD[register] / (LAST[SPARCArchitecture.RegisterLS] + 1);
RETURN [registerMS];
};
RegisterLSFromRegister: PUBLIC PROCEDURE [register: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.RegisterLS]~ {
registerLS: SPARCArchitecture.RegisterLS ~
ORD[register] MOD (LAST[SPARCArchitecture.RegisterLS] + 1);
RETURN [registerLS];
};
SetI: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, i: SPARCArchitecture.I]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3asi: SPARCArchitecture.Format3asi ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3asi.i ¬ i;
RETURN [LOOPHOLE[format3asi]];
};
SetASI: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, asi: SPARCArchitecture.ASI]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3asi: SPARCArchitecture.Format3asi ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3asi.asi ¬ asi;
RETURN [LOOPHOLE[format3asi]];
};
SetRs2: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, rs2: SPARCArchitecture.Register]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3asi: SPARCArchitecture.Format3asi ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3asi.rs2 ¬ rs2;
RETURN [LOOPHOLE[format3asi]];
};
SetSimm13: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, simm13: SPARCArchitecture.Simm13]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3Simm13: SPARCArchitecture.Format3Simm13 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3Simm13.simm13 ¬ SPARCArchitecture.Unbiased13FromSimm13[simm13: simm13];
RETURN [LOOPHOLE[format3Simm13]];
};
SetOpF: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, opf: SPARCArchitecture.OpF]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3OpF: SPARCArchitecture.Format3OpF ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3OpF.opf ¬ opf;
RETURN [LOOPHOLE[format3OpF]];
};
SetOp3: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction, op3: SPARCArchitecture.Op3]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
format3TiccRs2: SPARCArchitecture.Format3TiccRs2 ¬ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
format3TiccRs2.op3 ¬ op3;
RETURN [LOOPHOLE[format3TiccRs2]];
};
Op3FromOp10Op3: PUBLIC PROCEDURE [op10Op3: SPARCArchitecture.Op10Op3]
RETURNS [SPARCArchitecture.Op3] ~ {
op3: SPARCArchitecture.Op3 ~ VAL[ORD[op10Op3]];
RETURN [op3];
};
Op3FromOp11Op3: PUBLIC PROCEDURE [op11Op3: SPARCArchitecture.Op11Op3]
RETURNS [SPARCArchitecture.Op3] ~ {
op3: SPARCArchitecture.Op3 ~ VAL[ORD[op11Op3]];
RETURN [op3];
};
Unbiased30FromDisp30: PUBLIC PROCEDURE [disp30: SPARCArchitecture.Disp30]
RETURNS [SPARCArchitecture.Unbiased30] ~ {
Since SPARCArchitecture.Disp30 isn't a biased subrange any more, all I have to do is pick off the right bits.
unbiased: CARD32 ~ LOOPHOLE[disp30];
unbiased30: SPARCArchitecture.Unbiased30 ~
unbiased MOD (SPARCArchitecture.lastUnbiased30 + 1);
IF disp30 NOT IN [SPARCArchitecture.firstDisp30 .. SPARCArchitecture.lastDisp30] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [unbiased30];
};
Unbiased30MSFromDisp30: PUBLIC PROCEDURE [disp30: SPARCArchitecture.Disp30]
RETURNS [SPARCArchitecture.Unbiased30MS] ~ {
unbiased30: SPARCArchitecture.Unbiased30 ~
SPARCArchitecture.Unbiased30FromDisp30[disp30: disp30];
unbiased30MS: SPARCArchitecture.Unbiased30MS ~
unbiased30 / (CARD32[LAST[SPARCArchitecture.Unbiased30LS]] + 1);
IF disp30 NOT IN [SPARCArchitecture.firstDisp30 .. SPARCArchitecture.lastDisp30] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [unbiased30MS];
};
Unbiased30LSFromDisp30: PUBLIC PROCEDURE [disp30: SPARCArchitecture.Disp30]
RETURNS [SPARCArchitecture.Unbiased30LS] ~ {
unbiased30: SPARCArchitecture.Unbiased30 ~
SPARCArchitecture.Unbiased30FromDisp30[disp30: disp30];
unbiased30LS: SPARCArchitecture.Unbiased30LS ~
unbiased30 MOD (CARD32[LAST[SPARCArchitecture.Unbiased30LS]] + 1);
RETURN [unbiased30LS];
};
Unbiased22FromDisp22: PUBLIC PROCEDURE [disp22: SPARCArchitecture.Disp22]
RETURNS [SPARCArchitecture.Unbiased22] ~ {
Since SPARCArchitecture.Disp22 isn't a biased subrange any more, all I have to do is pick off the right bits.
unbiased: CARD32 ~ LOOPHOLE[disp22];
unbiased22: SPARCArchitecture.Unbiased22 ~
unbiased MOD (SPARCArchitecture.lastUnbiased22 + 1);
IF disp22 NOT IN [SPARCArchitecture.firstDisp22 .. SPARCArchitecture.lastDisp22] THEN {
ERROR RuntimeError.BoundsFault;
};
RETURN [unbiased22];
};
Unbiased22MSFromDisp22: PUBLIC PROCEDURE [disp22: SPARCArchitecture.Disp22]
RETURNS [SPARCArchitecture.Unbiased22MS] ~ {
unbiased22: SPARCArchitecture.Unbiased22 ~
SPARCArchitecture.Unbiased22FromDisp22[disp22: disp22];
unbiased22MS: SPARCArchitecture.Unbiased22MS ~
unbiased22 / (CARD32[LAST[SPARCArchitecture.Unbiased22LS]] + 1);
RETURN [unbiased22MS];
};
Unbiased22LSFromDisp22: PUBLIC PROCEDURE [disp22: SPARCArchitecture.Disp22]
RETURNS [SPARCArchitecture.Unbiased22LS] ~ {
unbiased22: SPARCArchitecture.Unbiased22 ~
SPARCArchitecture.Unbiased22FromDisp22[disp22: disp22];
unbiased22LS: SPARCArchitecture.Unbiased22LS ~
unbiased22 MOD (CARD32[LAST[SPARCArchitecture.Unbiased22LS]] + 1);
RETURN [unbiased22LS];
};
Unbiased22MSFromImm22: PUBLIC PROCEDURE [imm22: SPARCArchitecture.Imm22]
RETURNS [SPARCArchitecture.Unbiased22MS] ~ {
unbiased22MS: SPARCArchitecture.Unbiased22MS ~
imm22 / (CARD32[LAST[SPARCArchitecture.Unbiased22LS]] + 1);
RETURN [unbiased22MS];
};
Unbiased22LSFromImm22: PUBLIC PROCEDURE [imm22: SPARCArchitecture.Imm22]
RETURNS [SPARCArchitecture.Unbiased22LS] ~ {
unbiased22LS: SPARCArchitecture.Unbiased22LS ~
imm22 MOD (CARD32[LAST[SPARCArchitecture.Unbiased22LS]] + 1);
RETURN [unbiased22LS];
};
Unbiased13FromSimm13: PUBLIC PROCEDURE [simm13: SPARCArchitecture.Simm13]
RETURNS [SPARCArchitecture.Unbiased13] ~ {
biased: INT32 ~ simm13;
unbiased13: SPARCArchitecture.Unbiased13 ~
IF biased >= 0
THEN biased
ELSE SPARCArchitecture.lastUnbiased13 + 1 + biased;
RETURN [unbiased13];
};
Miscellaneous.
IsNullSPARCAddress: PUBLIC PROCEDURE [address: SPARCArchitecture.SPARCAddress]
RETURNS [BOOLEAN] ~ {
Tests if its argument is the null SPARCAddress.
isNullSPARCAddress: BOOLEAN ~ address = SPARCArchitecture.nullSPARCAddress;
RETURN [isNullSPARCAddress];
};
SPARCAddressFromDisplacement: PUBLIC PROCEDURE [
address: SPARCArchitecture.SPARCAddress,
displacement: TargetArchitecture.Displacement]
RETURNS [SPARCArchitecture.SPARCAddress] ~ {
targetAddress: TargetArchitecture.Address ~
SPARCArchitecture.TargetAddressFromSPARCAddress[sparcAddress: address];
displaced: TargetArchitecture.Address ~
TargetArchitecture.AddressFromDisplacement[
address: targetAddress, displacement: displacement];
sparcDisplaced: SPARCArchitecture.SPARCAddress ~ SPARCArchitecture.SPARCAddressFromTargetAddress[address: displaced];
IF address.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
RETURN [sparcDisplaced];
};
DisplacementFromSPARCAddresses: PUBLIC PROCEDURE [
here: SPARCArchitecture.SPARCAddress, there: SPARCArchitecture.SPARCAddress]
RETURNS [TargetArchitecture.Displacement] ~ {
hereTarget: TargetArchitecture.Address ~
SPARCArchitecture.TargetAddressFromSPARCAddress[sparcAddress: here];
thereTarget: TargetArchitecture.Address ~
SPARCArchitecture.TargetAddressFromSPARCAddress[sparcAddress: there];
displacement: TargetArchitecture.Displacement ~
TargetArchitecture.DisplacementFromAddresses[
here: hereTarget, there: thereTarget];
IF here.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
IF there.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
RETURN [displacement];
};
IsNullSPARCInstruction: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [BOOLEAN] ~ {
Tests if its argument is the null SPARCInstruction.
isNullSPARCInstruction: BOOLEAN ~
instruction = SPARCArchitecture.nullSPARCInstruction;
RETURN [isNullSPARCInstruction];
};
NextSPARCInstruction: PUBLIC PROCEDURE [pc: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCAddress] ~ TRUSTED {
Returns the instruction address after the given one.
targetPC: TargetArchitecture.Address ~
SPARCArchitecture.TargetAddressFromSPARCAddress[sparcAddress: pc];
nextInstruction: TargetArchitecture.Address ~
TargetArchitecture.NextInstruction[pc: targetPC];
nextSPARCInstruction: SPARCArchitecture.SPARCAddress ~
SPARCArchitecture.SPARCAddressFromTargetAddress[address: nextInstruction];
IF pc.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
RETURN [nextSPARCInstruction];
};
PrevSPARCInstruction: PUBLIC PROCEDURE [pc: SPARCArchitecture.SPARCAddress]
RETURNS [SPARCArchitecture.SPARCAddress] ~ {
Returns a pointer to the previous instruction.
Yeah for being able to back up in instruction streams, boo for needing to.
targetPC: TargetArchitecture.Address ~
SPARCArchitecture.TargetAddressFromSPARCAddress[sparcAddress: pc];
prevInstruction: TargetArchitecture.Address ~
TargetArchitecture.PrevInstruction[pc: targetPC];
prevSPARCInstruction: SPARCArchitecture.SPARCAddress ~
SPARCArchitecture.SPARCAddressFromTargetAddress[address: prevInstruction];
IF pc.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
RETURN [prevSPARCInstruction];
};
SPARCAddressFromTargetAddress: PUBLIC PROCEDURE [
address: TargetArchitecture.Address]
RETURNS [SPARCArchitecture.SPARCAddress] ~ {
sparcAddress: SPARCArchitecture.SPARCAddress ~ LOOPHOLE[address];
IF sparcAddress.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
RETURN [sparcAddress];
};
TargetAddressFromSPARCAddress: PUBLIC PROCEDURE [
sparcAddress: SPARCArchitecture.SPARCAddress]
RETURNS [TargetArchitecture.Address] ~ {
address: TargetArchitecture.Address ~ LOOPHOLE[sparcAddress];
IF sparcAddress.IsNullSPARCAddress[] THEN {
ERROR SPARCArchitecture.NullSPARCAddress;
};
RETURN [address];
};
SPARCContentsFromTargetContents: PUBLIC PROCEDURE [
contents: TargetArchitecture.Contents]
RETURNS [SPARCArchitecture.SPARCContents] ~ {
sparcContents: SPARCArchitecture.SPARCContents ~ LOOPHOLE[contents];
RETURN [sparcContents];
};
TargetContentsFromSPARCContents: PUBLIC PROCEDURE [
contents: SPARCArchitecture.SPARCContents]
RETURNS [TargetArchitecture.Contents] ~ {
targetContents: TargetArchitecture.Contents ~ LOOPHOLE[contents];
RETURN [targetContents];
};
SPARCInstructionFromTargetInstruction: PUBLIC PROCEDURE [
instruction: TargetArchitecture.Instruction]
RETURNS [SPARCArchitecture.SPARCInstruction] ~ {
sparcInstruction: SPARCArchitecture.SPARCInstruction ~ LOOPHOLE[instruction];
IF sparcInstruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [sparcInstruction];
};
TargetInstructionFromSPARCInstruction: PUBLIC PROCEDURE [
instruction: SPARCArchitecture.SPARCInstruction]
RETURNS [TargetArchitecture.Instruction] ~ {
targetInstruction: TargetArchitecture.Instruction ~ LOOPHOLE[instruction];
IF instruction.IsNullSPARCInstruction[] THEN {
ERROR SPARCArchitecture.NullSPARCInstruction;
};
RETURN [targetInstruction];
};
SPARCRegisterClassFromTargetRegisterClass: PUBLIC PROCEDURE [
registerClass: TargetArchitecture.RegisterClass]
RETURNS [SPARCArchitecture.RegisterClass] ~ {
sparcRegisterClass: SPARCArchitecture.RegisterClass ~ LOOPHOLE[registerClass];
SELECT sparcRegisterClass FROM
none,
globals,
globalsAndIns,
globalsInsAndFloats,
globalsInsFloatsOutsAndLocals,
all => {
NULL;
};
ENDCASE => {
ERROR RuntimeError.BoundsFault;
};
RETURN [sparcRegisterClass];
};
TargetRegisterClassFromSPARCRegisterClass: PUBLIC PROCEDURE [
registerClass: SPARCArchitecture.RegisterClass]
RETURNS [TargetArchitecture.RegisterClass] ~ {
targetRegisterClass: TargetArchitecture.RegisterClass ~ LOOPHOLE[registerClass];
SELECT registerClass FROM
none,
globals,
globalsAndIns,
globalsInsAndFloats,
globalsInsFloatsOutsAndLocals,
all => {
NULL;
};
ENDCASE => {
ERROR RuntimeError.BoundsFault;
};
RETURN [targetRegisterClass];
};
Errors.
CantRelocate: PUBLIC ERROR ~ CODE;
Given for attempts to relocate an instruction too far, etc.
CantReach: PUBLIC ERROR ~ CODE;
Given for attempts to generate pc-relative instructions that don't reach.
NullSPARCAddress: PUBLIC ERROR ~ CODE;
Given during code generation when null addresses are supplied.
NullSPARCInstruction: PUBLIC ERROR ~ CODE;
Given when supplied instruction is the null instruction.
}.