Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs164_lab3_cg
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
recolic-hust
cs164_lab3_cg
Commits
432b5aa9
There was an error fetching the commit references. Please try again later.
Commit
432b5aa9
authored
6 years ago
by
Vedaank
Browse files
Options
Downloads
Patches
Plain Diff
added return null cmp int, 17 pass
parent
a74511b1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
src/main/java/chocopy/pa3/CodeGenImpl.java
+6
-2
6 additions, 2 deletions
src/main/java/chocopy/pa3/CodeGenImpl.java
with
7 additions
and
3 deletions
Makefile
+
1
−
1
View file @
432b5aa9
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
:
...
...
This diff is collapsed.
Click to expand it.
src/main/java/chocopy/pa3/CodeGenImpl.java
+
6
−
2
View file @
432b5aa9
...
@@ -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
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment