DIRECTORY TargetArchitecture, RS6000Architecture, RuntimeError; RS6000ArchitectureImpl: CEDAR PROGRAM IMPORTS TargetArchitecture, RS6000Architecture, RuntimeError EXPORTS RS6000Architecture ~ { Ai: PUBLIC PROCEDURE [ rt: RS6000Architecture.Register, ra: RS6000Architecture.Register, si: RS6000Architecture.SI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rsi: RS6000Architecture.Format2rsi ~ [ op: RS6000Architecture.Op.ai, rt: rt, ra: ra, si: si]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rsi]; RETURN [instruction]; }; B: PUBLIC PROCEDURE [ pc: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address, abs, link: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction] ~ { displacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses[here: pc, there: to]; instruction: RS6000Architecture.RS6000Instruction _ RS6000Architecture.nullRS6000Instruction; IF pc.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF to.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF displacement NOT IN [RS6000Architecture.firstOffset26 .. RS6000Architecture.lastOffset26] THEN { ERROR RS6000Architecture.CantReach; }; { disp24: RS6000Architecture.Disp24 ~ displacement / BYTES[RS6000Architecture.RS6000Instruction]; msb: BOOLEAN ~ disp24 IN [RS6000Architecture.firstDisp24..0]; disp23: RS6000Architecture.Disp23 ~ IF msb THEN disp24 - RS6000Architecture.firstDisp24 ELSE disp24; formatBranch: RS6000Architecture.FormatBranch ~ [ op: RS6000Architecture.Op.b, limsb: msb, li: disp23, aa: abs, lk: link ]; instruction _ LOOPHOLE[formatBranch]; }; RETURN [instruction]; }; Brl: PUBLIC PROCEDURE [] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatBOnCondCount: RS6000Architecture.FormatBOnCondCount ~ [ op: RS6000Architecture.Op.group19, bo: [TRUE, FALSE, TRUE, FALSE, FALSE], bi: 0, subOp: RS6000Architecture.SubOpFor19.bcr, lk: FALSE ]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatBOnCondCount]; RETURN [instruction]; }; Bctr: PUBLIC PROCEDURE [] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatBOnCondCount: RS6000Architecture.FormatBOnCondCount ~ [ op: RS6000Architecture.Op.group19, bo: [TRUE, FALSE, TRUE, FALSE, FALSE], bi: 0, subOp: RS6000Architecture.SubOpFor19.bcc, lk: FALSE ]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatBOnCondCount]; RETURN [instruction]; }; Cror: PUBLIC PROCEDURE [bt: RS6000Architecture.CCBitPosition, ba: RS6000Architecture.CCBitPosition, bb: RS6000Architecture.CCBitPosition, lk: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatCondRegAnd: RS6000Architecture.FormatCondRegAnd ~ [ op: RS6000Architecture.Op.group19, bt: bt, ba: ba, bb: bb, subOp: RS6000Architecture.SubOpFor19.cror, lk: lk]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatCondRegAnd]; RETURN [instruction]; }; L: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.l, rt: rt, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Lil: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, low: RS6000Architecture.SI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoadi: RS6000Architecture.FormatLoadi ~ [op: RS6000Architecture.Op.cal, rt: rt, zero: 0, si: low]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoadi]; RETURN [instruction]; }; Liu: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, upper: RS6000Architecture.UI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoadui: RS6000Architecture.FormatLoadui ~ [op: RS6000Architecture.Op.cau, rt: rt, zero: 0, ui: upper]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoadui]; RETURN [instruction]; }; Lm: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.lm, rt: rt, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Mfspr: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, spr: RS6000Architecture.SpecialRegister, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatMoveSPR: RS6000Architecture.FormatMoveSPR ~ [ op: RS6000Architecture.Op.group31, rt: rt, spr: spr, subOp: RS6000Architecture.SubOpFor31withoutOE.mfspr, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveSPR]; RETURN [instruction]; }; Mtspr: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, spr: RS6000Architecture.SpecialRegister, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatMoveSPR: RS6000Architecture.FormatMoveSPR ~ [ op: RS6000Architecture.Op.group31, rt: rt, spr: spr, subOp: RS6000Architecture.SubOpFor31withoutOE.mtspr, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveSPR]; RETURN [instruction]; }; Mfcr: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatMoveFromCR: RS6000Architecture.FormatMoveFromCR ~ [ op: RS6000Architecture.Op.group31, rt: rs, subOp: RS6000Architecture.SubOpFor31withoutOE.mfcr, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveFromCR]; RETURN [instruction]; }; Mtcrf: PUBLIC PROCEDURE [fxm: RS6000Architecture.FXM, rs: RS6000Architecture.Register, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatMoveToCRField: RS6000Architecture.FormatMoveToCRField ~ [ op: RS6000Architecture.Op.group31, rs: rs, fxm: fxm, subOp: RS6000Architecture.SubOpFor31withoutOE.mtcrf, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveToCRField]; RETURN [instruction]; }; Noop: PUBLIC PROCEDURE [] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatMask: RS6000Architecture.FormatMask ~ [ op: RS6000Architecture.Op.group31, rs: RS6000Architecture.Register.gpr0, ra: RS6000Architecture.Register.gpr0, rb: RS6000Architecture.Register.gpr0, subOp: RS6000Architecture.SubOpFor31withoutOE.or, rc: FALSE ]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMask]; RETURN [instruction]; }; OrLConst: PUBLIC PROCEDURE [ ra: RS6000Architecture.Register, rs: RS6000Architecture.Register, ui: RS6000Architecture.UI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rui: RS6000Architecture.Format2rui ~ [ op: RS6000Architecture.Op.oril, rt: rs, ra: ra, ui: ui]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rui]; RETURN [instruction]; }; OrUConst: PUBLIC PROCEDURE [ ra: RS6000Architecture.Register, rs: RS6000Architecture.Register, ui: RS6000Architecture.UI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rui: RS6000Architecture.Format2rui ~ [ op: RS6000Architecture.Op.oril, rt: rs, ra: ra, ui: ui]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rui]; RETURN [instruction]; }; St: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.st, rt: rs, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Stm: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.stm, rt: rs, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Stu: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.stu, rt: rs, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Si: PUBLIC PROCEDURE [ rt: RS6000Architecture.Register, ra: RS6000Architecture.Register, si: RS6000Architecture.SI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rsi: RS6000Architecture.Format2rsi ~ [ op: RS6000Architecture.Op.ai, rt: rt, ra: ra, si: -si]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rsi]; RETURN [instruction]; }; Relocate: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF from.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF to.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.dozi => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.cmpli => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.cmpi => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.ai => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.aiDot => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.cal => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.cau => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.bc => {relocated _ DoRelocateForBranch16bits[instruction, from, to];}; RS6000Architecture.Op.b => {relocated _ DoRelocateForBranch26bits[instruction, from, to];}; RS6000Architecture.Op.group19 => {relocated _ RelocateGroup19[instruction, from, to];}; RS6000Architecture.Op.rlimi => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.rlinm => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.rlmi => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.rlnm => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.oril => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.oriu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.xoril => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.xoriu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.andil => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.andiu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.group31 => {relocated _ RelocateGroup31[instruction, from, to];}; RS6000Architecture.Op.l => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lbz => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lbzu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.st => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stb => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lhz => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lhzu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lha => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lhau => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.sth => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lm => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stm => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lfs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lfsu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lfd => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.lfdu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stfs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stfsu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stfd => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.stfdu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.Op.group63 => {relocated _ RelocateGroup63[instruction, from, to];}; ENDCASE => {ERROR;}; RETURN [relocated]; }; RelocateGroup19: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; SELECT instruction.GetSubOp19[] FROM RS6000Architecture.SubOpFor19.mcrf => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.bcr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crnor => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crandc => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crxor => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crnand => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crand => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.creqv => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crorc => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.cror => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.bcc => {relocated _ NoRelocate[instruction];}; ENDCASE => {ERROR;}; RETURN [relocated]; }; RelocateGroup31: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; SELECT instruction.GetSubOp31withoutOE[] FROM RS6000Architecture.SubOpFor31withoutOE.cmp => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.t => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mfcr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sl => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.cntlz => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.and => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.maskg => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.cmpl => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.andc => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mfmsr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lbzx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lbzux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.nor => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mtcrf => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.slq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sle => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sliq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stbx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sllq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sleq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stbux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.slliq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lscbx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhzx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhzux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.xor => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mfspr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhax => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhaux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sthx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.orc => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sthux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.or => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mtspr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.nand => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mcrxr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lsx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lbrx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfsx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.rrib => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.maskir => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfsux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lsi => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfdx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfdux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stsx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stbrx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfsx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sre => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfsux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sriq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfdx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srlq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sreq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfdux => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srliq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhbrx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sra => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srai => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sthbrx => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sraq => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srea => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sraiq => {relocated _ NoRelocate[instruction];}; ENDCASE => { SELECT instruction.GetSubOp31withOE[] FROM RS6000Architecture.SubOpFor31withOE.sf => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.a => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.mul => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.sfe => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.ae => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.sfze => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.aze => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.sfme => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.me => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.muls => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.doz => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.cax => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.eqv => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.adiv => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.abs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.divs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.nabs => {relocated _ NoRelocate[instruction];}; ENDCASE => {ERROR;}; }; RETURN [relocated]; }; RelocateGroup63: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; SELECT instruction.GetSubOp3r63[] FROM RS6000Architecture.FSubOp3r63.fd => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fa => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fm => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fms => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fma => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fnms => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fnma => {relocated _ NoRelocate[instruction];}; ENDCASE => { SELECT instruction.GetSubOp2r63[] FROM RS6000Architecture.FSubOp2r63.fcmpu => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.frsp => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fcmpo => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsb1 => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fneg => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mcrfs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsb0 => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fmr => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsfi => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fnabs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fabs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mffs => {relocated _ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsf => {relocated _ NoRelocate[instruction];}; ENDCASE => {ERROR;}; }; RETURN [relocated]; }; NoRelocate: PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.RS6000Instruction] ~ { RETURN [instruction]; }; DoRelocateForBranch16bits: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; instructionDisp14: RS6000Architecture.Disp14 ~ instruction.GetDisp14[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp14 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses[here: to, there: targetAddress]; relocationDisp14: RS6000Architecture.Disp14 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp14 NOT IN [RS6000Architecture.firstDisp14..RS6000Architecture.lastDisp14] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated _ instruction.SetDisp14[disp14: relocationDisp14]; RETURN [relocated]; }; DoRelocateForBranch26bits: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; instructionDisp24: RS6000Architecture.Disp24 ~ instruction.GetDisp24[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp24 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses[here: to, there: targetAddress]; relocationDisp24: RS6000Architecture.Disp24 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp24 NOT IN [RS6000Architecture.firstDisp24..RS6000Architecture.lastDisp24] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated _ instruction.SetDisp24[disp24: relocationDisp24]; RETURN [instruction]; }; noopInstruction: RS6000Architecture.RS6000Instruction ~ RS6000Architecture.Noop[]; IsNoopInstruction: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { isNoopInstruction: BOOLEAN ~ instruction = noopInstruction; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [isNoopInstruction]; }; GetOp: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Op] ~ { formatGeneric: RS6000Architecture.Format3rArith ~ LOOPHOLE[instruction]; op: RS6000Architecture.Op ~ formatGeneric.op; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [op]; }; GetSubOp19: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.SubOpFor19] ~ { formatGeneric: RS6000Architecture.FormatCondRegAnd ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.SubOpFor19 ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp31withoutOE: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.SubOpFor31withoutOE] ~ { formatGeneric: RS6000Architecture.FormatCmp ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.SubOpFor31withoutOE ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp31withOE: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.SubOpFor31withOE] ~ { formatGeneric: RS6000Architecture.Format2rArith ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.SubOpFor31withOE ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp3r63: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.FSubOp3r63] ~ { formatGeneric: RS6000Architecture.FormatFl3rArith ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.FSubOp3r63 ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp2r63: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.FSubOp2r63] ~ { formatGeneric: RS6000Architecture.FormatFl2rArith ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.FSubOp2r63 ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetDisp14: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp14] ~ { formatBOnCond: RS6000Architecture.FormatBOnCond ~ LOOPHOLE[instruction]; disp14: RS6000Architecture.Disp14 ~ IF formatBOnCond.bdmsb THEN formatBOnCond.bd + RS6000Architecture.firstDisp14 ELSE formatBOnCond.bd; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp14]; }; GetDisp24: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp24] ~ { formatBranch: RS6000Architecture.FormatBranch ~ LOOPHOLE[instruction]; disp24: RS6000Architecture.Disp24 ~ IF formatBranch.limsb THEN formatBranch.li + RS6000Architecture.firstDisp24 ELSE formatBranch.li; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp24]; }; High: PUBLIC PROCEDURE [value: CARD32] RETURNS [RS6000Architecture.UI] ~ { hi: RS6000Architecture.UI ~ value / (LAST[CARD16] + 1); RETURN [hi]; }; Low: PUBLIC PROCEDURE [value: CARD32] RETURNS [RS6000Architecture.UI] ~ { lo: RS6000Architecture.SI ~ value MOD (LAST[CARD16] + 1); RETURN [lo]; }; SetOp: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, op: RS6000Architecture.Op] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatGeneric: RS6000Architecture.Format3rArith _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; formatGeneric.op _ op; RETURN [LOOPHOLE[formatGeneric]]; }; SetDisp14: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp14: RS6000Architecture.Disp14] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatBOnCond: RS6000Architecture.FormatBOnCond _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp14 NOT IN [RS6000Architecture.firstDisp14 ..RS6000Architecture.lastDisp14] THEN { ERROR RuntimeError.BoundsFault; }; formatBOnCond.bdmsb _ disp14 IN [RS6000Architecture.firstDisp14..0]; formatBOnCond.bd _ IF formatBOnCond.bdmsb THEN disp14 - RS6000Architecture.firstDisp14 ELSE disp14; RETURN [LOOPHOLE[formatBOnCond]]; }; SetDisp24: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp24: RS6000Architecture.Disp24] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatBranch: RS6000Architecture.FormatBranch _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp24 NOT IN [RS6000Architecture.firstDisp24 ..RS6000Architecture.lastDisp24] THEN { ERROR RuntimeError.BoundsFault; }; formatBranch.limsb _ disp24 IN [RS6000Architecture.firstDisp24..0]; formatBranch.li _ IF formatBranch.limsb THEN disp24 - RS6000Architecture.firstDisp24 ELSE disp24; RETURN [LOOPHOLE[formatBranch]]; }; IsNullRS6000Address: PUBLIC PROCEDURE [address: RS6000Architecture.RS6000Address] RETURNS [BOOLEAN] ~ { isNullRS6000Address: BOOLEAN ~ address = RS6000Architecture.nullRS6000Address; RETURN [isNullRS6000Address]; }; RS6000AddressFromDisplacement: PUBLIC PROCEDURE [ address: RS6000Architecture.RS6000Address, displacement: TargetArchitecture.Displacement] RETURNS [RS6000Architecture.RS6000Address] ~ { targetAddress: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: address]; displaced: TargetArchitecture.Address ~ TargetArchitecture.AddressFromDisplacement[ address: targetAddress, displacement: displacement]; rs6000Displaced: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromTargetAddress[address: displaced]; IF address.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [rs6000Displaced]; }; DisplacementFromRS6000Addresses: PUBLIC PROCEDURE [ here: RS6000Architecture.RS6000Address, there: RS6000Architecture.RS6000Address] RETURNS [TargetArchitecture.Displacement] ~ { hereTarget: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: here]; thereTarget: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: there]; displacement: TargetArchitecture.Displacement ~ TargetArchitecture.DisplacementFromAddresses[ here: hereTarget, there: thereTarget]; IF here.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF there.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [displacement]; }; IsNullRS6000Instruction: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { isNullRS6000Instruction: BOOLEAN ~ instruction = RS6000Architecture.nullRS6000Instruction; RETURN [isNullRS6000Instruction]; }; NextRS6000Instruction: PUBLIC PROCEDURE [pc: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Address] ~ TRUSTED { targetPC: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: pc]; nextInstruction: TargetArchitecture.Address ~ TargetArchitecture.NextInstruction[pc: targetPC]; nextRS6000Instruction: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromTargetAddress[address: nextInstruction]; IF pc.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [nextRS6000Instruction]; }; PrevRS6000Instruction: PUBLIC PROCEDURE [pc: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Address] ~ { targetPC: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: pc]; prevInstruction: TargetArchitecture.Address ~ TargetArchitecture.PrevInstruction[pc: targetPC]; prevRS6000Instruction: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromTargetAddress[address: prevInstruction]; IF pc.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [prevRS6000Instruction]; }; RS6000AddressFromTargetAddress: PUBLIC PROCEDURE [ address: TargetArchitecture.Address] RETURNS [RS6000Architecture.RS6000Address] ~ { rs6000Address: RS6000Architecture.RS6000Address ~ LOOPHOLE[address]; IF rs6000Address.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [rs6000Address]; }; TargetAddressFromRS6000Address: PUBLIC PROCEDURE [ rs6000Address: RS6000Architecture.RS6000Address] RETURNS [TargetArchitecture.Address] ~ { address: TargetArchitecture.Address ~ LOOPHOLE[rs6000Address]; IF rs6000Address.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [address]; }; RS6000ContentsFromTargetContents: PUBLIC PROCEDURE [ contents: TargetArchitecture.Contents] RETURNS [RS6000Architecture.RS6000Contents] ~ { rs6000Contents: RS6000Architecture.RS6000Contents ~ LOOPHOLE[contents]; RETURN [rs6000Contents]; }; TargetContentsFromRS6000Contents: PUBLIC PROCEDURE [ contents: RS6000Architecture.RS6000Contents] RETURNS [TargetArchitecture.Contents] ~ { targetContents: TargetArchitecture.Contents ~ LOOPHOLE[contents]; RETURN [targetContents]; }; RS6000InstructionFromTargetInstruction: PUBLIC PROCEDURE [ instruction: TargetArchitecture.Instruction] RETURNS [RS6000Architecture.RS6000Instruction] ~ { rs6000Instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[instruction]; IF rs6000Instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rs6000Instruction]; }; TargetInstructionFromRS6000Instruction: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction] RETURNS [TargetArchitecture.Instruction] ~ { targetInstruction: TargetArchitecture.Instruction ~ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [targetInstruction]; }; RS6000RegisterClassFromTargetRegisterClass: PUBLIC PROCEDURE [ registerClass: TargetArchitecture.RegisterClass] RETURNS [RS6000Architecture.RegisterClass] ~ { rs6000RegisterClass: RS6000Architecture.RegisterClass ~ LOOPHOLE[registerClass]; SELECT rs6000RegisterClass FROM none, globals, globalsAndIns, globalsInsAndFloats, globalsInsFloatsOutsAndLocals, all => { NULL; }; ENDCASE => { ERROR RuntimeError.BoundsFault; }; RETURN [rs6000RegisterClass]; }; TargetRegisterClassFromRS6000RegisterClass: PUBLIC PROCEDURE [ registerClass: RS6000Architecture.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]; }; CantRelocate: PUBLIC ERROR ~ CODE; CantReach: PUBLIC ERROR ~ CODE; NullRS6000Address: PUBLIC ERROR ~ CODE; NullRS6000Instruction: PUBLIC ERROR ~ CODE; }. k RS6000ArchitectureImpl.mesa Copyright Ó 1991, 1992, 1993 by Xerox Corporation. All rights reserved. Peter B. Kessler, April 9, 1990 3:31:21 pm PDT Operations the debugger performs on the RS6000. Udagawa, September 18, 1991 7:10 pm PDT Katsuyuki Komatsu March 5, 1992 1:16 pm PST Laurie Horton, February 24, 1993 8:30 pm PST Code Assembly. or instruction with rc bit off doesn't affect condition register. So, it can be used for nop with the same source and destination registers. Relocates an instruction from the given address to another address. Relocates an instruction from the given address to another address. Relocates an instruction from the given address to another address. Relocates an instruction from the given address to another address. Relocate: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { Relocates an instruction from the given address to another address. relocated: RS6000Architecture.RS6000Instruction _ instruction; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF from.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF to.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => { SELECT instruction.GetOp2[] FROM RS6000Architecture.Op2.bicc, RS6000Architecture.Op2.fbfcc, RS6000Architecture.Op2.cbccc => { RelocateFormat2: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; instructionDisp22: RS6000Architecture.Disp22 ~ instruction.GetDisp22[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp22 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses [here: to, there: targetAddress]; relocationDisp22: RS6000Architecture.Disp22 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp22 NOT IN [RS6000Architecture.firstDisp22..RS6000Architecture.lastDisp22] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated _ instruction.SetDisp22[disp22: relocationDisp22]; RETURN [relocated]; }; relocated _ RelocateFormat2[instruction: instruction, from: from, to: to]; }; ENDCASE => { NULL; }; }; RS6000Architecture.Op.call => { RelocateFormat1: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; instructionDisp30: RS6000Architecture.Disp30 ~ instruction.GetDisp30[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp30 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses [here: to, there: targetAddress]; relocationDisp30: RS6000Architecture.Disp30 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp30 NOT IN [RS6000Architecture.firstDisp30..RS6000Architecture.lastDisp30] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated _ instruction.SetDisp30[disp30: relocationDisp30]; RETURN [relocated]; }; relocated _ RelocateFormat1[instruction: instruction, from: from, to: to]; }; RS6000Architecture.Op.other2 => { NULL; }; RS6000Architecture.Op.other3 => { NULL; }; ENDCASE => ERROR; RETURN [relocated]; }; Instruction Classification. A sample noop instruction. Checks whether the instruction at the given pc is a noop. NeedsRelocation: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { Checks whether the instruction at the given pc has pc-relative operands. needsRelocation: BOOLEAN _ FALSE; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => { SELECT instruction.GetOp2[] FROM RS6000Architecture.Op2.bicc, RS6000Architecture.Op2.fbfcc, RS6000Architecture.Op2.cbccc => { needsRelocation _ TRUE; }; ENDCASE => { needsRelocation _ FALSE; }; }; RS6000Architecture.Op.call => { needsRelocation _ TRUE; }; RS6000Architecture.Op.other2 => { needsRelocation _ FALSE; }; RS6000Architecture.Op.other3 => { needsRelocation _ FALSE; }; ENDCASE => ERROR; RETURN [needsRelocation]; }; IsCallInstruction: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { Checks whether the instruction is a call instruction. isCallInstruction: BOOLEAN _ FALSE; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => { isCallInstruction _ FALSE; }; RS6000Architecture.Op.call => { isCallInstruction _ TRUE; }; RS6000Architecture.Op.other2 => { isCallInstruction _ FALSE; }; RS6000Architecture.Op.other3 => { isCallInstruction _ FALSE; }; ENDCASE => ERROR; RETURN [isCallInstruction]; }; Field accessors for instructions. GetFormat: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Format] ~ { format: RS6000Architecture.Format ~ SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => RS6000Architecture.Format.format2, RS6000Architecture.Op.call => RS6000Architecture.Format.format1, RS6000Architecture.Op.other2 => RS6000Architecture.Format.format2, RS6000Architecture.Op.other3 => RS6000Architecture.Format.format3, ENDCASE => ERROR; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [format]; }; GetDisp30: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp30] ~ { format1: RS6000Architecture.Format1 ~ LOOPHOLE[instruction]; disp30: RS6000Architecture.Disp30 ~ RS6000Architecture.Disp30FromUnbiased30[ unbiased30MS: format1.disp30MS, unbiased30LS: format1.disp30LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp30]; }; GetRd: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Register] ~ { format2Imm22: RS6000Architecture.Format2Imm22 ~ LOOPHOLE[instruction]; rd: RS6000Architecture.Register ~ format2Imm22.rd; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rd]; }; GetOp2: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Op2] ~ { format2Imm22: RS6000Architecture.Format2Imm22 ~ LOOPHOLE[instruction]; op2: RS6000Architecture.Op2 ~ format2Imm22.op2; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [op2]; }; GetImm22: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Imm22] ~ { format2Imm22: RS6000Architecture.Format2Imm22 ~ LOOPHOLE[instruction]; imm22: RS6000Architecture.Imm22 ~ RS6000Architecture.Imm22FromImm22ML[ imm22MS: format2Imm22.imm22MS, imm22LS: format2Imm22.imm22LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [imm22]; }; GetAnnul: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Annul] ~ { format2Disp22: RS6000Architecture.Format2Disp22 ~ LOOPHOLE[instruction]; annul: RS6000Architecture.Annul ~ format2Disp22.a; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [annul]; }; GetCond: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Cond] ~ { format2Disp22: RS6000Architecture.Format2Disp22 ~ LOOPHOLE[instruction]; cond: RS6000Architecture.Cond ~ format2Disp22.cond; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [cond]; }; GetDisp22: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp22] ~ { format2Disp22: RS6000Architecture.Format2Disp22 ~ LOOPHOLE[instruction]; disp22: RS6000Architecture.Disp22 ~ RS6000Architecture.Disp22FromUnbiased22[ unbiased22MS: format2Disp22.disp22MS, unbiased22LS: format2Disp22.disp22LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp22]; }; GetRs1: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Register] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; rs1: RS6000Architecture.Register ~ RS6000Architecture.RegisterFromRegisterML[registerMS: format3asi.rs1MS, registerLS: format3asi.rs1LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rs1]; }; RegisterFromRegisterML: PUBLIC PROCEDURE [ registerMS: RS6000Architecture.RegisterMS, registerLS: RS6000Architecture.RegisterLS] RETURNS [RS6000Architecture.Register] ~ { register: RS6000Architecture.Register ~ VAL[ (registerMS * (LAST[RS6000Architecture.RegisterLS] + 1)) + registerLS ]; RETURN [register]; }; GetI: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.I] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; i: RS6000Architecture.I ~ format3asi.i; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [i]; }; GetASI: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.ASI] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; asi: RS6000Architecture.ASI ~ format3asi.asi; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [asi]; }; GetRs2: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Register] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; rs2: RS6000Architecture.Register ~ format3asi.rs2; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rs2]; }; GetSimm13: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Simm13] ~ { format3Simm13: RS6000Architecture.Format3Simm13 ~ LOOPHOLE[instruction]; simm13: RS6000Architecture.Simm13 ~ RS6000Architecture.Simm13FromUnbiased13[unbiased13: format3Simm13.simm13]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [simm13]; }; GetOpF: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.OpF] ~ { format3OpF: RS6000Architecture.Format3OpF ~ LOOPHOLE[instruction]; opf: RS6000Architecture.OpF ~ format3OpF.opf; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [opf]; }; GetOp3: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Op3] ~ { format3TiccRs2: RS6000Architecture.Format3TiccRs2 ~ LOOPHOLE[instruction]; op3: RS6000Architecture.Op3 ~ format3TiccRs2.op3; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [op3]; }; Op10Op3FromOp3: PUBLIC PROCEDURE [op3: RS6000Architecture.Op3] RETURNS [RS6000Architecture.Op10Op3] ~ { op10Op3: RS6000Architecture.Op10Op3 ~ VAL[ORD[op3]]; RETURN [op10Op3]; }; Op11Op3FromOp3: PUBLIC PROCEDURE [op3: RS6000Architecture.Op3] RETURNS [RS6000Architecture.Op11Op3] ~ { op11Op3: RS6000Architecture.Op11Op3 ~ VAL[ORD[op3]]; RETURN [op11Op3]; }; Disp30FromUnbiased30: PUBLIC PROCEDURE [ unbiased30MS: RS6000Architecture.Unbiased30MS, unbiased30LS: RS6000Architecture.Unbiased30LS] RETURNS [RS6000Architecture.Disp30] ~ { unbiased30: RS6000Architecture.Unbiased30 ~ (unbiased30MS * (CARD32[LAST[RS6000Architecture.Unbiased30LS]] + 1)) + unbiased30LS; disp30: RS6000Architecture.Disp30 ~ IF unbiased30 <= RS6000Architecture.Unbiased30[RS6000Architecture.lastDisp30] THEN unbiased30 ELSE -(RS6000Architecture.lastUnbiased30 + 1 - unbiased30); Since RS6000Architecture.Disp30 isn't a biased subrange any more, this can just sign-extend the unbiased the representation. IF unbiased30 NOT IN [RS6000Architecture.firstUnbiased30 .. RS6000Architecture.lastUnbiased30] THEN { ERROR RuntimeError.BoundsFault }; RETURN [disp30]; }; Disp22FromUnbiased22: PUBLIC PROCEDURE [ unbiased22MS: RS6000Architecture.Unbiased22MS, unbiased22LS: RS6000Architecture.Unbiased22LS] RETURNS [RS6000Architecture.Disp22] ~ { unbiased22: RS6000Architecture.Unbiased22 ~ (unbiased22MS * (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1)) + unbiased22LS; disp22: RS6000Architecture.Disp22 ~ IF unbiased22 <= RS6000Architecture.Unbiased22[RS6000Architecture.lastDisp22] THEN unbiased22 ELSE -(RS6000Architecture.lastUnbiased22 + 1 - unbiased22); Since RS6000Architecture.Disp22 isn't a biased subrange any more, this can just sign-extend the unbiased the representation. IF unbiased22 NOT IN [RS6000Architecture.firstUnbiased22 .. RS6000Architecture.lastUnbiased22] THEN { ERROR RuntimeError.BoundsFault }; RETURN [disp22]; }; Imm22FromImm22ML: PUBLIC PROCEDURE [ imm22MS: RS6000Architecture.Imm22MS, imm22LS: RS6000Architecture.Imm22LS] RETURNS [RS6000Architecture.Imm22] ~ { imm22: RS6000Architecture.Imm22 ~ (imm22MS * (CARD32[LAST[RS6000Architecture.Imm22LS]] + 1)) + imm22LS; IF NOT imm22 IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [imm22]; }; Imm22MSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Imm22MS] ~ { imm22MS: RS6000Architecture.Imm22MS ~ imm22 / (CARD32[LAST[RS6000Architecture.Imm22LS]] + 1); IF NOT imm22 IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [imm22MS]; }; Imm22LSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Imm22LS] ~ { imm22LS: RS6000Architecture.Imm22LS ~ imm22 MOD (CARD32[LAST[RS6000Architecture.Imm22LS]] + 1); IF NOT imm22 IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [imm22LS]; }; Simm13FromUnbiased13: PUBLIC PROCEDURE [unbiased13: RS6000Architecture.Unbiased13] RETURNS [RS6000Architecture.Simm13] ~ { biased: INT32 ~ IF unbiased13 <= RS6000Architecture.lastSimm13 THEN unbiased13 ELSE -(RS6000Architecture.lastUnbiased13 + 1 - unbiased13); simm13: RS6000Architecture.Simm13 ~ biased; RETURN [simm13]; }; HiLo: PUBLIC PROCEDURE[hi: RS6000Architecture.Imm22, lo: RS6000Architecture.Imm10] RETURNS [CARD32] ~ { hiLo: CARD32 ~ (hi * (CARD32[RS6000Architecture.lastImm10] + 1)) + lo; IF hi NOT IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; IF lo NOT IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [hiLo]; }; Field assigners for instructions. SetDisp30: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format1: RS6000Architecture.Format1 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp30 NOT IN [RS6000Architecture.firstDisp30 ..RS6000Architecture.lastDisp30] THEN { ERROR RuntimeError.BoundsFault; }; format1.disp30MS _ RS6000Architecture.Unbiased30MSFromDisp30[disp30: disp30]; format1.disp30LS _ RS6000Architecture.Unbiased30LSFromDisp30[disp30: disp30]; RETURN [LOOPHOLE[format1]]; }; SetRd: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, rd: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Imm22: RS6000Architecture.Format2Imm22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Imm22.rd _ rd; RETURN [LOOPHOLE[format2Imm22]]; }; SetOp2: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, op2: RS6000Architecture.Op2] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Imm22: RS6000Architecture.Format2Imm22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Imm22.op2 _ op2; RETURN [LOOPHOLE[format2Imm22]]; }; SetImm22: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Imm22: RS6000Architecture.Format2Imm22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF imm22 NOT IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; format2Imm22.imm22MS _ RS6000Architecture.Unbiased22MSFromImm22[imm22: imm22]; format2Imm22.imm22LS _ RS6000Architecture.Unbiased22LSFromImm22[imm22: imm22]; RETURN [LOOPHOLE[format2Imm22]]; }; SetAnnul: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, annul: RS6000Architecture.Annul] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Disp22: RS6000Architecture.Format2Disp22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Disp22.a _ annul; RETURN [LOOPHOLE[format2Disp22]]; }; SetCond: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, cond: RS6000Architecture.Cond] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Disp22: RS6000Architecture.Format2Disp22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Disp22.cond _ cond; RETURN [LOOPHOLE[format2Disp22]]; }; SetDisp22: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Disp22: RS6000Architecture.Format2Disp22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp22 NOT IN [RS6000Architecture.firstDisp22 .. RS6000Architecture.lastDisp22] THEN { ERROR RuntimeError.BoundsFault; }; format2Disp22.disp22MS _ RS6000Architecture.Unbiased22MSFromDisp22[disp22: disp22]; format2Disp22.disp22LS _ RS6000Architecture.Unbiased22LSFromDisp22[disp22: disp22]; RETURN [LOOPHOLE[format2Disp22]]; }; SetRs1: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, rs1: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.rs1MS _ RS6000Architecture.RegisterMSFromRegister[register: rs1]; format3asi.rs1LS _ RS6000Architecture.RegisterLSFromRegister[register: rs1]; RETURN [LOOPHOLE[format3asi]]; }; RegisterMSFromRegister: PUBLIC PROCEDURE [register: RS6000Architecture.Register] RETURNS [RS6000Architecture.RegisterMS] ~ { registerMS: RS6000Architecture.RegisterMS ~ ORD[register] / (LAST[RS6000Architecture.RegisterLS] + 1); RETURN [registerMS]; }; RegisterLSFromRegister: PUBLIC PROCEDURE [register: RS6000Architecture.Register] RETURNS [RS6000Architecture.RegisterLS]~ { registerLS: RS6000Architecture.RegisterLS ~ ORD[register] MOD (LAST[RS6000Architecture.RegisterLS] + 1); RETURN [registerLS]; }; SetI: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, i: RS6000Architecture.I] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.i _ i; RETURN [LOOPHOLE[format3asi]]; }; SetASI: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, asi: RS6000Architecture.ASI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.asi _ asi; RETURN [LOOPHOLE[format3asi]]; }; SetRs2: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, rs2: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.rs2 _ rs2; RETURN [LOOPHOLE[format3asi]]; }; SetSimm13: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, simm13: RS6000Architecture.Simm13] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3Simm13: RS6000Architecture.Format3Simm13 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3Simm13.simm13 _ RS6000Architecture.Unbiased13FromSimm13[simm13: simm13]; RETURN [LOOPHOLE[format3Simm13]]; }; SetOpF: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, opf: RS6000Architecture.OpF] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3OpF: RS6000Architecture.Format3OpF _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3OpF.opf _ opf; RETURN [LOOPHOLE[format3OpF]]; }; SetOp3: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, op3: RS6000Architecture.Op3] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3TiccRs2: RS6000Architecture.Format3TiccRs2 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3TiccRs2.op3 _ op3; RETURN [LOOPHOLE[format3TiccRs2]]; }; Op3FromOp10Op3: PUBLIC PROCEDURE [op10Op3: RS6000Architecture.Op10Op3] RETURNS [RS6000Architecture.Op3] ~ { op3: RS6000Architecture.Op3 ~ VAL[ORD[op10Op3]]; RETURN [op3]; }; Op3FromOp11Op3: PUBLIC PROCEDURE [op11Op3: RS6000Architecture.Op11Op3] RETURNS [RS6000Architecture.Op3] ~ { op3: RS6000Architecture.Op3 ~ VAL[ORD[op11Op3]]; RETURN [op3]; }; Unbiased30FromDisp30: PUBLIC PROCEDURE [disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.Unbiased30] ~ { Since RS6000Architecture.Disp30 isn't a biased subrange any more, all I have to do is pick off the right bits. unbiased: CARD32 ~ LOOPHOLE[disp30]; unbiased30: RS6000Architecture.Unbiased30 ~ unbiased MOD (RS6000Architecture.lastUnbiased30 + 1); IF disp30 NOT IN [RS6000Architecture.firstDisp30 .. RS6000Architecture.lastDisp30] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [unbiased30]; }; Unbiased30MSFromDisp30: PUBLIC PROCEDURE [disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.Unbiased30MS] ~ { unbiased30: RS6000Architecture.Unbiased30 ~ RS6000Architecture.Unbiased30FromDisp30[disp30: disp30]; unbiased30MS: RS6000Architecture.Unbiased30MS ~ unbiased30 / (CARD32[LAST[RS6000Architecture.Unbiased30LS]] + 1); IF disp30 NOT IN [RS6000Architecture.firstDisp30 .. RS6000Architecture.lastDisp30] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [unbiased30MS]; }; Unbiased30LSFromDisp30: PUBLIC PROCEDURE [disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.Unbiased30LS] ~ { unbiased30: RS6000Architecture.Unbiased30 ~ RS6000Architecture.Unbiased30FromDisp30[disp30: disp30]; unbiased30LS: RS6000Architecture.Unbiased30LS ~ unbiased30 MOD (CARD32[LAST[RS6000Architecture.Unbiased30LS]] + 1); RETURN [unbiased30LS]; }; Unbiased22FromDisp22: PUBLIC PROCEDURE [disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.Unbiased22] ~ { Since RS6000Architecture.Disp22 isn't a biased subrange any more, all I have to do is pick off the right bits. unbiased: CARD32 ~ LOOPHOLE[disp22]; unbiased22: RS6000Architecture.Unbiased22 ~ unbiased MOD (RS6000Architecture.lastUnbiased22 + 1); IF disp22 NOT IN [RS6000Architecture.firstDisp22 .. RS6000Architecture.lastDisp22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [unbiased22]; }; Unbiased22MSFromDisp22: PUBLIC PROCEDURE [disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.Unbiased22MS] ~ { unbiased22: RS6000Architecture.Unbiased22 ~ RS6000Architecture.Unbiased22FromDisp22[disp22: disp22]; unbiased22MS: RS6000Architecture.Unbiased22MS ~ unbiased22 / (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22MS]; }; Unbiased22LSFromDisp22: PUBLIC PROCEDURE [disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.Unbiased22LS] ~ { unbiased22: RS6000Architecture.Unbiased22 ~ RS6000Architecture.Unbiased22FromDisp22[disp22: disp22]; unbiased22LS: RS6000Architecture.Unbiased22LS ~ unbiased22 MOD (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22LS]; }; Unbiased22MSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Unbiased22MS] ~ { unbiased22MS: RS6000Architecture.Unbiased22MS ~ imm22 / (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22MS]; }; Unbiased22LSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Unbiased22LS] ~ { unbiased22LS: RS6000Architecture.Unbiased22LS ~ imm22 MOD (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22LS]; }; Unbiased13FromSimm13: PUBLIC PROCEDURE [simm13: RS6000Architecture.Simm13] RETURNS [RS6000Architecture.Unbiased13] ~ { biased: INT32 ~ simm13; unbiased13: RS6000Architecture.Unbiased13 ~ IF biased >= 0 THEN biased ELSE RS6000Architecture.lastUnbiased13 + 1 + biased; RETURN [unbiased13]; }; Miscellaneous. Tests if its argument is the null RS6000Address. Tests if its argument is the null RS6000Instruction. Returns the instruction address after the given one. Returns a pointer to the previous instruction. Yeah for being able to back up in instruction streams, boo for needing to. Errors. Given for attempts to relocate an instruction too far, etc. Given for attempts to generate pc-relative instructions that don't reach. Given during code generation when null addresses are supplied. Given when supplied instruction is the null instruction. �Ê2£•NewlineDelimiter – "cedar" style™code™K™HKšœ.™.K™—šœ(Ïkœ™/K™'K™+K™,—™š� ˜ K˜K˜K˜ K˜——unitšÐlnœ�œ�œ˜&Kš�œ5˜˜>K˜š�œ'�œ˜/Kš�œ*˜/K˜—š�œ�œ˜$Kš�œ&˜+K˜—š�œ�œ˜"Kš�œ&˜+K˜—š�œ�˜KšœE˜EKšœF˜FKšœE˜EKšœC˜CKšœF˜FKšœD˜DKšœD˜DKšœ\˜\Kšœ[˜[KšœW˜WKšœF˜FKšœF˜FKšœE˜EKšœE˜EKšœE˜EKšœE˜EKšœF˜FKšœF˜FKšœF˜FKšœF˜FKšœW˜WKšœB˜BKšœC˜CKšœD˜DKšœE˜EKšœC˜CKšœD˜DKšœD˜DKšœD˜DKšœE˜EKšœD˜DKšœE˜EKšœD˜DKšœC˜CKšœD˜DKšœD˜DKšœE˜EKšœD˜DKšœE˜EKšœE˜EKšœF˜FKšœE˜EKšœF˜FKšœW˜WKš�œ�œ˜—Kš�œ ˜K˜—K˜šŸœ� œ‡�œ+˜ÓK™CK™Kšœ>˜>š�œ�˜$KšœM˜MKšœL˜LKšœN˜NKšœO˜OKšœN˜NKšœO˜OKšœN˜NKšœN˜NKšœN˜NKšœM˜MKšœL˜LKš�œ�œ˜K˜—Kš�œ ˜K˜—K˜šŸœ� œ‡�œ+˜ÓK™CK™Kšœ>˜>š�œ#�˜-KšœU˜UKšœS˜SKšœV˜VKšœT˜TKšœT˜TKšœW˜WKšœU˜UKšœW˜WKšœV˜VKšœU˜UKšœV˜VKšœW˜WKšœV˜VKšœW˜WKšœU˜UKšœW˜WKšœU˜UKšœU˜UKšœU˜UKšœV˜VKšœV˜VKšœV˜VKšœV˜VKšœV˜VKšœW˜WKšœW˜WKšœW˜WKšœV˜VKšœW˜WKšœU˜UKšœW˜WKšœV˜VKšœW˜WKšœV˜VKšœU˜UKšœW˜WKšœT˜TKšœW˜WKšœV˜VKšœW˜WKšœU˜UKšœV˜VKšœV˜VKšœT˜TKšœV˜VKšœX˜XKšœW˜WKšœU˜UKšœV˜VKšœW˜WKšœV˜VKšœW˜WKšœW˜WKšœU˜UKšœU˜UKšœX˜XKšœV˜VKšœW˜WKšœV˜VKšœV˜VKšœX˜XKšœW˜WKšœW˜WKšœU˜UKšœV˜VKšœX˜XKšœV˜VKšœV˜VKšœW˜WK˜—š�œ˜ š�œ �˜*KšœQ˜QKšœP˜PKšœR˜RKšœR˜RKšœQ˜QKšœS˜SKšœR˜RKšœS˜SKšœQ˜QKšœS˜SKšœR˜RKšœR˜RKšœR˜RKšœS˜SKšœR˜RKšœS˜SKšœS˜SK˜—Kš�œ�œ˜Kšœ˜K˜—Kš�œ ˜K˜—K˜šŸœ� œ‡�œ+˜ÓK™CK™Kšœ>˜>š�œ�˜&KšœK˜KKšœK˜KKšœK˜KKšœK˜KKšœL˜LKšœL˜LKšœM˜MKšœM˜MK˜—š�œ˜ š�œ�˜&KšœN˜NKšœM˜MKšœN˜NKšœO˜OKšœM˜MKšœN˜NKšœO˜OKšœL˜LKšœO˜OKšœN˜NKšœM˜MKšœM˜MKšœN˜NK˜—Kš�œ�œ˜K˜—Kš�œ ˜K˜K˜—šŸ œ� œ5�œ+˜|K˜Kš�œ˜K˜—K˜šŸœ� œ†�œ+˜ÜK˜Kšœ>˜>KšœG˜Gšœ4˜4Kšœ�œ'˜@—šœ2˜2šœ1˜1Kšœ/˜/——šœ:˜:KšœS˜S—šœ.˜.Kšœ�œ'˜EK˜—š�œ�œ�œA�œ˜aKš�œ!˜&K˜—š�œ�œ�œ+�œ˜TKš�œ!˜&K˜—Kšœ<˜˜>KšœG˜Gšœ4˜4Kšœ�œ'˜@—šœ2˜2šœ1˜1Kšœ/˜/——šœ:˜:KšœS˜S—šœ.˜.Kšœ�œ'˜EK˜—š�œ�œ�œA�œ˜aKš�œ!˜&K˜—š�œ�œ�œ+�œ˜TKš�œ!˜&K˜—Kšœ<˜™>K™š�œ'�œ™/Kš�œ*™/K™—š�œ�œ™$Kš�œ&™+K™—š�œ�œ™"Kš�œ&™+K™—š�œ�™šœ!™!š�œ�™ Kšœ™Kšœ™šœ!™!šŸœ� œ‡�œ+™ÓKšœ>™>KšœG™Gšœ4™4Kšœ�œ'™@—šœ2™2šœ1™1Kšœ/™/——šœ:™:šœ2™2Kšœ!™!——šœ.™.Kšœ�œ'™E—K™š�œ�œ�œ@�œ™aKš�œ!™&K™—š�œ�œ�œ+�œ™TKš�œ!™&K™—Kšœ<™™>KšœG™Gšœ4™4Kšœ�œ'™@—šœ2™2šœ1™1Kšœ/™/——šœ:™:šœ2™2Kšœ!™!——šœ.™.Kšœ�œ'™E—K™š�œ�œ�œ@�œ™aKš�œ!™&K™—š�œ�œ�œ+�œ™TKš�œ!™&K™—Kšœ<™™>—K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ6�œ™vKšœ2�œ™HKšœ2™2K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ6�œ™tKšœ2�œ™HKšœ3™3K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™Kšœ™K™—šŸ œ�œ� œ6�œ ™xKšœ2�œ™Hšœ$™$šœ(™(KšœL™L——K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ6�œ"™wKšœ,�œ™BKšœ‰™‰K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™ Kšœ™K™šŸœ�œ� œZ�œ"™«šœ(�œ™,Kšœ�œ2™EKšœ™K™—Kš�œ ™Kšœ™—K™—šŸœ�œ� œ6�œ™nKšœ,�œ™BKšœ'™'K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™ Kšœ™K™—š Ÿœ�œ� œ6�œ�œ™rKšœ,�œ™BKšœ�œ™-K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™ Kšœ™K™—šŸœ�œ� œ6�œ"™wKšœ,�œ™BKšœ2™2K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™ Kšœ™K™—šŸ œ�œ� œ6�œ ™xKšœ2�œ™Hšœ$™$KšœJ™J—K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ6�œ™rKšœ,�œ™BKšœ-™-K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™ Kšœ™K™—šŸœ�œ� œ6�œ™rKšœ4�œ™JKšœ1™1K™š�œ'�œ™/Kš�œ*™/K™—Kš�œ™ Kšœ™K™šŸœ�œ� œ �œ!™hKšœ&�œ�œ™4Kš�œ ™K™—šŸœ�œ� œ �œ!™hKšœ&�œ�œ™4Kš�œ ™K™—K™—šŸœ�œ� œc�œ ™°šœ,™,Kšœ�œ�œ)™EKšœ™—šœ$™$š�œK™MKš�œ ™Kš�œ7™;Kšœ|™|——K™š�œ �œ�œL�œ™fKš�œ™Kšœ™—Kš�œ ™Kšœ™K™—šŸœ�œ� œb�œ ™¯šœ,™,Kšœ�œ�œ)™EKšœ™—šœ$™$š�œK™MKš�œ ™Kš�œ7™;Kšœ|™|——K™š�œ �œ�œL�œ™fKš�œ™Kšœ™—Kš�œ ™Kšœ™K™—šŸœ�œ� œO�œ™—šœ"™"Kšœ �œ�œ.™E—K™š�œ�œ�œA�œ™VKš�œ™K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ$�œ!™nšœ&™&Kšœ �œ�œ#™7—K™š�œ�œ�œA�œ™VKš�œ™K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ$�œ!™nšœ&™&Kšœ�œ�œ�œ#™9—K™š�œ�œ�œA�œ™VKš�œ™K™—Kš�œ ™Kšœ™K™—šŸœ�œ� œ.�œ ™{šœ�œ�œ,™>Kš�œ ™Kš�œ7™;—Kšœ+™+K™Kš�œ ™Kšœ™K™—š Ÿœ�œ� œ �œ�œ�œ˜JKšœ�œ  œ œ˜7K˜Kš�œ˜ Kšœ˜K˜—š Ÿœ�œ� œ �œ�œ�œ˜IKš œ�œÏsœ œ œ œ˜9K˜Kš�œ˜ Kšœ˜K™—š Ÿœ�œ� œ>�œ�œ™hKšœ�œ �œ*™FK™š�œ�œ�œA�œ™SKš�œ™K™—š�œ�œ�œA�œ™SKš�œ™K™—Kš�œ™K™K˜——™!šŸœ�œ� œR�œ+˜›Kšœ2�œ˜HK˜š�œ'�œ˜/Kš�œ*˜/K˜—Kšœ˜Kš�œ�œ˜!Kšœ˜K˜—šŸ œ�œ� œZ�œ+˜§Kšœ2�œ˜HK˜š�œ'�œ˜/Kš�œ*˜/K˜—š�œ�œ�œB�œ˜XKš�œ˜Kšœ˜—Kšœ œ%˜DKšœ�œ�œ)�œ˜cKš�œ�œ˜!Kšœ˜K˜—K˜—šŸ œ�œ� œZ�œ+˜§Kšœ0�œ˜FK˜š�œ'�œ˜/Kš�œ*˜/K˜—š�œ�œ�œB�œ˜XKš�œ˜Kšœ˜—Kšœ Ðlsœ¢œ˜CKšœ�œ�œ)�œ˜aKš�œ�œ˜ Kšœ˜K˜šŸ œ�œ� œZ�œ+™§Kšœ&�œ™—K™Kš�œ™Kšœ™—K™—šŸœ�œ� œ&�œ$™wKšœ�œ ™šœ,™,š�œ ™Kš�œ™ Kš�œ0™4——K™Kš�œ™K™K˜——™š Ÿœ�œ� œ.�œ�œ˜hK™0Kšœ�œ2˜NK˜Kš�œ˜Kšœ˜K™—šŸœ�œ� œ^�œ'˜»šœ,˜,KšœJ˜J—šœ(˜(šœ+˜+Kšœ4˜4——Kšœz˜zJ˜š�œ�œ˜'Kš�œ&˜+K˜—Jš�œ˜Kšœ˜K˜—šŸœ�œ� œT�œ&˜²šœ)˜)KšœG˜G—šœ*˜*KšœH˜H—šœ0˜0šœ-˜-Kšœ&˜&——K˜š�œ�œ˜$Kš�œ&˜+K˜—š�œ�œ˜%Kš�œ&˜+K˜—Kš�œ˜Kšœ˜K˜—š Ÿœ�œ� œ7�œ�œ˜uK™4šœ�œ˜#Kšœ7˜7—K˜Kš�œ˜!Kšœ˜K™—š Ÿœ�œ� œ)�œ&�œ˜†K™4šœ'˜'KšœE˜E—šœ.˜.Kšœ1˜1—šœ:˜:KšœL˜L—K˜š�œ�œ˜"Kš�œ&˜+K˜—Kš�œ˜Kšœ˜K˜—šŸœ�œ� œ)�œ'˜~™.K™J—šœ'˜'KšœE˜E—šœ.˜.Kšœ1˜1—šœ:˜:KšœL˜L—K˜š�œ�œ˜"Kš�œ&˜+K˜—Kš�œ˜K˜K˜—šŸœ�œ� œ)�œ'˜‡Kšœ2�œ ˜DK˜š�œ%�œ˜-Kš�œ&˜+K˜—Kš�œ˜K˜K˜—šŸœ�œ� œ5�œ!˜�Kšœ&�œ˜>K˜š�œ%�œ˜-Kš�œ&˜+K˜—Kš�œ ˜K˜K˜—šŸ œ�œ� œ*�œ(˜‹Kšœ4�œ ˜GK˜Kš�œ˜Kšœ˜K˜—šŸ œ�œ� œ0�œ"˜‹Kšœ.�œ ˜AK˜Kš�œ˜Kšœ˜K˜—šŸ&œ�œ� œ0�œ+˜šKšœ:�œ˜PK˜š�œ-�œ˜5Kš�œ*˜/K˜—Kš�œ˜Kšœ˜K˜—šŸ&œ�œ� œ6�œ%˜šKšœ4�œ˜JK˜š�œ'�œ˜/Kš�œ*˜/K˜—Kš�œ˜Kšœ˜K˜—šŸ*œ�œ� œ4�œ'˜žKšœ8�œ˜PK˜š�œ�˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜šœ˜Kš�œ˜Kšœ˜—š�œ˜ Kš�œ˜Kšœ˜——Kš�œ˜Kšœ˜K˜—šŸ*œ�œ� œ4�œ'˜žKšœ8�œ˜PK˜š�œ�˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜šœ˜Kš�œ˜Kšœ˜—š�œ˜ Kš�œ˜Kšœ˜——Kš�œ˜Kšœ˜K˜——™šŸ œ�œ�œ�œ˜"K™;K™—šŸ œ�œ�œ�œ˜K™IK™—šŸœ�œ�œ�œ˜'K™>K™—šŸœ�œ�œ�œ˜+K™8K™——L˜K™——…—”R2