aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC/MCExpr.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/MC/MCExpr.h')
-rw-r--r--include/llvm/MC/MCExpr.h50
1 files changed, 33 insertions, 17 deletions
diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h
index e96ecb4..f0e8611 100644
--- a/include/llvm/MC/MCExpr.h
+++ b/include/llvm/MC/MCExpr.h
@@ -19,6 +19,7 @@ class MCAsmInfo;
class MCAsmLayout;
class MCAssembler;
class MCContext;
+class MCFixup;
class MCSection;
class MCSectionData;
class MCStreamer;
@@ -49,11 +50,17 @@ private:
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
const SectionAddrMap *Addrs) const;
+
+ bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
+ const MCAsmLayout *Layout,
+ const SectionAddrMap *Addrs, bool InSet) const;
+
protected:
explicit MCExpr(ExprKind _Kind) : Kind(_Kind) {}
bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
+ const MCFixup *Fixup,
const SectionAddrMap *Addrs, bool InSet,
bool ForceVarExpansion) const;
@@ -87,13 +94,17 @@ public:
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
+ int64_t evaluateKnownAbsolute(const MCAsmLayout &Layout) const;
+
/// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
/// value, i.e. an expression of the fixed form (a - b + constant).
///
/// @param Res - The relocatable value, if evaluation succeeds.
/// @param Layout - The assembler layout object to use for evaluating values.
+ /// @param Fixup - The Fixup object if available.
/// @result - True on success.
- bool EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout) const;
+ bool EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout,
+ const MCFixup *Fixup) const;
/// \brief Try to evaluate the expression to the form (a - b + constant) where
/// neither a nor b are variables.
@@ -101,7 +112,8 @@ public:
/// This is a more aggressive variant of EvaluateAsRelocatable. The intended
/// use is for when relocations are not available, like the symbol value in
/// the symbol table.
- bool EvaluateAsValue(MCValue &Res, const MCAsmLayout *Layout) const;
+ bool EvaluateAsValue(MCValue &Res, const MCAsmLayout *Layout,
+ const MCFixup *Fixup) const;
/// FindAssociatedSection - Find the "associated section" for this expression,
/// which is currently defined as the absolute section for constants, or
@@ -238,6 +250,7 @@ public:
VK_PPC_GOT_TLSLD_HI, // symbol@got@tlsld@h
VK_PPC_GOT_TLSLD_HA, // symbol@got@tlsld@ha
VK_PPC_TLSLD, // symbol@tlsld
+ VK_PPC_LOCAL, // symbol@local
VK_Mips_GPREL,
VK_Mips_GOT_CALL,
@@ -270,21 +283,20 @@ public:
};
private:
- /// The symbol being referenced.
- const MCSymbol *Symbol;
-
/// The symbol reference modifier.
- const VariantKind Kind;
+ const unsigned Kind : 16;
- /// MCAsmInfo that is used to print symbol variants correctly.
- const MCAsmInfo *MAI;
+ /// Specifies how the variant kind should be printed.
+ const unsigned UseParensForSymbolVariant : 1;
- explicit MCSymbolRefExpr(const MCSymbol *_Symbol, VariantKind _Kind,
- const MCAsmInfo *_MAI)
- : MCExpr(MCExpr::SymbolRef), Symbol(_Symbol), Kind(_Kind), MAI(_MAI) {
- assert(Symbol);
- assert(MAI);
- }
+ // FIXME: Remove this bit.
+ const unsigned HasSubsectionsViaSymbols : 1;
+
+ /// The symbol being referenced.
+ const MCSymbol *Symbol;
+
+ explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
+ const MCAsmInfo *MAI);
public:
/// @name Construction
@@ -304,9 +316,12 @@ public:
/// @{
const MCSymbol &getSymbol() const { return *Symbol; }
- const MCAsmInfo &getMCAsmInfo() const { return *MAI; }
- VariantKind getKind() const { return Kind; }
+ VariantKind getKind() const { return static_cast<VariantKind>(Kind); }
+
+ void printVariantKind(raw_ostream &OS) const;
+
+ bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
/// @}
/// @name Static Utility Functions
@@ -524,7 +539,8 @@ public:
virtual void PrintImpl(raw_ostream &OS) const = 0;
virtual bool EvaluateAsRelocatableImpl(MCValue &Res,
- const MCAsmLayout *Layout) const = 0;
+ const MCAsmLayout *Layout,
+ const MCFixup *Fixup) const = 0;
virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
virtual const MCSection *FindAssociatedSection() const = 0;