5 Star 0 Fork 1

嘉然今天偷着乐/SysY-Compiler

forked from 黄子潇/SysY-Compiler 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sysyc.cpp 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
MIN 提交于 2022-08-03 22:11 . fix bug
#include "sysy/Support/CommandLine.h"
#include "sysy/Frontend/Frontend.h"
#include "sysy/IR/Module.h"
#include "sysy/IR/PassManager.h"
#include "sysy/Target/Module.h"
#include "sysy/Transform/Transform.h"
#include <string>
#include <iostream>
using namespace sysy;
cmdline::parser cmd;
int main(int argc, char* argv[])
{
cmd.add<std::string>("input", 0, "input filename");
cmd.add<std::string>("output", 'o', "output filename", false, "a.s");
cmd.add<std::string>("gen", 'g', "gen what type output", false, "asm", cmdline::oneof<std::string>("asm", "ast", "cst", "ir"));
cmd.add<std::string>("opt", 0, "opt level", false, "O0", cmdline::oneof<std::string>("O0", "O2"));
cmd.parse_check(argc, argv);
auto InputFilename = cmd.get<std::string>("input");
auto Gen = cmd.get<std::string>("gen");
auto OutputFilename = cmd.get<std::string>("output");
auto Opt = cmd.get<std::string>("opt");
std::cout << InputFilename << std::endl;
ir::Module* module;
if(!(module = FrontendMain(InputFilename, Gen)))
return 0;
auto pm = new ir::ModulePassManager;
ir::initialIRTransform(Opt, pm);
pm->run(module);
mc::Module* mc_module = new mc::Module(module);
mc_module->run(OutputFilename);// TODO: 写成mc::PassManager的形式
// 如下->
// using mc::ModulePassManager = PassManager<mc::Module>
// pm->addPass(new RegAlloc) ...........................
// std::cout << "hello world" << std::endl;
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/diana-have-fun-today/sys-y-compiler.git
git@gitee.com:diana-have-fun-today/sys-y-compiler.git
diana-have-fun-today
sys-y-compiler
SysY-Compiler
develop

搜索帮助