aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-19 03:19:40 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-19 03:19:40 +0800
commit69e1baa931dfa63838683378fa20ed9c46c68a70 (patch)
treed8ae9222ed52c3036b30371241bd593e0324ce6c /backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
parentc0f2700e0c7effc5da267bf501232ff4bfea63bc (diff)
downloadrcc-project-69e1baa931dfa63838683378fa20ed9c46c68a70.tar.gz
rcc-project-69e1baa931dfa63838683378fa20ed9c46c68a70.tar.xz
[RISCV][GlobalISel] Match floating comparisons
Diffstat (limited to 'backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp')
-rw-r--r--backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index 8cfb9c7..995a9a0 100644
--- a/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -273,6 +273,19 @@ Expected<MachinePassResult> InstructionSelect::runImplementation(MachineFunction
Worklist.push_back(Instruction);
DiscoveredInstructions.insert(Instruction->stableID());
}
+ const auto DiscoverNewInstructions = [&]() -> Expected<void> {
+ for (MachineInstr *Candidate : bottomUpInstructions(Function)) {
+ const InstructionDescriptor *CandidateDescriptor =
+ Target.instructionDescriptor(Candidate->opcode());
+ if (CandidateDescriptor == nullptr) {
+ return std::unexpected(
+ passFailure("instruction selector produced an unknown instruction descriptor"));
+ }
+ if (DiscoveredInstructions.insert(Candidate->stableID()).second)
+ Worklist.push_back(Candidate);
+ }
+ return {};
+ };
for (std::size_t Index = 0; Index < Worklist.size(); ++Index) {
MachineInstr *Instruction = Worklist[Index];
@@ -320,6 +333,14 @@ Expected<MachinePassResult> InstructionSelect::runImplementation(MachineFunction
auto Selection = Info->select(*Instruction, Function, Target);
if (!Selection)
return std::unexpected(Selection.error());
+ if (Instruction->parent() == nullptr) {
+ Result.Changed = true;
+ Result.Changes.add(MachinePassChange::Instructions);
+ auto Discovered = DiscoverNewInstructions();
+ if (!Discovered)
+ return std::unexpected(Discovered.error());
+ continue;
+ }
const InstructionDescriptor *Selected = Target.instructionDescriptor(Instruction->opcode());
if (Selected == nullptr)
return std::unexpected(
@@ -348,16 +369,9 @@ Expected<MachinePassResult> InstructionSelect::runImplementation(MachineFunction
Result.Changes.add(MachinePassChange::Instructions);
if (Selected->Flags.has(InstructionFlag::Generic))
Worklist.push_back(Instruction);
- for (MachineInstr *Candidate : bottomUpInstructions(Function)) {
- const InstructionDescriptor *CandidateDescriptor =
- Target.instructionDescriptor(Candidate->opcode());
- if (CandidateDescriptor == nullptr)
- return std::unexpected(
- passFailure("instruction selector produced an unknown instruction descriptor"));
- if (!DiscoveredInstructions.insert(Candidate->stableID()).second)
- continue;
- Worklist.push_back(Candidate);
- }
+ auto Discovered = DiscoverNewInstructions();
+ if (!Discovered)
+ return std::unexpected(Discovered.error());
}
for (MachineInstr *Instruction : layoutInstructions(Function)) {
const InstructionDescriptor *Descriptor = Target.instructionDescriptor(Instruction->opcode());