[llvm-commits] [llvm] r120240 - in /llvm/trunk: include/llvm/MC/MCFixup.h lib/MC/ELFObjectWriter.cpp lib/MC/MCCodeEmitter.cpp lib/MC/MCELFStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCPureStreamer.cpp lib/MC/MachObjectWriter.cpp lib/MC/WinCOFFObjectWriter.cpp lib/MC/WinCOFFStreamer.cpp lib/Target/MBlaze/MBlazeAsmBackend.cpp lib/Target/MBlaze/MBlazeFixupKinds.h lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp lib/Target/X86/X86AsmBackend.cpp lib/Target/X86/X86FixupKinds.h lib/Target/X86/X86MCCodeEmitter.cpp

Rafael Espindola rafael.espindola at gmail.com
Sun Nov 28 06:17:56 PST 2010


Author: rafael
Date: Sun Nov 28 08:17:56 2010
New Revision: 120240

URL: http://llvm.org/viewvc/llvm-project?rev=120240&view=rev
Log:
Define generic 1, 2 and 4 byte pc relative relocations. They are common
and at least the 4 byte one will be needed to implement the .cfi_* directives.

Removed:
    llvm/trunk/lib/Target/MBlaze/MBlazeFixupKinds.h
Modified:
    llvm/trunk/include/llvm/MC/MCFixup.h
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/lib/MC/MCCodeEmitter.cpp
    llvm/trunk/lib/MC/MCELFStreamer.cpp
    llvm/trunk/lib/MC/MCMachOStreamer.cpp
    llvm/trunk/lib/MC/MCPureStreamer.cpp
    llvm/trunk/lib/MC/MachObjectWriter.cpp
    llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
    llvm/trunk/lib/MC/WinCOFFStreamer.cpp
    llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp
    llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp
    llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
    llvm/trunk/lib/Target/X86/X86FixupKinds.h
    llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp

Modified: llvm/trunk/include/llvm/MC/MCFixup.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCFixup.h?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCFixup.h (original)
+++ llvm/trunk/include/llvm/MC/MCFixup.h Sun Nov 28 08:17:56 2010
@@ -22,6 +22,9 @@
   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 @@
 
   /// 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;
     }
   }
 };

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Sun Nov 28 08:17:56 2010
@@ -31,7 +31,6 @@
 
 #include "../Target/X86/X86FixupKinds.h"
 #include "../Target/ARM/ARMFixupKinds.h"
-#include "../Target/MBlaze/MBlazeFixupKinds.h"
 
 #include <vector>
 using namespace llvm;
@@ -371,8 +370,9 @@
       switch (Kind) {
       default:
         return false;
-      case X86::reloc_pcrel_1byte:
-      case X86::reloc_pcrel_4byte:
+      case FK_PCRel_1:
+      case FK_PCRel_2:
+      case FK_PCRel_4:
       case X86::reloc_riprel_4byte:
       case X86::reloc_riprel_4byte_movq_load:
         return true;
@@ -401,6 +401,9 @@
       switch (Kind) {
       default:
         return false;
+      case FK_PCRel_1:
+      case FK_PCRel_2:
+      case FK_PCRel_4:
       case ARM::fixup_arm_pcrel_12:
       case ARM::fixup_arm_vfp_pcrel_12:
       case ARM::fixup_arm_branch:
@@ -429,8 +432,9 @@
       switch (Kind) {
       default:
         return false;
-      case MBlaze::reloc_pcrel_2byte:
-      case MBlaze::reloc_pcrel_4byte:
+      case FK_PCRel_1:
+      case FK_PCRel_2:
+      case FK_PCRel_4:
         return true;
       }
     }
@@ -1509,10 +1513,10 @@
     switch ((unsigned)Fixup.getKind()) {
     default:
       llvm_unreachable("Unimplemented");
-    case MBlaze::reloc_pcrel_4byte:
+    case FK_PCRel_4:
       Type = ELF::R_MICROBLAZE_64_PCREL;
       break;
-    case MBlaze::reloc_pcrel_2byte:
+    case FK_PCRel_2:
       Type = ELF::R_MICROBLAZE_32_PCREL;
       break;
     }
@@ -1644,7 +1648,7 @@
       default: llvm_unreachable("invalid fixup kind!");
       case FK_Data_8: Type = ELF::R_X86_64_64; break;
       case X86::reloc_signed_4byte:
-      case X86::reloc_pcrel_4byte:
+      case FK_PCRel_4:
         assert(isInt<32>(Target.getConstant()));
         switch (Modifier) {
         default:
@@ -1670,7 +1674,7 @@
         Type = ELF::R_X86_64_32;
         break;
       case FK_Data_2: Type = ELF::R_X86_64_16; break;
-      case X86::reloc_pcrel_1byte:
+      case FK_PCRel_1:
       case FK_Data_1: Type = ELF::R_X86_64_8; break;
       }
     }
@@ -1697,7 +1701,7 @@
       // FIXME: Should we avoid selecting reloc_signed_4byte in 32 bit mode
       // instead?
       case X86::reloc_signed_4byte:
-      case X86::reloc_pcrel_4byte:
+      case FK_PCRel_4:
       case FK_Data_4:
         switch (Modifier) {
         default:
@@ -1735,7 +1739,7 @@
         }
         break;
       case FK_Data_2: Type = ELF::R_386_16; break;
-      case X86::reloc_pcrel_1byte:
+      case FK_PCRel_1:
       case FK_Data_1: Type = ELF::R_386_8; break;
       }
     }

Modified: llvm/trunk/lib/MC/MCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeEmitter.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/MC/MCCodeEmitter.cpp Sun Nov 28 08:17:56 2010
@@ -22,9 +22,12 @@
     { "FK_Data_1", 0, 8, 0 },
     { "FK_Data_2", 0, 16, 0 },
     { "FK_Data_4", 0, 32, 0 },
-    { "FK_Data_8", 0, 64, 0 }
+    { "FK_Data_8", 0, 64, 0 },
+    { "FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel },
+    { "FK_PCRel_2", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
+    { "FK_PCRel_4", 0, 32, MCFixupKindInfo::FKF_IsPCRel }
   };
   
-  assert(Kind <= 3 && "Unknown fixup kind");
+  assert(Kind <= 6 && "Unknown fixup kind");
   return Builtins[Kind];
 }

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Sun Nov 28 08:17:56 2010
@@ -398,7 +398,7 @@
       DF->getContents().push_back(uint8_t(AbsValue >> (i * 8)));
   } else {
     DF->addFixup(MCFixup::Create(DF->getContents().size(), AddValueSymbols(Value),
-                                 MCFixup::getKindForSize(Size)));
+                                 MCFixup::getKindForSize(Size, false)));
     DF->getContents().resize(DF->getContents().size() + Size, 0);
   }
 }

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sun Nov 28 08:17:56 2010
@@ -337,7 +337,7 @@
   } else {
     DF->addFixup(MCFixup::Create(DF->getContents().size(),
                                  AddValueSymbols(Value),
-                                 MCFixup::getKindForSize(Size)));
+                                 MCFixup::getKindForSize(Size, false)));
     DF->getContents().resize(DF->getContents().size() + Size, 0);
   }
 }

Modified: llvm/trunk/lib/MC/MCPureStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCPureStreamer.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCPureStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCPureStreamer.cpp Sun Nov 28 08:17:56 2010
@@ -173,7 +173,7 @@
   } else {
     DF->addFixup(MCFixup::Create(DF->getContents().size(),
                                  AddValueSymbols(Value),
-                                 MCFixup::getKindForSize(Size)));
+                                 MCFixup::getKindForSize(Size, false)));
     DF->getContents().resize(DF->getContents().size() + Size, 0);
   }
 }

Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Sun Nov 28 08:17:56 2010
@@ -32,11 +32,11 @@
 static unsigned getFixupKindLog2Size(unsigned Kind) {
   switch (Kind) {
   default: llvm_unreachable("invalid fixup kind!");
-  case X86::reloc_pcrel_1byte:
+  case FK_PCRel_1:
   case FK_Data_1: return 0;
-  case X86::reloc_pcrel_2byte:
+  case FK_PCRel_2:
   case FK_Data_2: return 1;
-  case X86::reloc_pcrel_4byte:
+  case FK_PCRel_4:
   case X86::reloc_riprel_4byte:
   case X86::reloc_riprel_4byte_movq_load:
   case X86::reloc_signed_4byte:
@@ -49,9 +49,9 @@
   switch (Kind) {
   default:
     return false;
-  case X86::reloc_pcrel_1byte:
-  case X86::reloc_pcrel_2byte:
-  case X86::reloc_pcrel_4byte:
+  case FK_PCRel_1:
+  case FK_PCRel_2:
+  case FK_PCRel_4:
   case X86::reloc_riprel_4byte:
   case X86::reloc_riprel_4byte_movq_load:
     return true;

Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Sun Nov 28 08:17:56 2010
@@ -689,7 +689,7 @@
   Reloc.Data.VirtualAddress += Fixup.getOffset();
 
   switch ((unsigned)Fixup.getKind()) {
-  case X86::reloc_pcrel_4byte:
+  case FK_PCRel_4:
   case X86::reloc_riprel_4byte:
   case X86::reloc_riprel_4byte_movq_load:
     Reloc.Data.Type = Is64Bit ? COFF::IMAGE_REL_AMD64_REL32

Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Sun Nov 28 08:17:56 2010
@@ -363,7 +363,7 @@
   } else {
     DF->addFixup(MCFixup::Create(DF->getContents().size(),
                                  AddValueSymbols(Value),
-                                 MCFixup::getKindForSize(Size)));
+                                 MCFixup::getKindForSize(Size, false)));
     DF->getContents().resize(DF->getContents().size() + Size, 0);
   }
 }

Modified: llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp Sun Nov 28 08:17:56 2010
@@ -10,7 +10,6 @@
 #include "llvm/Target/TargetAsmBackend.h"
 #include "MBlaze.h"
 #include "MBlazeELFWriterInfo.h"
-#include "MBlazeFixupKinds.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCAsmLayout.h"
@@ -32,9 +31,9 @@
   switch (Kind) {
   default: assert(0 && "invalid fixup kind!");
   case FK_Data_1: return 1;
-  case MBlaze::reloc_pcrel_2byte:
+  case FK_PCRel_2:
   case FK_Data_2: return 2;
-  case MBlaze::reloc_pcrel_4byte:
+  case FK_PCRel_4:
   case FK_Data_4: return 4;
   case FK_Data_8: return 8;
   }

Removed: llvm/trunk/lib/Target/MBlaze/MBlazeFixupKinds.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeFixupKinds.h?rev=120239&view=auto
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/MBlazeFixupKinds.h (original)
+++ llvm/trunk/lib/Target/MBlaze/MBlazeFixupKinds.h (removed)
@@ -1,24 +0,0 @@
-//===-- MBlaze/MBlazeFixupKinds.h - MBlaze Fixup Entries --------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MBLAZE_MBLAZEFIXUPKINDS_H
-#define LLVM_MBLAZE_MBLAZEFIXUPKINDS_H
-
-#include "llvm/MC/MCFixup.h"
-
-namespace llvm {
-namespace MBlaze {
-enum Fixups {
-  reloc_pcrel_4byte = FirstTargetFixupKind,  // 32-bit pcrel, e.g. a brlid
-  reloc_pcrel_2byte                          // 16-bit pcrel, e.g. beqid
-};
-}
-}
-
-#endif

Modified: llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp Sun Nov 28 08:17:56 2010
@@ -14,7 +14,6 @@
 #define DEBUG_TYPE "mccodeemitter"
 #include "MBlaze.h"
 #include "MBlazeInstrInfo.h"
-#include "MBlazeFixupKinds.h"
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
@@ -56,22 +55,6 @@
     return 2;
   }
 
-  const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
-    const static MCFixupKindInfo Infos[] = {
-      // name                offset  bits    flags
-      { "reloc_pcrel_4byte", 2,      4 * 8,  MCFixupKindInfo::FKF_IsPCRel },
-      { "reloc_pcrel_2byte", 2,      2 * 8,  MCFixupKindInfo::FKF_IsPCRel } };
-
-    if (Kind < FirstTargetFixupKind)
-      return MCCodeEmitter::getFixupKindInfo(Kind);
-
-    if (unsigned(Kind-FirstTargetFixupKind) < getNumFixupKinds())
-      return Infos[Kind - FirstTargetFixupKind];
-
-    assert(0 && "Invalid fixup kind.");
-    return Infos[0];
-  }
-
   static unsigned GetMBlazeRegNum(const MCOperand &MO) {
     // FIXME: getMBlazeRegisterNumbering() is sufficient?
     assert(0 && "MBlazeMCCodeEmitter::GetMBlazeRegNum() not yet implemented.");
@@ -181,13 +164,13 @@
     MCFixupKind FixupKind;
     switch (MI.getOpcode()) {
     default:
-      FixupKind = pcrel ? MCFixupKind(MBlaze::reloc_pcrel_2byte) : FK_Data_2;
+      FixupKind = pcrel ? FK_PCRel_2 : FK_Data_2;
       Fixups.push_back(MCFixup::Create(0,oper.getExpr(),FixupKind));
       break;
     case MBlaze::ORI32:
     case MBlaze::ADDI32:
     case MBlaze::BRLID32:
-      FixupKind = pcrel ? MCFixupKind(MBlaze::reloc_pcrel_4byte) : FK_Data_4;
+      FixupKind = pcrel ? FK_PCRel_4 : FK_Data_4;
       Fixups.push_back(MCFixup::Create(0,oper.getExpr(),FixupKind));
       break;
     }

Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Sun Nov 28 08:17:56 2010
@@ -29,11 +29,11 @@
 static unsigned getFixupKindLog2Size(unsigned Kind) {
   switch (Kind) {
   default: assert(0 && "invalid fixup kind!");
-  case X86::reloc_pcrel_1byte:
+  case FK_PCRel_1:
   case FK_Data_1: return 0;
-  case X86::reloc_pcrel_2byte:
+  case FK_PCRel_2:
   case FK_Data_2: return 1;
-  case X86::reloc_pcrel_4byte:
+  case FK_PCRel_4:
   case X86::reloc_riprel_4byte:
   case X86::reloc_riprel_4byte_movq_load:
   case X86::reloc_signed_4byte:

Modified: llvm/trunk/lib/Target/X86/X86FixupKinds.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FixupKinds.h?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FixupKinds.h (original)
+++ llvm/trunk/lib/Target/X86/X86FixupKinds.h Sun Nov 28 08:17:56 2010
@@ -15,10 +15,7 @@
 namespace llvm {
 namespace X86 {
 enum Fixups {
-  reloc_pcrel_4byte = FirstTargetFixupKind,  // 32-bit pcrel, e.g. a branch.
-  reloc_pcrel_1byte,                         // 8-bit pcrel, e.g. branch_1
-  reloc_pcrel_2byte,                         // 16-bit pcrel, e.g. callw
-  reloc_riprel_4byte,                        // 32-bit rip-relative
+  reloc_riprel_4byte = FirstTargetFixupKind, // 32-bit rip-relative
   reloc_riprel_4byte_movq_load,              // 32-bit rip-relative in movq
   reloc_signed_4byte,                        // 32-bit signed. Unlike FK_Data_4
                                              // this will be sign extended at

Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp?rev=120240&r1=120239&r2=120240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp Sun Nov 28 08:17:56 2010
@@ -44,9 +44,6 @@
 
   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
     const static MCFixupKindInfo Infos[] = {
-      { "reloc_pcrel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
-      { "reloc_pcrel_1byte", 0, 1 * 8, MCFixupKindInfo::FKF_IsPCRel },
-      { "reloc_pcrel_2byte", 0, 2 * 8, MCFixupKindInfo::FKF_IsPCRel },
       { "reloc_riprel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
       { "reloc_riprel_4byte_movq_load", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
       { "reloc_signed_4byte", 0, 4 * 8, 0},
@@ -173,13 +170,7 @@
   unsigned Size = X86II::getSizeOfImm(TSFlags);
   bool isPCRel = X86II::isImmPCRel(TSFlags);
 
-  switch (Size) {
-  default: assert(0 && "Unknown immediate size");
-  case 1: return isPCRel ? MCFixupKind(X86::reloc_pcrel_1byte) : FK_Data_1;
-  case 2: return isPCRel ? MCFixupKind(X86::reloc_pcrel_2byte) : FK_Data_2;
-  case 4: return isPCRel ? MCFixupKind(X86::reloc_pcrel_4byte) : FK_Data_4;
-  case 8: assert(!isPCRel); return FK_Data_8;
-  }
+  return MCFixup::getKindForSize(Size, isPCRel);
 }
 
 /// Is32BitMemOperand - Return true if the specified instruction with a memory
@@ -222,9 +213,9 @@
   if (DispOp.isImm()) {
     // If this is a simple integer displacement that doesn't require a relocation,
     // emit it now.
-    if (FixupKind != MCFixupKind(X86::reloc_pcrel_1byte) &&
-	FixupKind != MCFixupKind(X86::reloc_pcrel_2byte) &&
-	FixupKind != MCFixupKind(X86::reloc_pcrel_4byte)) {
+    if (FixupKind != FK_PCRel_1 &&
+	FixupKind != FK_PCRel_2 &&
+	FixupKind != FK_PCRel_4) {
       EmitConstant(DispOp.getImm()+ImmOffset, Size, CurByte, OS);
       return;
     }
@@ -243,13 +234,13 @@
 
   // If the fixup is pc-relative, we need to bias the value to be relative to
   // the start of the field, not the end of the field.
-  if (FixupKind == MCFixupKind(X86::reloc_pcrel_4byte) ||
+  if (FixupKind == FK_PCRel_4 ||
       FixupKind == MCFixupKind(X86::reloc_riprel_4byte) ||
       FixupKind == MCFixupKind(X86::reloc_riprel_4byte_movq_load))
     ImmOffset -= 4;
-  if (FixupKind == MCFixupKind(X86::reloc_pcrel_2byte))
+  if (FixupKind == FK_PCRel_2)
     ImmOffset -= 2;
-  if (FixupKind == MCFixupKind(X86::reloc_pcrel_1byte))
+  if (FixupKind == FK_PCRel_1)
     ImmOffset -= 1;
 
   if (ImmOffset)





More information about the llvm-commits mailing list