Add target a target hook to get the register number used by the compact unwind
authorBill Wendling <isanbard@gmail.com>
Thu, 30 Jun 2011 23:20:32 +0000 (23:20 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 30 Jun 2011 23:20:32 +0000 (23:20 +0000)
encoding for the registers it knows about. Return -1 if it can't handle that
register.

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

include/llvm/Target/TargetAsmInfo.h
include/llvm/Target/TargetRegisterInfo.h
lib/Target/X86/X86RegisterInfo.cpp
lib/Target/X86/X86RegisterInfo.h

index abaed81198907d9a6cf2c28f4e573466de22675e..1a417a11592807a357a3162039c8071ee88233ec 100644 (file)
@@ -106,6 +106,10 @@ public:
   int getSEHRegNum(unsigned RegNum) const {
     return TRI->getSEHRegNum(RegNum);
   }
+
+  int getCompactUnwindRegNum(unsigned RegNum) const {
+    return TRI->getCompactUnwindRegNum(RegNum);
+  }
 };
 
 }
index 2965b1d16d3acaf14c0ae6a5c87a1da9769a7278..3f28f6cd315f604fa5b842e747511b73c6f16101 100644 (file)
@@ -720,6 +720,12 @@ public:
   virtual int getSEHRegNum(unsigned i) const {
     return i;
   }
+
+  /// getCompactUnwindRegNum - This function maps the register to the number for
+  /// compact unwind encoding. Return -1 if the register isn't valid.
+  virtual int getCompactUnwindRegNum(unsigned) const {
+    return -1;
+  }
 };
 
 
index c0ce81a5cb0603efec1113a098528748f0a037aa..20f8992b84ca3c62c61367b5a4f6c94dd88456ba 100644 (file)
@@ -105,6 +105,21 @@ int X86RegisterInfo::getLLVMRegNum(unsigned DwarfRegNo, bool isEH) const {
   return X86GenRegisterInfo::getLLVMRegNumFull(DwarfRegNo, Flavour);
 }
 
+/// getCompactUnwindRegNum - This function maps the register to the number for
+/// compact unwind encoding. Return -1 if the register isn't valid.
+int X86RegisterInfo::getCompactUnwindRegNum(unsigned RegNum) const {
+  switch (RegNum) {
+  case X86::EBX: case X86::RBX: return 1;
+  case X86::ECX: case X86::RCX: return 2;
+  case X86::EDX: case X86::RDX: return 3;
+  case X86::EDI: case X86::RDI: return 4;
+  case X86::ESI: case X86::RSI: return 5;
+  case X86::EBP: case X86::RBP: return 6;
+  }
+
+  return -1;
+}
+
 int
 X86RegisterInfo::getSEHRegNum(unsigned i) const {
   int reg = getX86RegNum(i);
index 0c014a6b78d20479f37ba03da187a1d543892d5a..a09c7eeed828a66b7e8c63ea534c53374bb08183 100644 (file)
@@ -81,6 +81,10 @@ public:
   // FIXME: This should be tablegen'd like getDwarfRegNum is
   int getSEHRegNum(unsigned i) const;
 
+  /// getCompactUnwindRegNum - This function maps the register to the number for
+  /// compact unwind encoding. Return -1 if the register isn't valid.
+  int getCompactUnwindRegNum(unsigned RegNum) const;
+
   /// Code Generation virtual methods...
   ///