diff --git a/src/sysyc.cpp b/src/sysyc.cpp index bb9b783..bcde78f 100644 --- a/src/sysyc.cpp +++ b/src/sysyc.cpp @@ -125,7 +125,7 @@ int main(int argc, char **argv) { // 无论最终输出是 IR 还是 ASM,只要不是停止在 AST 阶段,都会进入此优化流程。 // optLevel = 0 时,执行默认优化。 // optLevel >= 1 时,执行默认优化 + 额外的 -O1 优化。 - cout << "Applying middle-end optimizations (level -O" << optLevel << ")...\n"; + if (DEBUG) cout << "Applying middle-end optimizations (level -O" << optLevel << ")...\n"; // 设置 DEBUG 模式(如果指定了 'ird') if (argStopAfter == "ird") { @@ -146,20 +146,20 @@ int main(int argc, char **argv) { } AddressCalculationExpansion ace(moduleIR, builder); if (ace.run()) { - cout << "AddressCalculationExpansion made changes.\n"; + if (DEBUG) 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"; + if (DEBUG) cout << "AddressCalculationExpansion made no changes.\n"; } // 根据优化级别,执行额外的优化 pass if (optLevel >= 1) { - cout << "Applying additional -O" << optLevel << " optimizations...\n"; + if (DEBUG) cout << "Applying additional -O" << optLevel << " optimizations...\n"; // 放置 -O1 及其以上级别要启用的额外优化 pass // 例如: // MyNewOptimizationPass newOpt(moduleIR, builder); @@ -201,7 +201,7 @@ int main(int argc, char **argv) { SysYPrinter(moduleIR).printIR(); } } else { - cout << "No additional middle-end optimizations applied for -O" << optLevel << ".\n"; + if (DEBUG) cout << "No additional middle-end optimizations applied for -O" << optLevel << ".\n"; } // 5. 根据 argStopAfter 决定后续操作 diff --git a/test_script/runit.sh b/test_script/runit.sh index b8dc458..6a459d6 100644 --- a/test_script/runit.sh +++ b/test_script/runit.sh @@ -102,8 +102,8 @@ find "${TESTDATA_DIR}" -name "*.sy" | while read sy_file; do echo " SY 文件: ${sy_file}" # 步骤 1: 使用 sysyc 编译 .sy 到 .s - echo " 使用 sysyc 编译: ${SYSYC} -s asm \"${sy_file}\" > \"${assembly_file}\"" - "${SYSYC}" -s asm "${sy_file}" > "${assembly_file}" + echo " 使用 sysyc 编译: ${SYSYC} -S \"${sy_file}\" -o \"${assembly_file}\"" + "${SYSYC}" -S "${sy_file}" -o "${assembly_file}" if [ $? -ne 0 ]; then echo -e "\e[31m错误: SysY 编译 ${sy_file} 失败\e[0m" continue diff --git a/testdata/functional/73_int_io.in b/testdata/functional/73_int_io.in index 98c32c2..bf09072 100755 --- a/testdata/functional/73_int_io.in +++ b/testdata/functional/73_int_io.in @@ -1,14 +1,6 @@ - - 5 - 4006571 - - 9900 - 1504379 - - -758219 - 99336677 - - - \ No newline at end of file +4006571 +9900 +1504379 +758219 +99336677 \ No newline at end of file