[llvm] [GlobalISel][ARM] Legalze set_fpmode and get_fpmode (PR #96467)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 05:00:13 PDT 2024


================
@@ -439,6 +443,23 @@ bool ARMLegalizerInfo::legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI,
                              *ConstantInt::get(Ctx, AsInteger));
     break;
   }
+  case G_SET_FPMODE: {
+    // New FPSCR = (FPSCR & FPStatusBits) | (Modes & ~FPStatusBits)
+    LLT FPEnvTy = LLT::scalar(32);
+    auto FPEnv = MRI.createGenericVirtualRegister(FPEnvTy);
+    auto Modes = MI.getOperand(0).getReg();
+    MIRBuilder.buildInstr(G_GET_FPENV).addDef({FPEnv});
+    auto StatusBitMask = MIRBuilder.buildConstant(FPEnvTy, ARM::FPStatusBits);
+    auto StatusBits =
+        MIRBuilder.buildAnd(FPEnvTy, FPEnv, StatusBitMask).getReg(0);
+    auto NotStatusBitMask =
+        MIRBuilder.buildConstant(FPEnvTy, ~ARM::FPStatusBits);
+    auto FPModeBits =
+        MIRBuilder.buildAnd(FPEnvTy, Modes, NotStatusBitMask).getReg(0);
----------------
arsenm wrote:

Drop the .getReg(0) 

https://github.com/llvm/llvm-project/pull/96467


More information about the llvm-commits mailing list