mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
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
This commit is contained in:
@@ -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);
|
||||
|
@@ -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; }
|
||||
|
||||
|
Reference in New Issue
Block a user