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
54c6f80f
Commit
54c6f80f
authored
Oct 28, 2022
by
李晓奇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push to repository
parent
06dd9b3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletion
+10
-1
Reports/3-ir-gen/report.md
Reports/3-ir-gen/report.md
+6
-0
src/cminusfc/cminusf_builder.cpp
src/cminusfc/cminusf_builder.cpp
+1
-0
src/cminusfc/cminusfc.cpp
src/cminusfc/cminusfc.cpp
+3
-1
No files found.
Reports/3-ir-gen/report.md
View file @
54c6f80f
...
...
@@ -128,6 +128,12 @@ PB20111654 李晓奇
-
知道了为什么clang生成的中间代码,会把实参声明一遍再拷贝了。
在我看来方便编译器代码的生成,因为重新声明,push给scope的值是指针类型而不是纯值,这在后边访问Var中有用。
-
发现ret会有乱跳转的问题,这个在最后一个测试的abs中发现。
问题出在:我为if_else语句设置了三个测试块,分别负责if,else,和跳出。但是有一处的块是空的,就会导致生成默认返回。
后来发这里其实并没有问题,如果有返回值,在if或者else内部就返回了,并不会跳出去被默认返回扰乱。
## 实验设计
...
...
src/cminusfc/cminusf_builder.cpp
View file @
54c6f80f
...
...
@@ -400,6 +400,7 @@ void CminusfBuilder::visit(ASTReturnStmt &node) {
}
builder
->
create_ret
(
cur_value
);
LOG_DEBUG
<<
"create ret:
\n
"
<<
builder
->
get_module
()
->
print
();
}
}
...
...
src/cminusfc/cminusfc.cpp
View file @
54c6f80f
...
...
@@ -67,7 +67,8 @@ int main(int argc, char **argv) {
std
::
cerr
<<
argv
[
0
]
<<
": input file "
<<
input_path
<<
" has unknown filetype!"
<<
std
::
endl
;
return
-
1
;
}
else
{
if
(
input_path
.
substr
(
pos
)
!=
".cminus"
)
{
// if (input_path.substr(pos) != ".cminus") {
if
(
input_path
.
substr
(
pos
).
substr
(
0
,
2
)
!=
".c"
)
{
std
::
cerr
<<
argv
[
0
]
<<
": input file "
<<
input_path
<<
" has unknown filetype!"
<<
std
::
endl
;
return
-
1
;
}
...
...
@@ -105,6 +106,7 @@ int main(int argc, char **argv) {
std
::
string
lib_path
=
argv
[
0
];
lib_path
.
erase
(
lib_path
.
rfind
(
'/'
))
+=
"/libcminus_io.a"
;
auto
command_string
=
"clang -O0 -w "
s
+
target_path
+
".ll -o "
+
target_path
+
" "
+
lib_path
;
std
::
cout
<<
command_string
<<
std
::
endl
;
int
re_code0
=
std
::
system
(
command_string
.
c_str
());
command_string
=
"rm "
s
+
target_path
+
".ll"
;
int
re_code1
=
std
::
system
(
command_string
.
c_str
());
...
...
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