aboutsummaryrefslogtreecommitdiff
path: root/backend/tools/MIRTool/MIRToolStageTest.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'backend/tools/MIRTool/MIRToolStageTest.cmake')
-rw-r--r--backend/tools/MIRTool/MIRToolStageTest.cmake70
1 files changed, 55 insertions, 15 deletions
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