aboutsummaryrefslogtreecommitdiff
path: root/backend/tools/MIRTool
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-12 04:21:14 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-12 04:21:14 +0800
commit1775d50ba02dab033c639f5c8fedd46cb6613bef (patch)
treeb4ca387ff0015862cdf90a8652ad35402fa9af69 /backend/tools/MIRTool
parent64c0360a6646dd1d3f75b8d1ed11ec4da825256b (diff)
downloadrcc-project-1775d50ba02dab033c639f5c8fedd46cb6613bef.tar.gz
rcc-project-1775d50ba02dab033c639f5c8fedd46cb6613bef.tar.xz
[Tooling] Adopt LLVM MIR command-line spellings
Diffstat (limited to 'backend/tools/MIRTool')
-rw-r--r--backend/tools/MIRTool/MIRToolMain.cpp92
-rw-r--r--backend/tools/MIRTool/MIRToolOperationsTest.cmake46
-rw-r--r--backend/tools/MIRTool/MIRToolOutputTest.cmake4
-rw-r--r--backend/tools/MIRTool/MIRToolStageTest.cmake70
4 files changed, 142 insertions, 70 deletions
diff --git a/backend/tools/MIRTool/MIRToolMain.cpp b/backend/tools/MIRTool/MIRToolMain.cpp
index f764cf0..ea180d6 100644
--- a/backend/tools/MIRTool/MIRToolMain.cpp
+++ b/backend/tools/MIRTool/MIRToolMain.cpp
@@ -81,15 +81,17 @@ void printUsage(std::ostream &Output) {
" --fuzz <layer,...|all> Run deterministic layered fuzzing\n"
" --list-passes List the canonical pipeline suffix\n"
"pipeline/output:\n"
- " --run-pass <name> Run one named pass\n"
- " --passes <name,...> Run an explicit pass sequence\n"
- " --stop-before <pass[#N]> Stop before a pass occurrence\n"
- " --stop-after <pass[#N]> Stop after a pass occurrence\n"
- " --print-before <pass[#N],...> Print snapshots before passes\n"
- " --print-after <pass[#N],...> Print snapshots after passes\n"
+ " -run-pass <name> Run one named pass\n"
+ " -passes <name,...> Run an explicit pass sequence\n"
+ " -stop-before <pass[#N]> Stop before a pass occurrence\n"
+ " -stop-after <pass[#N]> Stop after a pass occurrence\n"
+ " -print-before <pass[#N],...> Print snapshots before passes\n"
+ " -print-after <pass[#N],...> Print snapshots after passes\n"
+ " -simplify-mir Omit default-valued MIR fields\n"
+ " -verify-machineinstrs Verify each machine pass result\n"
" --stage-snapshots Print every stage boundary\n"
" --emit <stage|assembly|object> Select the output artifact\n"
- " -o, --output <file|-> Select the output path\n"
+ " -o <file|-> Select the output path\n"
"reproduction/cache/fuzz:\n"
" --crash-reproducer <path> Save input and manifest before execution\n"
" --cache-dir <path> Select the content-addressed cache root\n"
@@ -102,10 +104,11 @@ void printUsage(std::ostream &Output) {
" --enable-action <name> Enable an Action ID component\n"
" --print-actions Print stable Action decisions\n"
" -O0|-O1|-O2|-O3|-Os|-Oz Optimization level identity\n"
- " --relocation-model <static|pic>\n"
- " --code-model <small|medium|large>\n"
+ " -relocation-model <static|pic>\n"
+ " -code-model <small|medium|large>\n"
" --layout <native-object|compiler-final-layout|external-relaxation>\n"
- " --cpu/--tune-cpu/--features/--abi/--data-layout <value>\n"
+ " -mtriple/-mcpu/-mtune/-mattr/-target-abi <value>\n"
+ " --data-layout <value> Override the MIR data layout\n"
" --target-option <name=value> Explicit target option\n"
" --assembler-option <name=value>\n"
" --assembler-flavor/--assembler-version <value>\n";
@@ -160,6 +163,24 @@ template <typename IntegerT>
return Result;
}
+void applyFeatureOverrides(std::vector<std::string> Overrides, std::vector<std::string> &Features) {
+ for (std::string &Override : Overrides) {
+ if (!Override.empty() && Override.front() != '+' && Override.front() != '-')
+ Override.insert(Override.begin(), '+');
+ const std::string_view Name = std::string_view(Override).substr(1);
+ std::erase_if(Features, [Name](const std::string &Feature) {
+ return Feature.size() > 1 && std::string_view(Feature).substr(1) == Name;
+ });
+ Features.push_back(std::move(Override));
+ }
+}
+
+[[nodiscard]] std::string normalizeRV64Triple(std::string_view Triple) {
+ if (Triple == "riscv64" || Triple == "riscv64-linux-gnu")
+ return "riscv64-unknown-linux-gnu";
+ return std::string(Triple);
+}
+
[[nodiscard]] Expected<rcc::tooling::BackendOption> parseBackendOption(std::string_view Text,
std::string_view Category) {
const std::size_t Equal = Text.find('=');
@@ -238,6 +259,14 @@ template <typename IntegerT>
Command.Controls.CaptureStageSnapshots = true;
continue;
}
+ if (Argument == "-simplify-mir") {
+ Command.Controls.SimplifyMIR = true;
+ continue;
+ }
+ if (Argument == "-verify-machineinstrs") {
+ Command.Controls.VerifyEach = true;
+ continue;
+ }
if (Argument == "--no-verify-each") {
Command.Controls.VerifyEach = false;
continue;
@@ -268,11 +297,7 @@ template <typename IntegerT>
Command.InputPath = std::string(**Input);
continue;
}
- auto Output = takeOption(Argument, "--output", Index, ArgumentCount, Arguments);
- if (!Output)
- return std::unexpected(Output.error());
- if (!*Output && Argument == "-o")
- Output = takeOption(Argument, "-o", Index, ArgumentCount, Arguments);
+ auto Output = takeOption(Argument, "-o", Index, ArgumentCount, Arguments);
if (!Output)
return std::unexpected(Output.error());
if (*Output) {
@@ -291,24 +316,24 @@ template <typename IntegerT>
Command.OutputWasSpecified = true;
continue;
}
- auto RunPass = takeOption(Argument, "--run-pass", Index, ArgumentCount, Arguments);
+ auto RunPass = takeOption(Argument, "-run-pass", Index, ArgumentCount, Arguments);
if (!RunPass)
return std::unexpected(RunPass.error());
if (*RunPass) {
if (ExplicitPipeline)
return rcc::makeUnexpected(ErrorCode::InvalidInvocation,
- "--run-pass and --passes cannot be combined");
+ "-run-pass and -passes cannot be combined");
Command.Invocation.PassPipeline = {std::string(**RunPass)};
ExplicitPipeline = true;
continue;
}
- auto Passes = takeOption(Argument, "--passes", Index, ArgumentCount, Arguments);
+ auto Passes = takeOption(Argument, "-passes", Index, ArgumentCount, Arguments);
if (!Passes)
return std::unexpected(Passes.error());
if (*Passes) {
if (ExplicitPipeline)
return rcc::makeUnexpected(ErrorCode::InvalidInvocation,
- "--run-pass and --passes cannot be combined");
+ "-run-pass and -passes cannot be combined");
auto Names = splitList(**Passes, "pass pipeline");
if (!Names)
return std::unexpected(Names.error());
@@ -327,12 +352,12 @@ template <typename IntegerT>
Destination = std::string(**Value);
return true;
};
- auto StopBefore = ParseSelector("--stop-before", Command.Controls.StopBefore);
+ auto StopBefore = ParseSelector("-stop-before", Command.Controls.StopBefore);
if (!StopBefore)
return std::unexpected(StopBefore.error());
if (*StopBefore)
continue;
- auto StopAfter = ParseSelector("--stop-after", Command.Controls.StopAfter);
+ auto StopAfter = ParseSelector("-stop-after", Command.Controls.StopAfter);
if (!StopAfter)
return std::unexpected(StopAfter.error());
if (*StopAfter)
@@ -352,12 +377,12 @@ template <typename IntegerT>
std::make_move_iterator(Selectors->end()));
return true;
};
- auto PrintBefore = ParseSelectorList("--print-before", Command.Controls.PrintBefore);
+ auto PrintBefore = ParseSelectorList("-print-before", Command.Controls.PrintBefore);
if (!PrintBefore)
return std::unexpected(PrintBefore.error());
if (*PrintBefore)
continue;
- auto PrintAfter = ParseSelectorList("--print-after", Command.Controls.PrintAfter);
+ auto PrintAfter = ParseSelectorList("-print-after", Command.Controls.PrintAfter);
if (!PrintAfter)
return std::unexpected(PrintAfter.error());
if (*PrintAfter)
@@ -490,17 +515,24 @@ template <typename IntegerT>
Destination = std::string(**Value);
return true;
};
- auto CPU = ParseString("--cpu", Command.Invocation.CPU);
+ auto Triple = takeOption(Argument, "-mtriple", Index, ArgumentCount, Arguments);
+ if (!Triple)
+ return std::unexpected(Triple.error());
+ if (*Triple) {
+ Command.Invocation.Triple = normalizeRV64Triple(**Triple);
+ continue;
+ }
+ auto CPU = ParseString("-mcpu", Command.Invocation.CPU);
if (!CPU)
return std::unexpected(CPU.error());
if (*CPU)
continue;
- auto TuneCPU = ParseString("--tune-cpu", Command.Invocation.TuneCPU);
+ auto TuneCPU = ParseString("-mtune", Command.Invocation.TuneCPU);
if (!TuneCPU)
return std::unexpected(TuneCPU.error());
if (*TuneCPU)
continue;
- auto ABI = ParseString("--abi", Command.Invocation.ABI);
+ auto ABI = ParseString("-target-abi", Command.Invocation.ABI);
if (!ABI)
return std::unexpected(ABI.error());
if (*ABI)
@@ -520,17 +552,17 @@ template <typename IntegerT>
return std::unexpected(AssemblerVersion.error());
if (*AssemblerVersion)
continue;
- auto Features = takeOption(Argument, "--features", Index, ArgumentCount, Arguments);
+ auto Features = takeOption(Argument, "-mattr", Index, ArgumentCount, Arguments);
if (!Features)
return std::unexpected(Features.error());
if (*Features) {
auto Values = splitList(**Features, "target feature list");
if (!Values)
return std::unexpected(Values.error());
- Command.Invocation.Features = std::move(*Values);
+ applyFeatureOverrides(std::move(*Values), Command.Invocation.Features);
continue;
}
- auto Relocation = takeOption(Argument, "--relocation-model", Index, ArgumentCount, Arguments);
+ auto Relocation = takeOption(Argument, "-relocation-model", Index, ArgumentCount, Arguments);
if (!Relocation)
return std::unexpected(Relocation.error());
if (*Relocation) {
@@ -540,7 +572,7 @@ template <typename IntegerT>
Command.Invocation.Relocation = *Value;
continue;
}
- auto Code = takeOption(Argument, "--code-model", Index, ArgumentCount, Arguments);
+ auto Code = takeOption(Argument, "-code-model", Index, ArgumentCount, Arguments);
if (!Code)
return std::unexpected(Code.error());
if (*Code) {
diff --git a/backend/tools/MIRTool/MIRToolOperationsTest.cmake b/backend/tools/MIRTool/MIRToolOperationsTest.cmake
index 003e868..8dee32f 100644
--- a/backend/tools/MIRTool/MIRToolOperationsTest.cmake
+++ b/backend/tools/MIRTool/MIRToolOperationsTest.cmake
@@ -9,7 +9,7 @@ file(MAKE_DIRECTORY "${WORK_DIRECTORY}")
set(StandardInputMIR "${WORK_DIRECTORY}/stdin.mir")
execute_process(
- COMMAND "${TOOL}" --verify - --output "${StandardInputMIR}"
+ COMMAND "${TOOL}" --verify - -o "${StandardInputMIR}"
INPUT_FILE "${INPUT}"
RESULT_VARIABLE StandardInputResult
ERROR_VARIABLE StandardInputDiagnostics
@@ -28,7 +28,7 @@ set(ReloadedAssembly "${WORK_DIRECTORY}/reloaded.s")
execute_process(
COMMAND
"${TOOL}" --input "${INPUT}" --emit assembly --cache-dir "${CacheDirectory}"
- --cache-policy write --output "${CachedAssembly}"
+ --cache-policy write -o "${CachedAssembly}"
RESULT_VARIABLE CacheWriteResult
ERROR_VARIABLE CacheWriteDiagnostics
)
@@ -38,7 +38,7 @@ endif()
execute_process(
COMMAND
"${TOOL}" --input "${INPUT}" --emit assembly --cache-dir "${CacheDirectory}"
- --cache-policy read --output "${ReloadedAssembly}"
+ --cache-policy read -o "${ReloadedAssembly}"
RESULT_VARIABLE CacheReadResult
ERROR_VARIABLE CacheReadDiagnostics
)
@@ -56,7 +56,7 @@ endif()
execute_process(
COMMAND
"${TOOL}" --input "${INPUT}" --emit assembly --cache-dir
- "${WORK_DIRECTORY}/empty-cache" --cache-policy read --output "${WORK_DIRECTORY}/miss.s"
+ "${WORK_DIRECTORY}/empty-cache" --cache-policy read -o "${WORK_DIRECTORY}/miss.s"
RESULT_VARIABLE CacheMissResult
ERROR_VARIABLE CacheMissDiagnostics
)
@@ -74,7 +74,7 @@ file(WRITE "${CachedArtifact}" "corrupt")
execute_process(
COMMAND
"${TOOL}" --input "${INPUT}" --emit assembly --cache-dir "${CacheDirectory}"
- --cache-policy read --output "${WORK_DIRECTORY}/corrupt.s"
+ --cache-policy read -o "${WORK_DIRECTORY}/corrupt.s"
RESULT_VARIABLE CorruptCacheResult
ERROR_VARIABLE CorruptCacheDiagnostics
)
@@ -88,7 +88,7 @@ set(ReplayedAssembly "${WORK_DIRECTORY}/success-replayed.s")
execute_process(
COMMAND
"${TOOL}" --input "${INPUT}" --emit assembly --crash-reproducer "${SuccessReproducer}"
- --output "${SuccessAssembly}"
+ -o "${SuccessAssembly}"
RESULT_VARIABLE ReproducerWriteResult
ERROR_VARIABLE ReproducerWriteDiagnostics
)
@@ -96,7 +96,7 @@ if(NOT ReproducerWriteResult EQUAL 0)
message(FATAL_ERROR "successful reproducer publication failed: ${ReproducerWriteDiagnostics}")
endif()
execute_process(
- COMMAND "${TOOL}" --reproduce "${SuccessReproducer}" --output "${ReplayedAssembly}"
+ COMMAND "${TOOL}" --reproduce "${SuccessReproducer}" -o "${ReplayedAssembly}"
RESULT_VARIABLE ReproducerReplayResult
ERROR_VARIABLE ReproducerReplayDiagnostics
)
@@ -113,7 +113,7 @@ endif()
set(RegBankInput "${WORK_DIRECTORY}/regbank.mir")
execute_process(
- COMMAND "${TOOL}" --input "${INPUT}" --emit regbank-mir --output "${RegBankInput}"
+ COMMAND "${TOOL}" --input "${INPUT}" --emit regbank-mir -o "${RegBankInput}"
RESULT_VARIABLE RegBankResult
ERROR_VARIABLE RegBankDiagnostics
)
@@ -124,8 +124,8 @@ endif()
set(FailureReproducer "${WORK_DIRECTORY}/failure-reproducer")
execute_process(
COMMAND
- "${TOOL}" --input "${RegBankInput}" --run-pass InstructionSelect --emit selected-mir
- --fuel 0 --crash-reproducer "${FailureReproducer}" --output "${WORK_DIRECTORY}/failure.mir"
+ "${TOOL}" --input "${RegBankInput}" -run-pass instruction-select --emit selected-mir
+ --fuel 0 --crash-reproducer "${FailureReproducer}" -o "${WORK_DIRECTORY}/failure.mir"
RESULT_VARIABLE FailureResult
ERROR_VARIABLE FailureDiagnostics
)
@@ -134,12 +134,12 @@ if(FailureResult EQUAL 0 OR
message(FATAL_ERROR "zero Action fuel did not produce the expected failure")
endif()
file(READ "${FailureReproducer}/manifest.yaml" FailureManifest)
-if(NOT FailureManifest MATCHES "InstructionSelect" OR
+if(NOT FailureManifest MATCHES "instruction-select" OR
NOT FailureManifest MATCHES "required selection action was rejected")
message(FATAL_ERROR "failure reproducer did not record structured pass diagnostics")
endif()
execute_process(
- COMMAND "${TOOL}" --reproduce "${FailureReproducer}" --output "${WORK_DIRECTORY}/replay.mir"
+ COMMAND "${TOOL}" --reproduce "${FailureReproducer}" -o "${WORK_DIRECTORY}/replay.mir"
RESULT_VARIABLE FailureReplayResult
ERROR_VARIABLE FailureReplayDiagnostics
)
@@ -151,12 +151,12 @@ endif()
set(ActionOutput "${WORK_DIRECTORY}/selected.mir")
execute_process(
COMMAND
- "${TOOL}" --input "${RegBankInput}" --run-pass InstructionSelect --emit selected-mir
- --print-actions --output "${ActionOutput}"
+ "${TOOL}" --input "${RegBankInput}" -run-pass instruction-select --emit selected-mir
+ --print-actions -o "${ActionOutput}"
RESULT_VARIABLE ActionResult
ERROR_VARIABLE ActionDiagnostics
)
-if(NOT ActionResult EQUAL 0 OR NOT ActionDiagnostics MATCHES "accepted InstructionSelect")
+if(NOT ActionResult EQUAL 0 OR NOT ActionDiagnostics MATCHES "accepted instruction-select")
message(FATAL_ERROR "successful Action execution did not report stable decisions")
endif()
@@ -172,7 +172,7 @@ set(CanonicalReducerSeed "${WORK_DIRECTORY}/reducer-seed.canonical.mir")
set(ReducedMIR "${WORK_DIRECTORY}/reduced.mir")
file(WRITE "${ReducerSeed}" "${ReducerSeedText}")
execute_process(
- COMMAND "${TOOL}" --verify --input "${ReducerSeed}" --output "${CanonicalReducerSeed}"
+ COMMAND "${TOOL}" --verify --input "${ReducerSeed}" -o "${CanonicalReducerSeed}"
RESULT_VARIABLE ReducerSeedResult
ERROR_VARIABLE ReducerSeedDiagnostics
)
@@ -180,7 +180,7 @@ if(NOT ReducerSeedResult EQUAL 0)
message(FATAL_ERROR "reducer seed failed canonicalization: ${ReducerSeedDiagnostics}")
endif()
execute_process(
- COMMAND "${TOOL}" --reduce validity --input "${ReducerSeed}" --output "${ReducedMIR}"
+ COMMAND "${TOOL}" --reduce validity --input "${ReducerSeed}" -o "${ReducedMIR}"
RESULT_VARIABLE ValidityReducerResult
ERROR_VARIABLE ValidityReducerDiagnostics
)
@@ -204,8 +204,8 @@ endif()
set(FailureReducedMIR "${WORK_DIRECTORY}/failure-reduced.mir")
execute_process(
COMMAND
- "${TOOL}" --reduce failure --input "${RegBankInput}" --run-pass InstructionSelect
- --emit selected-mir --fuel 0 --output "${FailureReducedMIR}"
+ "${TOOL}" --reduce failure --input "${RegBankInput}" -run-pass instruction-select
+ --emit selected-mir --fuel 0 -o "${FailureReducedMIR}"
RESULT_VARIABLE FailureReducerResult
ERROR_VARIABLE FailureReducerDiagnostics
)
@@ -214,8 +214,8 @@ if(NOT FailureReducerResult EQUAL 0)
endif()
execute_process(
COMMAND
- "${TOOL}" --input "${FailureReducedMIR}" --run-pass InstructionSelect --emit selected-mir
- --fuel 0 --output "${WORK_DIRECTORY}/failure-reduced-output.mir"
+ "${TOOL}" --input "${FailureReducedMIR}" -run-pass instruction-select --emit selected-mir
+ --fuel 0 -o "${WORK_DIRECTORY}/failure-reduced-output.mir"
RESULT_VARIABLE ReducedFailureResult
ERROR_VARIABLE ReducedFailureDiagnostics
)
@@ -228,7 +228,7 @@ set(FirstFuzz "${WORK_DIRECTORY}/fuzz-1.txt")
set(SecondFuzz "${WORK_DIRECTORY}/fuzz-2.txt")
execute_process(
COMMAND
- "${TOOL}" --fuzz all --fuzz-iterations 2 --seed 123 --input "${INPUT}" --output
+ "${TOOL}" --fuzz all --fuzz-iterations 2 --seed 123 --input "${INPUT}" -o
"${FirstFuzz}"
RESULT_VARIABLE FirstFuzzResult
ERROR_VARIABLE FirstFuzzDiagnostics
@@ -238,7 +238,7 @@ if(NOT FirstFuzzResult EQUAL 0)
endif()
execute_process(
COMMAND
- "${TOOL}" --fuzz all --fuzz-iterations 2 --seed 123 --input "${INPUT}" --output
+ "${TOOL}" --fuzz all --fuzz-iterations 2 --seed 123 --input "${INPUT}" -o
"${SecondFuzz}"
RESULT_VARIABLE SecondFuzzResult
ERROR_VARIABLE SecondFuzzDiagnostics
diff --git a/backend/tools/MIRTool/MIRToolOutputTest.cmake b/backend/tools/MIRTool/MIRToolOutputTest.cmake
index f8e4499..13159b8 100644
--- a/backend/tools/MIRTool/MIRToolOutputTest.cmake
+++ b/backend/tools/MIRTool/MIRToolOutputTest.cmake
@@ -10,7 +10,7 @@ file(MAKE_DIRECTORY "${OutputDirectory}")
set(RepeatedOutput "${OUTPUT}.repeat")
execute_process(
- COMMAND "${TOOL}" --input "${INPUT}" --emit "${OUTPUT_KIND}" --output "${OUTPUT}"
+ COMMAND "${TOOL}" --input "${INPUT}" --emit "${OUTPUT_KIND}" -o "${OUTPUT}"
RESULT_VARIABLE FirstResult
ERROR_VARIABLE FirstDiagnostics
)
@@ -18,7 +18,7 @@ if(NOT FirstResult EQUAL 0)
message(FATAL_ERROR "${OUTPUT_KIND} production failed: ${FirstDiagnostics}")
endif()
execute_process(
- COMMAND "${TOOL}" --input "${INPUT}" --emit "${OUTPUT_KIND}" --output "${RepeatedOutput}"
+ COMMAND "${TOOL}" --input "${INPUT}" --emit "${OUTPUT_KIND}" -o "${RepeatedOutput}"
RESULT_VARIABLE SecondResult
ERROR_VARIABLE SecondDiagnostics
)
diff --git a/backend/tools/MIRTool/MIRToolStageTest.cmake b/backend/tools/MIRTool/MIRToolStageTest.cmake
index 8247363..25c55c3 100644
--- a/backend/tools/MIRTool/MIRToolStageTest.cmake
+++ b/backend/tools/MIRTool/MIRToolStageTest.cmake
@@ -22,7 +22,7 @@ foreach(Stage IN LISTS Stages)
set(RepeatedOutput "${WORK_DIRECTORY}/${Stage}.repeat.mir")
set(CanonicalOutput "${WORK_DIRECTORY}/${Stage}.canonical.mir")
execute_process(
- COMMAND "${TOOL}" --input "${INPUT}" --emit "${Stage}" --output "${StageOutput}"
+ COMMAND "${TOOL}" --input "${INPUT}" --emit "${Stage}" -o "${StageOutput}"
RESULT_VARIABLE StageResult
ERROR_VARIABLE StageDiagnostics
)
@@ -30,7 +30,7 @@ foreach(Stage IN LISTS Stages)
message(FATAL_ERROR "${Stage} production failed: ${StageDiagnostics}")
endif()
execute_process(
- COMMAND "${TOOL}" --input "${INPUT}" --emit "${Stage}" --output "${RepeatedOutput}"
+ COMMAND "${TOOL}" --input "${INPUT}" --emit "${Stage}" -o "${RepeatedOutput}"
RESULT_VARIABLE RepeatedResult
ERROR_VARIABLE RepeatedDiagnostics
)
@@ -45,7 +45,7 @@ foreach(Stage IN LISTS Stages)
message(FATAL_ERROR "${Stage} output is not deterministic")
endif()
execute_process(
- COMMAND "${TOOL}" --verify --input "${StageOutput}" --output "${CanonicalOutput}"
+ COMMAND "${TOOL}" --verify --input "${StageOutput}" -o "${CanonicalOutput}"
RESULT_VARIABLE VerifyResult
ERROR_VARIABLE VerifyDiagnostics
)
@@ -64,7 +64,7 @@ endforeach()
set(NoPassOutput "${WORK_DIRECTORY}/none.mir")
execute_process(
COMMAND
- "${TOOL}" --input "${INPUT}" --run-pass=none --emit final-mir --output "${NoPassOutput}"
+ "${TOOL}" --input "${INPUT}" -run-pass=none --emit final-mir -o "${NoPassOutput}"
RESULT_VARIABLE NoPassResult
ERROR_VARIABLE NoPassDiagnostics
)
@@ -80,9 +80,49 @@ if(NOT NoPassComparisonResult EQUAL 0)
message(FATAL_ERROR "LLVM-compatible none pass changed canonical MIR")
endif()
+set(LLVMContractOutput "${WORK_DIRECTORY}/llvm-contract.mir")
+execute_process(
+ COMMAND
+ "${TOOL}" "${INPUT}" -run-pass=none -mtriple=riscv64
+ -mattr=+m,+a,+f,+d,+c -relocation-model=pic -code-model=small -simplify-mir
+ -verify-machineinstrs -o "${LLVMContractOutput}"
+ RESULT_VARIABLE LLVMContractResult
+ ERROR_VARIABLE LLVMContractDiagnostics
+)
+if(NOT LLVMContractResult EQUAL 0)
+ message(FATAL_ERROR "LLVM llc-compatible invocation failed: ${LLVMContractDiagnostics}")
+endif()
+file(SIZE "${LLVMContractOutput}" LLVMContractOutputSize)
+if(LLVMContractOutputSize EQUAL 0)
+ message(FATAL_ERROR "LLVM llc-compatible invocation produced no MIR")
+endif()
+
+foreach(
+ RemovedOption
+ IN ITEMS
+ --run-pass=none
+ --passes=none
+ --stop-after=legalizer
+ --print-before=legalizer
+ --features=+m
+ --relocation-model=pic
+ --code-model=small
+ --output=-
+)
+ execute_process(
+ COMMAND "${TOOL}" "${INPUT}" "${RemovedOption}"
+ RESULT_VARIABLE RemovedOptionResult
+ ERROR_VARIABLE RemovedOptionDiagnostics
+ )
+ if(RemovedOptionResult EQUAL 0 OR
+ NOT RemovedOptionDiagnostics MATCHES "unknown command-line option")
+ message(FATAL_ERROR "removed option ${RemovedOption} remains accepted")
+ endif()
+endforeach()
+
set(PassList "${WORK_DIRECTORY}/passes.txt")
execute_process(
- COMMAND "${TOOL}" --list-passes --input "${INPUT}" --output "${PassList}"
+ COMMAND "${TOOL}" --list-passes --input "${INPUT}" -o "${PassList}"
RESULT_VARIABLE ListResult
ERROR_VARIABLE ListDiagnostics
)
@@ -90,7 +130,7 @@ if(NOT ListResult EQUAL 0)
message(FATAL_ERROR "pass listing failed: ${ListDiagnostics}")
endif()
file(READ "${PassList}" PassListText)
-foreach(RequiredPass IN ITEMS Legalizer RegisterBankSelect InstructionSelect PrologueEpilogueInsertion)
+foreach(RequiredPass IN ITEMS legalizer regbankselect instruction-select PrologueEpilogueInsertion)
if(NOT PassListText MATCHES "(^|\n)${RequiredPass}(\n|$)")
message(FATAL_ERROR "canonical pass list is missing ${RequiredPass}")
endif()
@@ -99,7 +139,7 @@ endforeach()
set(LegalizedOutput "${WORK_DIRECTORY}/run-pass.mir")
execute_process(
COMMAND
- "${TOOL}" --input "${INPUT}" --run-pass Legalizer --emit legalized-mir --output
+ "${TOOL}" --input "${INPUT}" -run-pass legalizer --emit legalized-mir -o
"${LegalizedOutput}"
RESULT_VARIABLE RunPassResult
ERROR_VARIABLE RunPassDiagnostics
@@ -111,8 +151,8 @@ endif()
set(RegBankOutput "${WORK_DIRECTORY}/passes.mir")
execute_process(
COMMAND
- "${TOOL}" --input "${INPUT}" --passes Legalizer,RegisterBankSelect --emit regbank-mir
- --output "${RegBankOutput}"
+ "${TOOL}" --input "${INPUT}" -passes legalizer,regbankselect --emit regbank-mir -o
+ "${RegBankOutput}"
RESULT_VARIABLE PassesResult
ERROR_VARIABLE PassesDiagnostics
)
@@ -123,7 +163,7 @@ endif()
set(StoppedOutput "${WORK_DIRECTORY}/stopped.mir")
execute_process(
COMMAND
- "${TOOL}" --input "${INPUT}" --stop-after Legalizer --emit final-mir --output
+ "${TOOL}" --input "${INPUT}" -stop-after legalizer --emit final-mir -o
"${StoppedOutput}"
RESULT_VARIABLE StopResult
ERROR_VARIABLE StopDiagnostics
@@ -142,22 +182,22 @@ endif()
execute_process(
COMMAND
- "${TOOL}" --input "${INPUT}" --emit legalized-mir --print-before Legalizer --print-after
- Legalizer --output "${WORK_DIRECTORY}/printed.mir"
+ "${TOOL}" --input "${INPUT}" --emit legalized-mir -print-before legalizer -print-after
+ legalizer -o "${WORK_DIRECTORY}/printed.mir"
RESULT_VARIABLE PrintResult
ERROR_VARIABLE PrintDiagnostics
)
if(NOT PrintResult EQUAL 0)
message(FATAL_ERROR "pass snapshot controls failed: ${PrintDiagnostics}")
endif()
-if(NOT PrintDiagnostics MATCHES "[*][*][*] prelegalizer-mir Legalizer#1" OR
- NOT PrintDiagnostics MATCHES "[*][*][*] legalized-mir Legalizer#1")
+if(NOT PrintDiagnostics MATCHES "[*][*][*] prelegalizer-mir legalizer#1" OR
+ NOT PrintDiagnostics MATCHES "[*][*][*] legalized-mir legalizer#1")
message(FATAL_ERROR "before/after pass snapshots are incomplete")
endif()
execute_process(
COMMAND
- "${TOOL}" --input "${INPUT}" --emit final-mir --stage-snapshots --output
+ "${TOOL}" --input "${INPUT}" --emit final-mir --stage-snapshots -o
"${WORK_DIRECTORY}/snapshot-final.mir"
RESULT_VARIABLE SnapshotResult
ERROR_VARIABLE SnapshotDiagnostics