merging branch lab2-IRGen into master

This commit is contained in:
lixuanwang
2025-05-28 23:49:02 +08:00
parent 90ba6db318
commit bb73ce3b5a
4 changed files with 554 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ using namespace antlr4;
#include "ASTPrinter.h"
#include "Backend.h"
#include "SysYIRGenerator.h"
#include "LLVMIRGenerator.h"
using namespace sysy;
static string argStopAfter;
@@ -20,7 +21,7 @@ void usage(int code = EXIT_FAILURE) {
"Supported options:\n"
" -h \tprint help message and exit\n";
" -f \tpretty-format the input file\n";
" -s {ast,ir,asm}\tstop after generating AST/IR/Assembly\n";
" -s {ast,ir,asm,llvmir}\tstop after generating AST/IR/Assembly\n";
cerr << msg;
exit(code);
}
@@ -83,6 +84,10 @@ int main(int argc, char **argv) {
if (argStopAfter == "ir") {
moduleIR->print(cout);
return EXIT_SUCCESS;
} else if (argStopAfter == "llvmir") {
LLVMIRGenerator llvmirGenerator;
cout << llvmirGenerator.getIR();
return EXIT_SUCCESS;
}
// generate assembly