diff options
author | David Peixotto <dpeixott@codeaurora.org> | 2013-12-04 22:43:20 +0000 |
---|---|---|
committer | David Peixotto <dpeixott@codeaurora.org> | 2013-12-04 22:43:20 +0000 |
commit | 0fc8c68b11a05aa276a066922d3c076034f1e37a (patch) | |
tree | 15f325e4c4ef45d1af86a649894de6fa679231a1 /include/llvm | |
parent | 6b2011a4a3e5dc10af33407b3f2a5c7e53274b49 (diff) | |
download | llvm-0fc8c68b11a05aa276a066922d3c076034f1e37a.tar.gz llvm-0fc8c68b11a05aa276a066922d3c076034f1e37a.tar.bz2 llvm-0fc8c68b11a05aa276a066922d3c076034f1e37a.tar.xz |
Add support for parsing ARM symbol variants on ELF targets
ARM symbol variants are written with parens instead of @ like this:
.word __GLOBAL_I_a(target1)
This commit adds support for parsing these symbol variants in
expressions. We introduce a new flag to MCAsmInfo that indicates the
parser should use parens to parse the symbol variant. The expression
parser is modified to look for symbol variants using parens instead
of @ when the corresponding MCAsmInfo flag is true.
The MCAsmInfo parens flag is enabled only for ARM on ELF.
By adding this flag to MCAsmInfo, we are able to get rid of
redundant ARM-specific symbol variants and use the generic variants
instead (e.g. VK_GOT instead of VK_ARM_GOT). We use the new
UseParensForSymbolVariant attribute in MCAsmInfo to correctly print
the symbol variants for arm.
To achive this we need to keep a handle to the MCAsmInfo in the
MCSymbolRefExpr class that we can check when printing the symbol
variant.
Updated Tests:
Changed case of symbol variant to match the generic kind.
test/CodeGen/ARM/tls-models.ll
test/CodeGen/ARM/tls1.ll
test/CodeGen/ARM/tls2.ll
test/CodeGen/Thumb2/tls1.ll
test/CodeGen/Thumb2/tls2.ll
PR18080
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/MC/MCAsmInfo.h | 7 | ||||
-rw-r--r-- | include/llvm/MC/MCExpr.h | 19 |
2 files changed, 17 insertions, 9 deletions
diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 8672b8dacf..f58a25d331 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -306,6 +306,10 @@ namespace llvm { /// instead of symbolic register names in .cfi_* directives. bool DwarfRegNumForCFI; // Defaults to false; + /// UseParensForSymbolVariant - True if target uses parens to indicate the + /// symbol variant instead of @. For example, foo(plt) instead of foo@plt. + bool UseParensForSymbolVariant; // Defaults to false; + //===--- Prologue State ----------------------------------------------===// std::vector<MCCFIInstruction> InitialFrameState; @@ -530,6 +534,9 @@ namespace llvm { bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; } + bool useParensForSymbolVariant() const { + return UseParensForSymbolVariant; + } void addInitialFrameState(const MCCFIInstruction &Inst) { InitialFrameState.push_back(Inst); diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h index 5d559744da..3052de112f 100644 --- a/include/llvm/MC/MCExpr.h +++ b/include/llvm/MC/MCExpr.h @@ -15,6 +15,7 @@ #include "llvm/Support/DataTypes.h" namespace llvm { +class MCAsmInfo; class MCAsmLayout; class MCAssembler; class MCContext; @@ -159,14 +160,8 @@ public: VK_DTPOFF, VK_TLVP, // Mach-O thread local variable relocation VK_SECREL, - // FIXME: We'd really like to use the generic Kinds listed above for these. + VK_ARM_NONE, - VK_ARM_PLT, // ARM-style PLT references. i.e., (PLT) instead of @PLT - VK_ARM_TLSGD, // ditto for TLSGD, GOT, GOTOFF, TPOFF and GOTTPOFF - VK_ARM_GOT, - VK_ARM_GOTOFF, - VK_ARM_TPOFF, - VK_ARM_GOTTPOFF, VK_ARM_TARGET1, VK_ARM_TARGET2, VK_ARM_PREL31, @@ -258,9 +253,14 @@ private: /// The symbol reference modifier. const VariantKind Kind; - explicit MCSymbolRefExpr(const MCSymbol *_Symbol, VariantKind _Kind) - : MCExpr(MCExpr::SymbolRef), Symbol(_Symbol), Kind(_Kind) { + /// MCAsmInfo that is used to print symbol variants correctly. + const MCAsmInfo *MAI; + + explicit MCSymbolRefExpr(const MCSymbol *_Symbol, VariantKind _Kind, + const MCAsmInfo *_MAI) + : MCExpr(MCExpr::SymbolRef), Symbol(_Symbol), Kind(_Kind), MAI(_MAI) { assert(Symbol); + assert(MAI); } public: @@ -281,6 +281,7 @@ public: /// @{ const MCSymbol &getSymbol() const { return *Symbol; } + const MCAsmInfo &getMCAsmInfo() const { return *MAI; } VariantKind getKind() const { return Kind; } |