Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
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
6
Merge Requests
6
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
c736471e
You need to sign in or sign up before continuing.
Commit
c736471e
authored
Jan 23, 2023
by
甘文迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cminusfc.cpp
parent
258a7391
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
src/cminusfc/cminusfc.cpp
src/cminusfc/cminusfc.cpp
+15
-13
No files found.
src/cminusfc/cminusfc.cpp
View file @
c736471e
#include "ActiveVars.hpp"
#include "ConstPropagation.hpp"
#include "DeadCode.h"
#include "DeadCode.h"
#include "Dominators.h"
#include "Dominators.h"
#include "GVN.h"
#include "GVN.h"
#include "LoopInvHoist.hpp"
#include "LoopSearch.hpp"
#include "Mem2Reg.hpp"
#include "Mem2Reg.hpp"
#include "PassManager.hpp"
#include "PassManager.hpp"
#include "cminusf_builder.hpp"
#include "cminusf_builder.hpp"
...
@@ -18,9 +14,10 @@
...
@@ -18,9 +14,10 @@
using
namespace
std
::
literals
::
string_literals
;
using
namespace
std
::
literals
::
string_literals
;
void
print_help
(
std
::
string
exe_name
)
{
void
print_help
(
std
::
string
exe_name
)
{
std
::
cout
<<
"Usage: "
<<
exe_name
std
::
cout
<<
" [ -h | --help ] [ -o <target-file> ] [ -emit-llvm ] [-mem2reg] [-gvn] [-dump-json] <input-file>"
<<
"Usage: "
<<
exe_name
<<
std
::
endl
;
<<
" [ -h | --help ] [ -o <target-file> ] [ -emit-llvm ] [ -S ] [-mem2reg] [-gvn] [-dump-json] <input-file>"
<<
std
::
endl
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
...
@@ -31,6 +28,7 @@ int main(int argc, char **argv) {
...
@@ -31,6 +28,7 @@ int main(int argc, char **argv) {
bool
gvn
=
false
;
bool
gvn
=
false
;
bool
dump_json
=
false
;
bool
dump_json
=
false
;
bool
emit
=
false
;
bool
emit
=
false
;
bool
assembly
=
false
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
argv
[
i
]
==
"-h"
s
||
argv
[
i
]
==
"--help"
s
)
{
if
(
argv
[
i
]
==
"-h"
s
||
argv
[
i
]
==
"--help"
s
)
{
...
@@ -48,6 +46,8 @@ int main(int argc, char **argv) {
...
@@ -48,6 +46,8 @@ int main(int argc, char **argv) {
emit
=
true
;
emit
=
true
;
}
else
if
(
argv
[
i
]
==
"-mem2reg"
s
)
{
}
else
if
(
argv
[
i
]
==
"-mem2reg"
s
)
{
mem2reg
=
true
;
mem2reg
=
true
;
}
else
if
(
argv
[
i
]
==
"-S"
s
)
{
assembly
=
true
;
}
else
if
(
argv
[
i
]
==
"-gvn"
s
)
{
}
else
if
(
argv
[
i
]
==
"-gvn"
s
)
{
gvn
=
true
;
gvn
=
true
;
}
else
if
(
argv
[
i
]
==
"-dump-json"
s
)
{
}
else
if
(
argv
[
i
]
==
"-dump-json"
s
)
{
...
@@ -105,12 +105,14 @@ int main(int argc, char **argv) {
...
@@ -105,12 +105,14 @@ int main(int argc, char **argv) {
auto
IR
=
m
->
print
();
auto
IR
=
m
->
print
();
CodeGen
codegen
(
m
.
get
());
if
(
assembly
)
{
codegen
.
run
();
CodeGen
codegen
(
m
.
get
());
codegen
.
run
();
std
::
ofstream
target_file
(
target_path
+
".s"
);
std
::
ofstream
target_file
(
target_path
+
".s"
);
target_file
<<
codegen
.
print
();
target_file
<<
codegen
.
print
();
target_file
.
close
();
target_file
.
close
();
return
0
;
}
std
::
ofstream
output_stream
;
std
::
ofstream
output_stream
;
auto
output_file
=
target_path
+
".ll"
;
auto
output_file
=
target_path
+
".ll"
;
...
...
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