Commit 1a0e7463 authored by Tom Zhao's avatar Tom Zhao
Browse files

xz1919: resolved all issues related to array, all array test passed except printRef

parent d97ca391
......@@ -136,7 +136,7 @@ public class IntelInstructionGenerator extends InstructionGenerator<IntelInstruc
visit(index);
indexReg = intelRegAllocator.curr();
if (isLhs) {
instructions.add(new Mov(new IntelAddress(indexReg), indexReg));
instructions.add(new Mov(new IntelAddress(indexReg), indexReg.withSize(intToIntelSize.get(index.getType().getSize()))));
}
} else {
indexReg = intelRegAllocator.allocate();
......@@ -300,16 +300,13 @@ public class IntelInstructionGenerator extends InstructionGenerator<IntelInstruc
int offset = currSymbolTable.getStackOffset(node.getName(), node.getSymbol())
- currParamListSize + stackOffset;
System.out.println(node.getName());
System.out.println(offset);
/* if is lhs, then only put address in register */
if (isLhs) {
instructions.add(new Lea(new IntelAddress(rbp, -offset), intelRegAllocator.allocate()));
} else {
/* otherwise, put value in register */
Map<Integer, IntelMovType> m = Map.of(8, IntelMovType.MOV, 4, IntelMovType.MOV, 1, IntelMovType.MOVZBQ);
instructions.add(new Mov(new IntelAddress(rbp, -offset), intelRegAllocator.allocate(), m.get(identTypeSize)));
instructions.add(new Mov(new IntelAddress(rbp, -offset), intelRegAllocator.allocate().withSize(intToIntelSize.get(identTypeSize)), m.get(identTypeSize)));
}
return null;
}
......
......@@ -46,7 +46,7 @@ public class Mov extends MovInstruction implements IntelInstruction {
boolean isNormalMov = type.equals(IntelMovType.MOV);
if (!isNormalMov) {
str.append(type.name().toLowerCase(Locale.ROOT));
str.append(type.name().toLowerCase());
}
String size = "";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment