[llvm] [RISCV][GISel] Add support for G_IS_FPCLASS in F and D extensions (PR #72000)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 11:00:26 PST 2023
================
@@ -948,6 +952,30 @@ bool RISCVInstructionSelector::selectFPCompare(MachineInstr &MI,
return true;
}
+bool RISCVInstructionSelector::selectIsFPClass(MachineInstr &MI,
+ MachineIRBuilder &MIB,
+ MachineRegisterInfo &MRI) const {
+ Register CheckResult = MI.getOperand(0).getReg();
+ Register Src = MI.getOperand(1).getReg();
+ int64_t MaskImm = MI.getOperand(2).getImm();
+ unsigned NewOpc = MRI.getType(Src).getSizeInBits() == 32 ? RISCV::FCLASS_S
+ : RISCV::FCLASS_D;
+
+ Register FClassResult = MRI.createVirtualRegister(&RISCV::GPRRegClass);
+ // Insert FCLASS_S/D.
+ auto FClass = MIB.buildInstr(NewOpc, {FClassResult}, {Src});
+ if (!FClass.constrainAllUses(TII, TRI, RBI))
+ return false;
+ // Insert AND to check Src aginst the mask.
+ auto And = MIB.buildInstr(RISCV::ANDI, {CheckResult}, {FClassResult})
+ .addImm(MaskImm);
+ if (!And.constrainAllUses(TII, TRI, RBI))
+ return false;
+
----------------
topperc wrote:
I don't expect you to use `getBooleanContents`. It will always be ZeroOrOneBooleanContent for RISC-V. I'm fine with assuming that. If you were writing target independent code you would need to use it.
https://github.com/llvm/llvm-project/pull/72000
More information about the llvm-commits
mailing list