[llvm] 68d6918 - [MC] Add createFPImm/isFPImm/setFPImm to smooth migration from FPImm to DFPImm after D96091

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 4 20:42:41 PST 2021


Author: Fangrui Song
Date: 2021-02-04T20:42:35-08:00
New Revision: 68d6918e7a13ac5efdc9f7f84499a4abeedf6daa

URL: https://github.com/llvm/llvm-project/commit/68d6918e7a13ac5efdc9f7f84499a4abeedf6daa
DIFF: https://github.com/llvm/llvm-project/commit/68d6918e7a13ac5efdc9f7f84499a4abeedf6daa.diff

LOG: [MC] Add createFPImm/isFPImm/setFPImm to smooth migration from FPImm to DFPImm after D96091

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCInst.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCInst.h b/llvm/include/llvm/MC/MCInst.h
index 60d8334db9f5..b8f4db8b20c3 100644
--- a/llvm/include/llvm/MC/MCInst.h
+++ b/llvm/include/llvm/MC/MCInst.h
@@ -100,11 +100,19 @@ class MCOperand {
     assert(isDFPImm() && "This is not an FP immediate");
     return FPImmVal;
   }
+  double getFPImm() const {
+    assert(isDFPImm() && "This is not an FP immediate");
+    return bit_cast<double>(FPImmVal);
+  }
 
   void setDFPImm(uint64_t Val) {
     assert(isDFPImm() && "This is not an FP immediate");
     FPImmVal = Val;
   }
+  void setFPImm(double Val) {
+    assert(isDFPImm() && "This is not an FP immediate");
+    FPImmVal = bit_cast<uint64_t>(Val);
+  }
 
   const MCExpr *getExpr() const {
     assert(isExpr() && "This is not an expression");
@@ -153,6 +161,12 @@ class MCOperand {
     Op.FPImmVal = Val;
     return Op;
   }
+  static MCOperand createFPImm(double Val) {
+    MCOperand Op;
+    Op.Kind = kDFPImmediate;
+    Op.FPImmVal = bit_cast<uint64_t>(Val);
+    return Op;
+  }
 
   static MCOperand createExpr(const MCExpr *Val) {
     MCOperand Op;


        


More information about the llvm-commits mailing list