@Override public InstructionsAndTiming<ArmInstruction> generate( final ArrayAccessExprSymbol arrayAccess, final Platform<ArmInstruction, Size> platform) { final InstructionsAndTiming<ArmInstruction> instructions = new InstructionsAndTiming<ArmInstruction>(); final SizeHelper<ArmInstruction, Size> sizeHelper = platform.getSizeHelper(); final ObjectLayout<ArmInstruction, Size> objectLayout = platform.getObjectLayout(); final IRuntime<ArmInstruction> runtime = platform.getRunime(); instructions.add(new Comment("Accessing array")); instructions.addAll(platform.getBest(arrayAccess.children.get(0))); platform.getTileHelper().setupJmpNull(IRuntime.EXCEPTION_LBL, sizeHelper, instructions); instructions.add(new Push(Register.R8)); instructions.add(new Mov(Register.R8, Register.R0, sizeHelper)); instructions.addAll(platform.getBest(arrayAccess.children.get(1))); instructions.add(new Comment("Checking element >= 0")); final long myVal = CodeGenVisitor.getNewLblNum(); String ok = "arrayAccessP1Ok" + myVal; instructions.add(new Eor(Register.R1, Register.R1, Register.R1, sizeHelper)); instructions.add(new Cmp(Register.R0, Register.R1, sizeHelper)); instructions.add(new B(Condition.GE, ok)); runtime.throwException(instructions, "Invalid array access"); instructions.add(new Label(ok)); ok = "arrayAccessOk" + myVal; instructions.add( new Ldr( Register.R3, Register.R8, new Immediate12((short) platform.getObjectLayout().objSize()), sizeHelper)); instructions.add(new Cmp(Register.R3, Register.R0, sizeHelper)); instructions.add(new B(Condition.GT, ok)); runtime.throwException(instructions, "Invalid array access"); instructions.add(new Label(ok)); final Size elementSize = sizeHelper.getPushSize(sizeHelper.getSizeOfType(arrayAccess.getType().value)); if (elementSize != Size.B && elementSize != Size.SB) { instructions.add( new Mov( Register.R0, new ConstantShift(Register.R0, ArmSizeHelper.getPowerSizeImd(elementSize), Shift.LSL), sizeHelper)); } final Immediate8 offset = new Immediate8((char) (objectLayout.objSize() + sizeHelper.getDefaultStackSize())); instructions.add(new Add(Register.R0, Register.R0, offset, sizeHelper)); return instructions; }
@Override public final String generate() { return what + " " + dst.getValue(sizeHelper.getDefaultSize(), sizeHelper) + ", " + Size.getSizeStr(size) + " " + src.getValue(size, sizeHelper); }
public IMul( final Register arg1, final InstructionArg<X86Instruction, Size> arg2, final SizeHelper<X86Instruction, Size> sizeHelper) { this(arg1, arg2, sizeHelper.getDefaultSize(), sizeHelper); }