[backend]引入了新的pass,负责消除数组复杂地址访问
This commit is contained in:
@@ -17,6 +17,7 @@ using namespace antlr4;
|
||||
#include "RISCv64Backend.h"
|
||||
#include "SysYIRAnalyser.h"
|
||||
#include "DeadCodeElimination.h"
|
||||
#include "AddressCalculationExpansion.h"
|
||||
#include "Mem2Reg.h"
|
||||
#include "Reg2Mem.h"
|
||||
|
||||
@@ -143,20 +144,19 @@ int main(int argc, char **argv) {
|
||||
cout << "=== After CFA & AVA (Default) ===\n";
|
||||
SysYPrinter(moduleIR).printIR(); // 临时打印器用于调试
|
||||
}
|
||||
|
||||
DeadCodeElimination dce(moduleIR, &cfa, &ava);
|
||||
dce.runDCEPipeline();
|
||||
if (DEBUG) {
|
||||
cout << "=== After 1st DCE (Default) ===\n";
|
||||
SysYPrinter(moduleIR).printIR();
|
||||
AddressCalculationExpansion ace(moduleIR, builder);
|
||||
if (ace.run()) {
|
||||
cout << "AddressCalculationExpansion made changes.\n";
|
||||
// 如果 ACE 改变了IR,并且 DEBUG 模式开启,可以考虑打印IR
|
||||
if (DEBUG) {
|
||||
cout << "=== After AddressCalculationExpansion ===\n";
|
||||
SysYPrinter(moduleIR).printIR();
|
||||
}
|
||||
} else {
|
||||
cout << "AddressCalculationExpansion made no changes.\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 根据优化级别,执行额外的优化 pass
|
||||
if (optLevel >= 1) {
|
||||
cout << "Applying additional -O" << optLevel << " optimizations...\n";
|
||||
@@ -174,7 +174,13 @@ int main(int argc, char **argv) {
|
||||
// MyCustomOpt2 opt2_pass(moduleIR, builder, &cfa); // 假设需要CFA
|
||||
// opt2_pass.run();
|
||||
// ... 更多 -O1 特有的优化
|
||||
|
||||
DeadCodeElimination dce(moduleIR, &cfa, &ava);
|
||||
dce.runDCEPipeline();
|
||||
if (DEBUG) {
|
||||
cout << "=== After 1st DCE (Default) ===\n";
|
||||
SysYPrinter(moduleIR).printIR();
|
||||
}
|
||||
|
||||
Mem2Reg mem2reg(moduleIR, builder, &cfa, &ava);
|
||||
mem2reg.mem2regPipeline();
|
||||
if (DEBUG) {
|
||||
@@ -212,7 +218,7 @@ int main(int argc, char **argv) {
|
||||
// 设置 DEBUG 模式(如果指定了 'asmd')
|
||||
if (argStopAfter == "asmd") {
|
||||
DEBUG = 1;
|
||||
DEEPDEBUG = 1;
|
||||
// DEEPDEBUG = 1;
|
||||
}
|
||||
sysy::RISCv64CodeGen codegen(moduleIR); // 传入优化后的 moduleIR
|
||||
string asmCode = codegen.code_gen();
|
||||
|
||||
Reference in New Issue
Block a user