Pass the value type to TLI::getRegisterByName
authorHal Finkel <hfinkel@anl.gov>
Sun, 11 May 2014 19:29:07 +0000 (19:29 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 11 May 2014 19:29:07 +0000 (19:29 +0000)
We must validate the value type in TLI::getRegisterByName, because if we
don't and the wrong type was used with the IR intrinsic, then we'll assert
(because we won't be able to find a valid register class with which to
construct the requested copy operation). For PPC64, additionally, the type
information is necessary to decide between the 64-bit register and the 32-bit
subregister.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208508 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/Target/AArch64/AArch64ISelLowering.cpp
lib/Target/AArch64/AArch64ISelLowering.h
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
lib/Target/ARM64/ARM64ISelLowering.cpp
lib/Target/ARM64/ARM64ISelLowering.h
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h

index c03ddbc96329bb16fd6eda05ad264c6c6ebbf3bb..060dc72421f1b275a2077787a49741f34e36423e 100644 (file)
@@ -2217,7 +2217,7 @@ public:
   /// Return the register ID of the name passed in. Used by named register
   /// global variables extension. There is no target-independent behaviour
   /// so the default action is to bail.
-  virtual unsigned getRegisterByName(const char* RegName) const {
+  virtual unsigned getRegisterByName(const char* RegName, EVT VT) const {
     report_fatal_error("Named registers not implemented for this target");
   }
 
index 1cbc83a3f6501bafe591ada84e54378f83123d3b..a5162fad94443a1a32c370a7093230e9ab407703 100644 (file)
@@ -1813,7 +1813,7 @@ SDNode
   MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(0));
   const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
   unsigned Reg = getTargetLowering()->getRegisterByName(
-                 RegStr->getString().data());
+                 RegStr->getString().data(), Op->getValueType(0));
   SDValue New = CurDAG->getCopyFromReg(
                         CurDAG->getEntryNode(), dl, Reg, Op->getValueType(0));
   New->setNodeId(-1);
@@ -1826,7 +1826,7 @@ SDNode
   MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
   const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
   unsigned Reg = getTargetLowering()->getRegisterByName(
-                 RegStr->getString().data());
+                 RegStr->getString().data(), Op->getOperand(2).getValueType());
   SDValue New = CurDAG->getCopyToReg(
                         CurDAG->getEntryNode(), dl, Reg, Op->getOperand(2));
   New->setNodeId(-1);
index a016e6e4855078de6cd03d0ca3462f966376fede..852d324476a6deadb9de171e00e6460b10121cf3 100644 (file)
@@ -2409,7 +2409,8 @@ SDValue AArch64TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG)
 
 // FIXME? Maybe this could be a TableGen attribute on some registers and
 // this table could be generated automatically from RegInfo.
-unsigned AArch64TargetLowering::getRegisterByName(const char* RegName) const {
+unsigned AArch64TargetLowering::getRegisterByName(const char* RegName,
+                                                  EVT VT) const {
   unsigned Reg = StringSwitch<unsigned>(RegName)
                        .Case("sp", AArch64::XSP)
                        .Default(0);
index 143c5528ce8b6582f7ce0cd3caa9df0b83f757ed..070db94808f0a9249f500410beab3cb0f6ce135c 100644 (file)
@@ -350,7 +350,7 @@ public:
 
   SDValue PerformDAGCombine(SDNode *N,DAGCombinerInfo &DCI) const override;
 
-  unsigned getRegisterByName(const char* RegName) const override;
+  unsigned getRegisterByName(const char* RegName, EVT VT) const override;
 
   /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
   /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
index 702e549e89adb50b897cef3ae0ef58b01c9db2ac..44e52c09f69003ec6464080dfb8874f661425b7f 100644 (file)
@@ -3925,7 +3925,8 @@ SDValue ARMTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
 
 // FIXME? Maybe this could be a TableGen attribute on some registers and
 // this table could be generated automatically from RegInfo.
-unsigned ARMTargetLowering::getRegisterByName(const char* RegName) const {
+unsigned ARMTargetLowering::getRegisterByName(const char* RegName,
+                                              EVT VT) const {
   unsigned Reg = StringSwitch<unsigned>(RegName)
                        .Case("sp", ARM::SP)
                        .Default(0);
index 03c2e34df5ce2dcb93205177df65b3a9a2d9a4d4..0175c24b735aa1230053ffdb780cecfc67b3d587 100644 (file)
@@ -471,7 +471,7 @@ namespace llvm {
     SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
     SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
 
-    unsigned getRegisterByName(const char* RegName) const override;
+    unsigned getRegisterByName(const char* RegName, EVT VT) const override;
 
     /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
     /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
index b422ddcb43ddaecbcc60b52343d585fd954a79b8..1d27e86e215be87d368591212fff56466879c5a5 100644 (file)
@@ -3445,7 +3445,8 @@ SDValue ARM64TargetLowering::LowerFRAMEADDR(SDValue Op,
 
 // FIXME? Maybe this could be a TableGen attribute on some registers and
 // this table could be generated automatically from RegInfo.
-unsigned ARM64TargetLowering::getRegisterByName(const char* RegName) const {
+unsigned ARM64TargetLowering::getRegisterByName(const char* RegName,
+                                                EVT VT) const {
   unsigned Reg = StringSwitch<unsigned>(RegName)
                        .Case("sp", ARM64::SP)
                        .Default(0);
index d7d08fa52f50209de874b323083e688c2e89de89..7292e06da7754ae1cc24309f490abfe48b380d71 100644 (file)
@@ -411,7 +411,7 @@ private:
 
   ConstraintType
   getConstraintType(const std::string &Constraint) const override;
-  unsigned getRegisterByName(const char* RegName) const override;
+  unsigned getRegisterByName(const char* RegName, EVT VT) const override;
 
   /// Examine constraint string and operand type and determine a weight value.
   /// The operand object must already have been set up with the operand type.
index 616171b2b69e2abc8df6d4496da8d911b0ba109a..7d24e23d089363a37912c7ce45389b62eaf06218 100644 (file)
@@ -12817,7 +12817,8 @@ SDValue X86TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
 
 // FIXME? Maybe this could be a TableGen attribute on some registers and
 // this table could be generated automatically from RegInfo.
-unsigned X86TargetLowering::getRegisterByName(const char* RegName) const {
+unsigned X86TargetLowering::getRegisterByName(const char* RegName,
+                                              EVT VT) const {
   unsigned Reg = StringSwitch<unsigned>(RegName)
                        .Case("esp", X86::ESP)
                        .Case("rsp", X86::RSP)
index ff571e4720012c044d5fc0ed24b2a4c6b38128d3..7d8a10c187c626b831dbfd54da353d47a69e1f32 100644 (file)
@@ -786,7 +786,7 @@ namespace llvm {
       return nullptr; // nothing to do, move along.
     }
 
-    unsigned getRegisterByName(const char* RegName) const override;
+    unsigned getRegisterByName(const char* RegName, EVT VT) const override;
 
     /// createFastISel - This method returns a target specific FastISel object,
     /// or null if the target does not support "fast" ISel.