Skip to content
Snippets Groups Projects
Commit 432b5aa9 authored by Vedaank's avatar Vedaank
Browse files

added return null cmp int, 17 pass

parent a74511b1
No related branches found
No related tags found
No related merge requests found
CLEAN=mvn clean package CLEAN=mvn clean package
TEST=java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy --pass=..s --run --dir src/test/data/pa3/sample/ --test TEST=java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy --pass=..s --run --dir src/test/data/pa3/sample/ --test
FILE= FILE=op_cmp_int
clean: clean:
$(CLEAN) $(CLEAN)
test: test:
......
...@@ -548,6 +548,7 @@ public class CodeGenImpl extends CodeGenBase { ...@@ -548,6 +548,7 @@ public class CodeGenImpl extends CodeGenBase {
backend.emitXOR(T0, T0, T1, "== operator on BOOL/INT"); backend.emitXOR(T0, T0, T1, "== operator on BOOL/INT");
backend.emitSEQZ(T0, T0, "Set to 1 if XOR results in 0, they were equal"); backend.emitSEQZ(T0, T0, "Set to 1 if XOR results in 0, they were equal");
backend.emitSW(T0, SP, 0, "Push result onto stack"); backend.emitSW(T0, SP, 0, "Push result onto stack");
return null;
} }
case "!=": case "!=":
...@@ -566,6 +567,7 @@ public class CodeGenImpl extends CodeGenBase { ...@@ -566,6 +567,7 @@ public class CodeGenImpl extends CodeGenBase {
// Don't think we need to do the SEQZ/SNEZ instructions here because XOR will already result in 1 // Don't think we need to do the SEQZ/SNEZ instructions here because XOR will already result in 1
// if they are not equal, which is the desired result. // if they are not equal, which is the desired result.
backend.emitSW(T0, SP, 0, "Push result onto stack"); backend.emitSW(T0, SP, 0, "Push result onto stack");
return null;
} }
case "<=": case "<=":
if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) { if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) {
...@@ -583,7 +585,7 @@ public class CodeGenImpl extends CodeGenBase { ...@@ -583,7 +585,7 @@ public class CodeGenImpl extends CodeGenBase {
backend.emitSLLI(T1, T1, 4, "Compute offset to correct object"); backend.emitSLLI(T1, T1, 4, "Compute offset to correct object");
backend.emitADD(T0, T0, T1, "Add offset to curr ptr"); backend.emitADD(T0, T0, T1, "Add offset to curr ptr");
backend.emitSW(T0, SP, 0, "Push result onto stack"); backend.emitSW(T0, SP, 0, "Push result onto stack");
return null;
} }
case ">=": case ">=":
if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) { if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) {
...@@ -601,6 +603,7 @@ public class CodeGenImpl extends CodeGenBase { ...@@ -601,6 +603,7 @@ public class CodeGenImpl extends CodeGenBase {
backend.emitSLLI(T1, T1, 4, "Compute offset to correct object"); backend.emitSLLI(T1, T1, 4, "Compute offset to correct object");
backend.emitADD(T0, T0, T1, "Add offset to curr ptr"); backend.emitADD(T0, T0, T1, "Add offset to curr ptr");
backend.emitSW(T0, SP, 0, "Push result onto stack"); backend.emitSW(T0, SP, 0, "Push result onto stack");
return null;
} }
case "<": case "<":
if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) { if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) {
...@@ -617,7 +620,7 @@ public class CodeGenImpl extends CodeGenBase { ...@@ -617,7 +620,7 @@ public class CodeGenImpl extends CodeGenBase {
backend.emitSLLI(T1, T1, 4, "Compute offset to correct object"); backend.emitSLLI(T1, T1, 4, "Compute offset to correct object");
backend.emitADD(T0, T0, T1, "Add offset to curr ptr"); backend.emitADD(T0, T0, T1, "Add offset to curr ptr");
backend.emitSW(T0, SP, 0, "Push result onto stack"); backend.emitSW(T0, SP, 0, "Push result onto stack");
return null;
} }
case ">": case ">":
if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) { if (binaryExpr.left.getInferredType().equals(SymbolType.INT_TYPE)) {
...@@ -634,6 +637,7 @@ public class CodeGenImpl extends CodeGenBase { ...@@ -634,6 +637,7 @@ public class CodeGenImpl extends CodeGenBase {
backend.emitSLLI(T1, T1, 4, "Compute offset to correct object"); backend.emitSLLI(T1, T1, 4, "Compute offset to correct object");
backend.emitADD(T0, T0, T1, "Add offset to curr ptr"); backend.emitADD(T0, T0, T1, "Add offset to curr ptr");
backend.emitSW(T0, SP, 0, "Push result onto stack"); backend.emitSW(T0, SP, 0, "Push result onto stack");
return null;
} }
case "and": case "and":
if (binaryExpr.getInferredType().equals(SymbolType.INT_TYPE)) { if (binaryExpr.getInferredType().equals(SymbolType.INT_TYPE)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment