aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-17 02:46:40 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-17 02:46:40 +0800
commit103299abab6922f450671baa76e34ad746ac4312 (patch)
tree19c684e8fc7dd8f48f7b938f7d9040afa0697f4c /backend/lib/CodeGen
parent125bee29ffbc64a5f8dc488d04cecf10ed26f98e (diff)
downloadrcc-project-103299abab6922f450671baa76e34ad746ac4312.tar.gz
rcc-project-103299abab6922f450671baa76e34ad746ac4312.tar.xz
[RISCV][GlobalISel] Constrain core copies during selection
Diffstat (limited to 'backend/lib/CodeGen')
-rw-r--r--backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index 1048843..8cfb9c7 100644
--- a/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -291,7 +291,9 @@ Expected<MachinePassResult> InstructionSelect::runImplementation(MachineFunction
if (CurrentDescriptor == nullptr)
return std::unexpected(
passFailure("instruction selector encountered an unknown instruction descriptor"));
- if (!CurrentDescriptor->Flags.has(InstructionFlag::Generic))
+ const bool IsGeneric = CurrentDescriptor->Flags.has(InstructionFlag::Generic);
+ const bool IsCopy = Instruction->opcode() == opcode(GenericOpcode::COPY);
+ if (!IsGeneric && !IsCopy)
continue;
const OpcodeState Before = stateOf(*Instruction);
if (!SeenStates.insert(Before).second) {
@@ -322,21 +324,23 @@ Expected<MachinePassResult> InstructionSelect::runImplementation(MachineFunction
if (Selected == nullptr)
return std::unexpected(
passFailure("instruction selector produced an unknown instruction descriptor"));
- auto FlagPropagation =
- Info->propagateSelectionFlags(*Instruction, InputFlags, InputMayRaiseFPException, Target);
- if (!FlagPropagation)
- return std::unexpected(FlagPropagation.error());
- auto Constraint = Info->constrainSelectedInstruction(*Instruction, Function, Target);
- if (!Constraint) {
- return std::unexpected(withErrorContext(
- Constraint.error(), "instruction selector could not constrain selected registers: "));
+ if (IsGeneric) {
+ auto FlagPropagation =
+ Info->propagateSelectionFlags(*Instruction, InputFlags, InputMayRaiseFPException, Target);
+ if (!FlagPropagation)
+ return std::unexpected(FlagPropagation.error());
+ auto Constraint = Info->constrainSelectedInstruction(*Instruction, Function, Target);
+ if (!Constraint) {
+ return std::unexpected(withErrorContext(
+ Constraint.error(), "instruction selector could not constrain selected registers: "));
+ }
}
auto Validation = Target.validateInstruction(*Instruction, Function.registerInfo());
if (!Validation)
return std::unexpected(withErrorContext(Validation.error(),
"instruction selector produced invalid MachineIR: "));
const OpcodeState After = stateOf(*Instruction);
- if (After == Before)
+ if (IsGeneric && After == Before)
return std::unexpected(
passFailure("instruction selector reported success without observable progress",
ErrorCode::InternalError));