refactor(test): 简化验证脚本命名并统一测试输出目录

master
Lane0218 1 week ago
parent 62dde8d7ab
commit a3b5018a17

@ -33,7 +33,7 @@ sudo apt install -y build-essential cmake git openjdk-11-jre
### 2.3 安装 LLVM 工具链
`scripts/verify_ir_with_llvm.sh` 在 `--run` 模式下会调用 LLVM 工具链(`llc` 与 `clang`)将生成的 IR 编译并运行。
`scripts/verify_ir.sh` 在 `--run` 模式下会调用 LLVM 工具链(`llc` 与 `clang`)将生成的 IR 编译并运行。
```bash
sudo apt update
@ -91,7 +91,7 @@ cmake --build build -j "$(nproc)"
跑完整编译流程自检:从 SysY 源码生成 AArch64 汇编,完成汇编、链接,并在 QEMU 下运行结果程序:
```bash
./scripts/verify_asm_with_qemu.sh test/test_case/simple_add.sy out/asm --run
./scripts/verify_asm.sh test/test_case/simple_add.sy test/test_result/asm --run
```
如果最终看到 `退出码: 3`,说明当前最小子集示例 `return a + b` 的完整链路已经跑通。

@ -85,5 +85,5 @@ cmake --build build -j "$(nproc)"
```bash
./scripts/verify_ir_with_llvm.sh test/test_case/simple_add.sy out/ir --run
./scripts/verify_ir.sh test/test_case/simple_add.sy test/test_result/ir --run
```

@ -49,7 +49,7 @@ Lab3 的目标是在该示例基础上扩展后端语义覆盖范围,逐步把
2. 视实现需要可能修改
- `src/main.cpp`(当需要调整输出阶段行为时)
- `src/utils/CLI.cpp`(当需要扩展后端相关命令行选项时)
- `scripts/verify_asm_with_qemu.sh`(当需要扩展统一验证脚本时)
- `scripts/verify_asm.sh`(当需要扩展统一验证脚本时)
## 5. 当前最小示例实现说明
@ -82,7 +82,7 @@ cmake --build build -j "$(nproc)"
推荐使用统一脚本验证 “源码 -> 汇编 -> 可执行程序” 整体链路,用于验证后端代码生成的正确性:
```bash
./scripts/verify_asm_with_qemu.sh test/test_case/simple_add.sy out/asm --run
./scripts/verify_asm.sh test/test_case/simple_add.sy test/test_result/asm --run
```
若最终输出 `退出码: 3`,说明当前最小子集示例 `return a + b` 的完整后端链路已经跑通。

@ -61,7 +61,7 @@ Lab4 的目标是在 Lab3 示例基础上,把“固定寄存器 + 栈槽”的
- `src/mir/MIRBasicBlock.cpp`(当需要扩展基本块级活跃性或辅助接口时)
- `src/main.cpp`(当需要调整后端阶段行为时)
- `src/utils/CLI.cpp`(当需要扩展后端调试相关命令行选项时)
- `scripts/verify_asm_with_qemu.sh`(当需要扩展统一验证脚本时)
- `scripts/verify_asm.sh`(当需要扩展统一验证脚本时)
## 5. 当前最小示例实现说明
@ -138,7 +138,7 @@ cmake --build build -j "$(nproc)"
推荐继续使用统一脚本验证 “源码 -> 汇编 -> 可执行程序” 整体链路,用于做最小回归:
```bash
./scripts/verify_asm_with_qemu.sh test/test_case/simple_add.sy out/asm --run
./scripts/verify_asm.sh test/test_case/simple_add.sy test/test_result/asm --run
```
建议在功能回归之外,再观察优化前后汇编输出差异。可按自己的实现方式保留调试日志、优化开关,或直接对比生成的汇编文本,重点关注:

@ -210,8 +210,8 @@ cmake --build build -j "$(nproc)"
### 8.2 语义回归
```bash
./scripts/verify_ir_with_llvm.sh test/test_case/simple_add.sy out/ir --run
./scripts/verify_asm_with_qemu.sh test/test_case/simple_add.sy out/asm --run
./scripts/verify_ir.sh test/test_case/simple_add.sy test/test_result/ir --run
./scripts/verify_asm.sh test/test_case/simple_add.sy test/test_result/asm --run
```
目标:优化后程序行为与优化前保持一致。

@ -157,8 +157,8 @@ cmake --build build -j "$(nproc)"
### 9.1 功能回归
```bash
./scripts/verify_ir_with_llvm.sh test/test_case/simple_add.sy out/ir --run
./scripts/verify_asm_with_qemu.sh test/test_case/simple_add.sy out/asm --run
./scripts/verify_ir.sh test/test_case/simple_add.sy test/test_result/ir --run
./scripts/verify_asm.sh test/test_case/simple_add.sy test/test_result/asm --run
```
### 9.2 优化效果对比(示例)
@ -170,5 +170,3 @@ cmake --build build -j "$(nproc)"
```
---

@ -8,7 +8,7 @@ if [[ $# -lt 1 || $# -gt 3 ]]; then
fi
input=$1
out_dir="out/asm"
out_dir="test/test_result/asm"
run_exec=false
shift
@ -44,7 +44,7 @@ mkdir -p "$out_dir"
base=$(basename "$input")
stem=${base%.sy}
asm_file="$out_dir/$stem.s"
exe="$out_dir/$stem.exe"
exe="$out_dir/$stem"
"$compiler" --emit-asm "$input" > "$asm_file"
echo "汇编已生成: $asm_file"

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# ./scripts/verify_ir_with_llvm.sh test/test_case/simple_add.sy --run
# ./scripts/verify_ir.sh test/test_case/simple_add.sy --run
set -euo pipefail
@ -9,7 +9,7 @@ if [[ $# -lt 1 || $# -gt 3 ]]; then
fi
input=$1
out_dir="out/ir"
out_dir="test/test_result/ir"
run_exec=false
shift
@ -53,7 +53,7 @@ if [[ "$run_exec" == true ]]; then
exit 1
fi
obj="$out_dir/$stem.o"
exe="$out_dir/$stem.exe"
exe="$out_dir/$stem"
llc -filetype=obj "$out_file" -o "$obj"
clang "$obj" -o "$exe"
echo "运行 $exe ..."
Loading…
Cancel
Save