[PATCH] D56037: [AArch64] Emit the correct MCExpr relocations specifiers like VK_ABS_G0, etc

Mandeep Singh Grang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 21 16:32:17 PST 2018


mgrang created this revision.
mgrang added reviewers: rnk, mstorsjo, efriedma.
Herald added subscribers: kristof.beyls, javed.absar.

D55896 <https://reviews.llvm.org/D55896> and D56029 <https://reviews.llvm.org/D56029> add support to emit fixups for :abs_g0: , :abs_g1_s: , etc.
This patch adds the necessary enums and MCExpr needed for lowering these.


Repository:
  rL LLVM

https://reviews.llvm.org/D56037

Files:
  lib/Target/AArch64/AArch64MCInstLower.cpp
  lib/Target/AArch64/Utils/AArch64BaseInfo.h


Index: lib/Target/AArch64/Utils/AArch64BaseInfo.h
===================================================================
--- lib/Target/AArch64/Utils/AArch64BaseInfo.h
+++ lib/Target/AArch64/Utils/AArch64BaseInfo.h
@@ -581,6 +581,10 @@
     /// to the symbol is for an import stub.  This is used for DLL import
     /// storage class indication on Windows.
     MO_DLLIMPORT = 0x80,
+
+    /// MO_S - Indicates that the bits of the symbol operand represented by
+    /// MO_G0 etc are signed.
+    MO_S = 0x100,
   };
 } // end namespace AArch64II
 
Index: lib/Target/AArch64/AArch64MCInstLower.cpp
===================================================================
--- lib/Target/AArch64/AArch64MCInstLower.cpp
+++ lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -189,20 +189,38 @@
 
 MCOperand AArch64MCInstLower::lowerSymbolOperandCOFF(const MachineOperand &MO,
                                                      MCSymbol *Sym) const {
-  AArch64MCExpr::VariantKind RefKind = AArch64MCExpr::VK_NONE;
+  uint32_t RefFlags = 0;
+
   if (MO.getTargetFlags() & AArch64II::MO_TLS) {
     if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_PAGEOFF)
-      RefKind = AArch64MCExpr::VK_SECREL_LO12;
+      RefFlags |= AArch64MCExpr::VK_SECREL_LO12;
     else if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) ==
              AArch64II::MO_HI12)
-      RefKind = AArch64MCExpr::VK_SECREL_HI12;
-  }
+      RefFlags |= AArch64MCExpr::VK_SECREL_HI12;
+
+  } else if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_S)
+    RefFlags |= AArch64MCExpr::VK_SABS;
+    else RefFlags |= AArch64MCExpr::VK_ABS;
+
+  if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_G3)
+    RefFlags |= AArch64MCExpr::VK_G3;
+  else if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_G2)
+    RefFlags |= AArch64MCExpr::VK_G2;
+  else if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_G1)
+    RefFlags |= AArch64MCExpr::VK_G1;
+  else if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_G0)
+    RefFlags |= AArch64MCExpr::VK_G0;
+
   const MCExpr *Expr =
       MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, Ctx);
   if (!MO.isJTI() && MO.getOffset())
     Expr = MCBinaryExpr::createAdd(
         Expr, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
+
+  AArch64MCExpr::VariantKind RefKind;
+  RefKind = static_cast<AArch64MCExpr::VariantKind>(RefFlags);
   Expr = AArch64MCExpr::create(Expr, RefKind, Ctx);
+
   return MCOperand::createExpr(Expr);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56037.179386.patch
Type: text/x-patch
Size: 2541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181222/dbd9caa6/attachment.bin>


More information about the llvm-commits mailing list