Define generic 1, 2 and 4 byte pc relative relocations. They are common
[oota-llvm.git] / include / llvm / MC / MCFixup.h
index eed4c349e848ee9cfbc49bad46774d6f55c5aa74..5352c642e626401e80971d69f324404ef80c4051 100644 (file)
@@ -22,6 +22,9 @@ enum MCFixupKind {
   FK_Data_2,     ///< A two-byte fixup.
   FK_Data_4,     ///< A four-byte fixup.
   FK_Data_8,     ///< A eight-byte fixup.
+  FK_PCRel_1,    ///< A one-byte pc relative fixup.
+  FK_PCRel_2,    ///< A two-byte pc relative fixup.
+  FK_PCRel_4,    ///< A four-byte pc relative fixup.
 
   FirstTargetFixupKind = 128,
 
@@ -77,13 +80,15 @@ public:
 
   /// getKindForSize - Return the generic fixup kind for a value with the given
   /// size. It is an error to pass an unsupported size.
-  static MCFixupKind getKindForSize(unsigned Size) {
+  static MCFixupKind getKindForSize(unsigned Size, bool isPCRel) {
     switch (Size) {
     default: assert(0 && "Invalid generic fixup size!");
-    case 1: return FK_Data_1;
-    case 2: return FK_Data_2;
-    case 4: return FK_Data_4;
-    case 8: return FK_Data_8;
+    case 1: return isPCRel ? FK_PCRel_1 : FK_Data_1;
+    case 2: return isPCRel ? FK_PCRel_2 : FK_Data_2;
+    case 4: return isPCRel ? FK_PCRel_4 : FK_Data_4;
+    case 8:
+      assert(!isPCRel && "8 byte pc relative fixup is not supported.");
+      return FK_Data_8;
     }
   }
 };