Skip to content

Commit

Permalink
[handout]
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoAfoat committed Aug 20, 2024
1 parent b99ca75 commit 54b2522
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
1 change: 1 addition & 0 deletions ir/opt/new_passManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void _PassManager::DecodeArgs(int argc, char *argv[]) {
bool _PassManager::Run() { return true; }

void _PassManager::RunOnLevel() {
level=O1;
if (level == O0)
return;
if (level == O1) {
Expand Down
34 changes: 4 additions & 30 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,19 @@ void copyFile(const std::string &sourcePath,
}

int main(int argc, char **argv) {
std::string output_path = argv[1];
output_path += ".ll";

std::string filename = argv[1];
size_t lastSlashPos = filename.find_last_of("/\\") + 1;
filename = filename.substr(lastSlashPos);

asmoutput_path = argv[1];
size_t lastPointPos = asmoutput_path.find_last_of(".");
asmoutput_path = asmoutput_path.substr(0, lastPointPos) + ".s";

copyFile("runtime.ll", output_path);
freopen(output_path.c_str(), "a", stdout);
yyin = fopen(argv[1], "r");
// compiler -S -o testcase.s testcase.sy
asmoutput_path = argv[3];
yyin = fopen(argv[4], "r");
yy::parser parse;
parse();
Singleton<CompUnit *>()->codegen();
// #ifdef SYSY_ENABLE_MIDDLE_END
auto PM = std::make_unique<_PassManager>();
PM->DecodeArgs(argc, argv);
#ifdef TEST
PM->RunOnTest();
#elif defined(LEVEL)
// PM->DecodeArgs(argc-4,argv+4);
PM->RunOnLevel();
// #else
// assert(0);
#endif
Singleton<Module>().Test();
fflush(stdout);
fclose(stdout);
// #endif
// #ifdef SYSY_ENABLE_BACKEND
freopen(asmoutput_path.c_str(), "w", stdout);
RISCVModuleLowering RISCVAsm;
RISCVAsm.run(&Singleton<Module>());
fflush(stdout);
fclose(stdout);
// #endif
// freopen("dev/tty", "w", stdout);

return 0;
}

0 comments on commit 54b2522

Please sign in to comment.