// Ranjay public static ExpressionInstruction generateTile(MemIR mem, TempTable tTable) { ExpressionInstruction inst = new ExpressionInstruction(); SyntaxIR address = (SyntaxIR) mem.getChildren().get(0); Instruction childInst = generateTile(address, tTable); inst.addAll(childInst.getTiles()); AddressingMode addr = ((ExpressionInstruction) childInst).getAddr(); if (addr.getMemAccess()) { inst.add(new Tile(1, "movq", addr, new AddressingMode("r12"))); inst.setAddr(new AddressingMode(true, "r12")); } else { inst.setAddr(new AddressingMode(true, addr.getBaseReg())); } return inst; }
// Ranjay public static Instruction generateTile(MoveIR move, TempTable tTable) { Instruction inst = new Instruction(); Instruction childDest = generateTile((SyntaxIR) move.getChildren().get(0), tTable); Instruction childSrc = generateTile((SyntaxIR) move.getChildren().get(1), tTable); inst.addAll(childSrc.getTiles()); inst.addAll(childDest.getTiles()); AddressingMode addr1 = ((ExpressionInstruction) childSrc).getAddr(); AddressingMode addr2 = ((ExpressionInstruction) childDest).getAddr(); if (addr1.getMemAccess() && addr2.getMemAccess()) { inst.add(new Tile(1, "movq", addr1, new AddressingMode("r12"))); inst.add(new Tile(1, "movq", new AddressingMode("r12"), addr2)); return inst; } else if (addr2.getMemAccess()) { Instruction iii = new Instruction(); iii.addAll(childSrc.getTiles()); iii.add(new Tile(1, "pushq", addr1, null)); iii.addAll(childDest.getTiles()); iii.add(new Tile(1, "popq", new AddressingMode("r12"), null)); iii.add(new Tile(1, "movq", new AddressingMode("r12"), addr2)); return iii; } inst.add(new Tile(1, "movq", addr1, addr2)); return inst; }