Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
2
2022fall-Compiler_CMinus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晓奇
2022fall-Compiler_CMinus
Commits
33502fa9
Commit
33502fa9
authored
Jan 27, 2023
by
lxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dry action for CmpInst
parent
eda3505d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+25
-25
No files found.
src/codegen/codegen.cpp
View file @
33502fa9
...
...
@@ -302,31 +302,31 @@ CodeGen::IR2assem(CallInst *instr) {
if
(
not
instr
->
is_void
())
back2stack
(
instr
);
}
void
CodeGen
::
IR2assem
(
CmpInst
*
instr
)
{
value2reg
(
instr
->
get_operand
(
0
),
0
);
value2reg
(
instr
->
get_operand
(
1
),
1
);
string
instr_ir
;
switch
(
instr
->
get_cmp_op
())
{
case
CmpInst
::
EQ
:
break
;
case
CmpInst
::
NE
:
// output.push_back("xor $a0, $a0, $a1");
break
;
case
CmpInst
::
GT
:
output
.
push_back
(
"slt $a0, $a1, $a0"
);
break
;
case
CmpInst
::
GE
:
break
;
case
CmpInst
::
LT
:
output
.
push_back
(
"slt $a0, $a0, $a1"
);
break
;
case
CmpInst
::
LE
:
break
;
}
output
.
push_back
(
instr_ir
+
" $a0, $a0, $a1"
);
back2stack
(
instr
);
}
/*
void
*
CodeGen::IR2assem(CmpInst *instr) {
*
value2reg(instr->get_operand(0), 0);
*
value2reg(instr->get_operand(1), 1);
*
string instr_ir;
*
switch (instr->get_cmp_op()) {
*
case CmpInst::EQ:
*
break;
*
case CmpInst::NE:
*
// output.push_back("xor $a0, $a0, $a1");
*
break;
*
case CmpInst::GT:
*
output.push_back("slt $a0, $a1, $a0");
*
break;
*
case CmpInst::GE:
*
break;
*
case CmpInst::LT:
*
output.push_back("slt $a0, $a0, $a1");
*
break;
*
case CmpInst::LE:
*
break;
*
}
*
output.push_back(instr_ir + " $a0, $a0, $a1");
*
back2stack(instr);
* } */
void
CodeGen
::
IR2assem
(
BinaryInst
*
instr
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment