Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
2
2025ustc-jianmu-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
43
Merge Requests
43
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
compiler_staff
2025ustc-jianmu-compiler
Commits
ea90d4dc
Commit
ea90d4dc
authored
Nov 26, 2025
by
Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recover ASMInst change
parent
78b2f265
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
9 deletions
+6
-9
include/codegen/CodeGen.hpp
include/codegen/CodeGen.hpp
+3
-6
src/codegen/CodeGen.cpp
src/codegen/CodeGen.cpp
+3
-3
No files found.
include/codegen/CodeGen.hpp
View file @
ea90d4dc
...
@@ -8,16 +8,13 @@
...
@@ -8,16 +8,13 @@
class
CodeGen
{
class
CodeGen
{
public:
public:
explicit
CodeGen
(
Module
*
module
)
:
m
(
module
)
{}
explicit
CodeGen
(
Module
*
module
)
:
m
(
module
)
{}
~
CodeGen
(){
for
(
auto
i
:
output
)
delete
i
;
}
std
::
string
print
()
const
;
std
::
string
print
()
const
;
void
run
();
void
run
();
template
<
class
...
Args
>
void
append_inst
(
Args
...
arg
)
{
template
<
class
...
Args
>
void
append_inst
(
Args
...
arg
)
{
output
.
emplace_back
(
new
ASMInstruction
(
arg
...)
);
output
.
emplace_back
(
arg
...
);
}
}
void
void
...
@@ -29,7 +26,7 @@ class CodeGen {
...
@@ -29,7 +26,7 @@ class CodeGen {
}
}
content
.
pop_back
();
content
.
pop_back
();
content
.
pop_back
();
content
.
pop_back
();
output
.
emplace_back
(
new
ASMInstruction
(
content
,
ty
)
);
output
.
emplace_back
(
content
,
ty
);
}
}
private:
private:
...
@@ -101,5 +98,5 @@ class CodeGen {
...
@@ -101,5 +98,5 @@ class CodeGen {
}
context
;
}
context
;
Module
*
m
;
Module
*
m
;
std
::
list
<
ASMInstruction
*
>
output
;
std
::
list
<
ASMInstruction
>
output
;
};
};
src/codegen/CodeGen.cpp
View file @
ea90d4dc
...
@@ -405,7 +405,7 @@ void CodeGen::run() {
...
@@ -405,7 +405,7 @@ void CodeGen::run() {
}
}
// 函数代码段
// 函数代码段
output
.
emplace_back
(
new
ASMInstruction
(
".text"
,
ASMInstruction
::
Attribute
)
);
output
.
emplace_back
(
".text"
,
ASMInstruction
::
Attribute
);
for
(
auto
func
:
m
->
get_functions
())
{
for
(
auto
func
:
m
->
get_functions
())
{
if
(
not
func
->
is_declaration
())
{
if
(
not
func
->
is_declaration
())
{
// 更新 context
// 更新 context
...
@@ -511,8 +511,8 @@ void CodeGen::run() {
...
@@ -511,8 +511,8 @@ void CodeGen::run() {
std
::
string
CodeGen
::
print
()
const
{
std
::
string
CodeGen
::
print
()
const
{
std
::
string
result
;
std
::
string
result
;
for
(
const
auto
inst
:
output
)
{
for
(
const
auto
&
inst
:
output
)
{
result
+=
inst
->
format
();
result
+=
inst
.
format
();
}
}
return
result
;
return
result
;
}
}
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