Commit c736471e authored by 甘文迪's avatar 甘文迪

Update cminusfc.cpp

parent 258a7391
#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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment