diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-19 18:13:19 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-19 18:13:19 +0800 |
| commit | 2920d4547d2ccea40da547de5d07dd2383de5e87 (patch) | |
| tree | 139a71b0ff6db081e1ae70a97cd81b031b1c59a0 /backend/unittests/Target | |
| parent | ff1029193a6c505e31b0b5df360c9af73b921b42 (diff) | |
| download | rcc-project-2920d4547d2ccea40da547de5d07dd2383de5e87.tar.gz rcc-project-2920d4547d2ccea40da547de5d07dd2383de5e87.tar.xz | |
[CodeGen] Remove RCC fallthrough normalization
Diffstat (limited to 'backend/unittests/Target')
| -rw-r--r-- | backend/unittests/Target/RISCVLateCodeGenTest.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/backend/unittests/Target/RISCVLateCodeGenTest.cpp b/backend/unittests/Target/RISCVLateCodeGenTest.cpp index 955af50..8160370 100644 --- a/backend/unittests/Target/RISCVLateCodeGenTest.cpp +++ b/backend/unittests/Target/RISCVLateCodeGenTest.cpp @@ -10,7 +10,6 @@ #include "rcc/CodeGen/MachineBranchRelaxation.h" #include "rcc/CodeGen/MachineCFGUpdater.h" #include "rcc/CodeGen/MachineCopyPropagation.h" -#include "rcc/CodeGen/MachineFallthrough.h" #include "rcc/CodeGen/MachineFinalization.h" #include "rcc/CodeGen/MachineFunction.h" #include "rcc/CodeGen/MachineIRBuilder.h" @@ -384,77 +383,6 @@ void testBlockPlacement(TestContext &Context, const rcc::TargetDescription &Targ "block placement must put the highest-probability successor on the trace"); } -void testFallthroughNormalization(TestContext &Context, const rcc::TargetDescription &Target) { - auto Function = makeFunction(Context, "fallthrough", 2); - if (!Function) - return; - rcc::MachineBasicBlock *Entry = appendBlock(Context, *Function); - rcc::MachineBasicBlock *False = appendBlock(Context, *Function); - rcc::MachineBasicBlock *True = appendBlock(Context, *Function); - if (Entry == nullptr || False == nullptr || True == nullptr) - return; - auto Half = rcc::BranchProbability::fromFraction(1, 2); - auto CFG = Function->cfgUpdater(); - Context.expect(Half && CFG.addSuccessor(*Entry, *True, *Half).has_value() && - CFG.addSuccessor(*Entry, *False, *Half).has_value(), - "fallthrough CFG construction must succeed"); - rcc::MachineIRBuilder Builder(*Function, Target); - Context.expect(Builder.setInsertPoint(*Entry).has_value(), - "fallthrough insertion point must be established"); - rcc::MachineInstr *Conditional = - buildConditional(Context, Builder, rcc::riscv::InstructionOpcode::BEQ, *True); - rcc::MachineInstr *Jump = buildJAL(Context, Builder, *False); - if (Conditional == nullptr || Jump == nullptr) - return; - setPostRAProperties(*Function); - auto Liveness = rcc::rebuildMachineLiveness(*Function, Target); - Context.expect(Liveness.has_value(), "fallthrough fixture liveness must be rebuilt"); - rcc::MachineFunctionAnalysisManager Analyses; - rcc::MachineFallthroughPass Pass(rcc::riscv::instrInfo()); - auto Result = Pass.run(*Function, Target, Analyses); - if (!Result) - std::cerr << "fallthrough normalization failure: " << Result.error().message() << '\n'; - Context.expect(Result && Result->Changed && Conditional->next() == nullptr && - Jump->parent() == nullptr, - "fallthrough normalization must remove a jump to the next block"); -} - -void testFallthroughMaterialization(TestContext &Context, const rcc::TargetDescription &Target) { - auto Function = makeFunction(Context, "fallthrough_materialization", 8); - if (!Function) - return; - rcc::MachineBasicBlock *Entry = appendBlock(Context, *Function); - rcc::MachineBasicBlock *Padding = appendBlock(Context, *Function); - rcc::MachineBasicBlock *True = appendBlock(Context, *Function); - rcc::MachineBasicBlock *False = appendBlock(Context, *Function); - if (Entry == nullptr || Padding == nullptr || True == nullptr || False == nullptr) - return; - auto Half = rcc::BranchProbability::fromFraction(1, 2); - auto CFG = Function->cfgUpdater(); - Context.expect(Half && CFG.addSuccessor(*Entry, *True, *Half).has_value() && - CFG.addSuccessor(*Entry, *False, *Half).has_value(), - "materialized fallthrough CFG construction must succeed"); - rcc::MachineIRBuilder Builder(*Function, Target); - Context.expect(Builder.setInsertPoint(*Entry).has_value(), - "materialized fallthrough insertion point must be established"); - rcc::MachineInstr *Conditional = - buildConditional(Context, Builder, rcc::riscv::InstructionOpcode::BNE, *True); - if (Conditional == nullptr) - return; - setPostRAProperties(*Function); - Context.expect(rcc::rebuildMachineLiveness(*Function, Target).has_value(), - "materialized fallthrough liveness must be rebuilt"); - rcc::MachineFunctionAnalysisManager Analyses; - rcc::MachineFallthroughPass Pass(rcc::riscv::instrInfo()); - auto Result = Pass.run(*Function, Target, Analyses); - if (!Result) - std::cerr << "fallthrough materialization failure: " << Result.error().message() << '\n'; - Context.expect(Result && Result->Changed && Conditional->next() != nullptr && - Conditional->next()->opcode() == opcode(rcc::riscv::InstructionOpcode::JAL) && - branchTarget(*Conditional->next()) == False, - "fallthrough normalization must materialize a displaced false edge"); -} - void testBranchOptimization(TestContext &Context, const rcc::TargetDescription &Target) { auto Function = makeFunction(Context, "branch_optimization", 9); if (!Function) @@ -1359,8 +1287,6 @@ int main() { if (!Target) return Context.result(); testBlockPlacement(Context, *Target); - testFallthroughNormalization(Context, *Target); - testFallthroughMaterialization(Context, *Target); testBranchOptimization(Context, *Target); testTailDuplication(Context, *Target); testBranchFoldingTailMerge(Context, *Target); |
