2009-08-31 08:06:59 +00:00
|
|
|
//===- MCExpr.h - Assembly Level Expressions --------------------*- C++ -*-===//
|
2009-06-29 20:40:36 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-08-31 08:06:59 +00:00
|
|
|
#ifndef LLVM_MC_MCEXPR_H
|
|
|
|
#define LLVM_MC_MCEXPR_H
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2010-12-07 00:27:36 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2017-01-19 20:06:32 +00:00
|
|
|
#include "llvm/Support/SMLoc.h"
|
2017-02-07 23:02:00 +00:00
|
|
|
#include <cstdint>
|
2009-06-29 20:40:36 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2013-12-04 22:43:20 +00:00
|
|
|
class MCAsmInfo;
|
2010-03-11 02:28:59 +00:00
|
|
|
class MCAsmLayout;
|
2010-12-03 00:55:40 +00:00
|
|
|
class MCAssembler;
|
2009-06-29 20:40:36 +00:00
|
|
|
class MCContext;
|
2014-08-10 11:35:12 +00:00
|
|
|
class MCFixup;
|
2015-10-05 12:07:05 +00:00
|
|
|
class MCFragment;
|
2011-04-29 18:00:03 +00:00
|
|
|
class MCSection;
|
2014-06-25 15:45:33 +00:00
|
|
|
class MCStreamer;
|
2009-06-29 20:40:36 +00:00
|
|
|
class MCSymbol;
|
2009-06-30 01:49:52 +00:00
|
|
|
class MCValue;
|
2009-08-31 08:07:33 +00:00
|
|
|
class raw_ostream;
|
2009-09-16 01:26:31 +00:00
|
|
|
class StringRef;
|
2017-04-26 22:31:39 +00:00
|
|
|
|
|
|
|
using SectionAddrMap = DenseMap<const MCSection *, uint64_t>;
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Base class for the full range of assembler expressions which are
|
2009-08-31 08:07:22 +00:00
|
|
|
/// needed for parsing.
|
2009-08-31 08:06:59 +00:00
|
|
|
class MCExpr {
|
2009-06-29 20:40:36 +00:00
|
|
|
public:
|
2009-08-31 08:06:59 +00:00
|
|
|
enum ExprKind {
|
2009-07-01 15:14:50 +00:00
|
|
|
Binary, ///< Binary expressions.
|
|
|
|
Constant, ///< Constant expressions.
|
|
|
|
SymbolRef, ///< References to labels and assigned expressions.
|
2010-02-08 19:41:07 +00:00
|
|
|
Unary, ///< Unary expressions.
|
|
|
|
Target ///< Target specific expression.
|
2009-06-29 20:40:36 +00:00
|
|
|
};
|
2009-08-31 08:07:22 +00:00
|
|
|
|
2009-06-29 20:40:36 +00:00
|
|
|
private:
|
2009-08-31 08:06:59 +00:00
|
|
|
ExprKind Kind;
|
2017-01-19 20:06:32 +00:00
|
|
|
SMLoc Loc;
|
2009-08-31 08:07:22 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
|
2010-12-18 03:57:21 +00:00
|
|
|
const MCAsmLayout *Layout,
|
2010-12-07 00:27:36 +00:00
|
|
|
const SectionAddrMap *Addrs) const;
|
2014-08-15 14:20:32 +00:00
|
|
|
|
|
|
|
bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
|
|
|
|
const MCAsmLayout *Layout,
|
|
|
|
const SectionAddrMap *Addrs, bool InSet) const;
|
|
|
|
|
2009-06-29 20:40:36 +00:00
|
|
|
protected:
|
2017-01-19 20:06:32 +00:00
|
|
|
explicit MCExpr(ExprKind Kind, SMLoc Loc) : Kind(Kind), Loc(Loc) {}
|
2009-08-31 08:07:22 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
|
2010-12-18 03:57:21 +00:00
|
|
|
const MCAsmLayout *Layout,
|
2014-08-10 11:35:12 +00:00
|
|
|
const MCFixup *Fixup,
|
2015-03-25 13:16:53 +00:00
|
|
|
const SectionAddrMap *Addrs, bool InSet) const;
|
2014-04-28 20:53:11 +00:00
|
|
|
|
2009-06-29 20:40:36 +00:00
|
|
|
public:
|
2017-02-07 23:02:00 +00:00
|
|
|
MCExpr(const MCExpr &) = delete;
|
|
|
|
MCExpr &operator=(const MCExpr &) = delete;
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Accessors
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2009-08-31 08:06:59 +00:00
|
|
|
ExprKind getKind() const { return Kind; }
|
2017-01-19 20:06:32 +00:00
|
|
|
SMLoc getLoc() const { return Loc; }
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2009-08-31 08:07:33 +00:00
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Utility Methods
|
2009-08-31 08:07:33 +00:00
|
|
|
/// @{
|
|
|
|
|
2016-05-03 13:35:44 +00:00
|
|
|
void print(raw_ostream &OS, const MCAsmInfo *MAI,
|
|
|
|
bool InParens = false) const;
|
2009-08-31 08:07:33 +00:00
|
|
|
void dump() const;
|
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Expression Evaluation
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Try to evaluate the expression to an absolute value.
|
2009-06-29 20:40:36 +00:00
|
|
|
///
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \param Res - The absolute value, if evaluation succeeds.
|
|
|
|
/// \param Layout - The assembler layout object to use for evaluating symbol
|
2010-03-11 02:28:59 +00:00
|
|
|
/// values. If not given, then only non-symbolic expressions will be
|
|
|
|
/// evaluated.
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \return - True on success.
|
2015-05-30 01:25:56 +00:00
|
|
|
bool evaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout,
|
2012-08-23 16:54:08 +00:00
|
|
|
const SectionAddrMap &Addrs) const;
|
2015-05-30 01:25:56 +00:00
|
|
|
bool evaluateAsAbsolute(int64_t &Res) const;
|
|
|
|
bool evaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
|
|
|
|
bool evaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2015-03-25 00:25:37 +00:00
|
|
|
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
|
2014-08-15 14:20:32 +00:00
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Try to evaluate the expression to a relocatable value, i.e. an
|
|
|
|
/// expression of the fixed form (a - b + constant).
|
2009-06-30 01:49:52 +00:00
|
|
|
///
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \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.
|
|
|
|
/// \return - True on success.
|
2015-05-30 01:25:56 +00:00
|
|
|
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout,
|
2014-08-10 11:35:12 +00:00
|
|
|
const MCFixup *Fixup) const;
|
2009-06-30 01:49:52 +00:00
|
|
|
|
2015-03-26 21:11:00 +00:00
|
|
|
/// \brief Try to evaluate the expression to the form (a - b + constant) where
|
|
|
|
/// neither a nor b are variables.
|
|
|
|
///
|
2015-05-30 01:25:56 +00:00
|
|
|
/// This is a more aggressive variant of evaluateAsRelocatable. The intended
|
2015-03-26 21:11:00 +00:00
|
|
|
/// use is for when relocations are not available, like the .size directive.
|
|
|
|
bool evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const;
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Find the "associated section" for this expression, which is
|
|
|
|
/// currently defined as the absolute section for constants, or
|
2011-04-29 18:00:03 +00:00
|
|
|
/// otherwise the section associated with the first defined symbol in the
|
|
|
|
/// expression.
|
2015-10-05 12:07:05 +00:00
|
|
|
MCFragment *findAssociatedFragment() const;
|
2011-04-29 18:00:03 +00:00
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @}
|
2009-06-29 20:40:36 +00:00
|
|
|
};
|
2010-03-12 21:00:45 +00:00
|
|
|
|
2010-01-18 00:37:40 +00:00
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
|
2015-06-09 00:31:39 +00:00
|
|
|
E.print(OS, nullptr);
|
2010-01-18 00:37:40 +00:00
|
|
|
return OS;
|
|
|
|
}
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
//// \brief Represent a constant integer expression.
|
2009-08-31 08:06:59 +00:00
|
|
|
class MCConstantExpr : public MCExpr {
|
2009-06-29 20:40:36 +00:00
|
|
|
int64_t Value;
|
|
|
|
|
2015-03-16 18:06:57 +00:00
|
|
|
explicit MCConstantExpr(int64_t Value)
|
2017-01-19 20:06:32 +00:00
|
|
|
: MCExpr(MCExpr::Constant, SMLoc()), Value(Value) {}
|
2009-08-31 08:07:22 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Construction
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCConstantExpr *create(int64_t Value, MCContext &Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
|
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Accessors
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
2009-06-29 20:40:36 +00:00
|
|
|
int64_t getValue() const { return Value; }
|
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::Constant;
|
2009-06-29 20:40:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Represent a reference to a symbol from inside an expression.
|
2009-07-01 15:14:50 +00:00
|
|
|
///
|
|
|
|
/// A symbol reference in an expression may be a use of a label, a use of an
|
|
|
|
/// assembler variable (defined constant), or constitute an implicit definition
|
|
|
|
/// of the symbol as external.
|
2009-08-31 08:06:59 +00:00
|
|
|
class MCSymbolRefExpr : public MCExpr {
|
2010-03-15 23:51:06 +00:00
|
|
|
public:
|
2015-05-21 16:40:18 +00:00
|
|
|
enum VariantKind : uint16_t {
|
2010-03-15 23:51:06 +00:00
|
|
|
VK_None,
|
|
|
|
VK_Invalid,
|
|
|
|
|
|
|
|
VK_GOT,
|
|
|
|
VK_GOTOFF,
|
2016-02-09 19:17:34 +00:00
|
|
|
VK_GOTREL,
|
2010-03-15 23:51:06 +00:00
|
|
|
VK_GOTPCREL,
|
|
|
|
VK_GOTTPOFF,
|
|
|
|
VK_INDNTPOFF,
|
|
|
|
VK_NTPOFF,
|
2010-10-28 14:22:44 +00:00
|
|
|
VK_GOTNTPOFF,
|
2010-03-15 23:51:06 +00:00
|
|
|
VK_PLT,
|
|
|
|
VK_TLSGD,
|
2010-10-28 15:02:40 +00:00
|
|
|
VK_TLSLD,
|
2010-10-28 14:37:09 +00:00
|
|
|
VK_TLSLDM,
|
2010-05-12 05:16:34 +00:00
|
|
|
VK_TPOFF,
|
2010-10-28 14:48:59 +00:00
|
|
|
VK_DTPOFF,
|
2016-03-15 00:25:22 +00:00
|
|
|
VK_TLSCALL, // symbol(tlscall)
|
2016-03-15 17:29:52 +00:00
|
|
|
VK_TLSDESC, // symbol(tlsdesc)
|
2014-03-29 10:18:08 +00:00
|
|
|
VK_TLVP, // Mach-O thread local variable relocations
|
|
|
|
VK_TLVPPAGE,
|
|
|
|
VK_TLVPPAGEOFF,
|
|
|
|
VK_PAGE,
|
|
|
|
VK_PAGEOFF,
|
|
|
|
VK_GOTPAGE,
|
|
|
|
VK_GOTPAGEOFF,
|
2012-02-11 17:26:53 +00:00
|
|
|
VK_SECREL,
|
2015-03-04 06:49:39 +00:00
|
|
|
VK_SIZE, // symbol@SIZE
|
2014-03-20 02:12:01 +00:00
|
|
|
VK_WEAKREF, // The link between the symbols in .weakref foo, bar
|
2013-12-04 22:43:20 +00:00
|
|
|
|
2017-01-31 18:28:44 +00:00
|
|
|
VK_X86_ABS8,
|
|
|
|
|
2012-12-12 07:14:46 +00:00
|
|
|
VK_ARM_NONE,
|
2015-10-26 18:23:16 +00:00
|
|
|
VK_ARM_GOT_PREL,
|
2012-01-26 09:25:43 +00:00
|
|
|
VK_ARM_TARGET1,
|
2012-11-09 20:20:12 +00:00
|
|
|
VK_ARM_TARGET2,
|
2012-12-12 07:14:46 +00:00
|
|
|
VK_ARM_PREL31,
|
2015-01-11 04:39:18 +00:00
|
|
|
VK_ARM_SBREL, // symbol(sbrel)
|
2014-01-20 11:00:40 +00:00
|
|
|
VK_ARM_TLSLDO, // symbol(tlsldo)
|
2014-01-30 04:02:47 +00:00
|
|
|
VK_ARM_TLSDESCSEQ,
|
2011-02-03 23:17:44 +00:00
|
|
|
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_LO, // symbol@l
|
2013-06-21 14:42:49 +00:00
|
|
|
VK_PPC_HI, // symbol@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_HA, // symbol@ha
|
2013-06-21 14:43:42 +00:00
|
|
|
VK_PPC_HIGHER, // symbol@higher
|
|
|
|
VK_PPC_HIGHERA, // symbol@highera
|
|
|
|
VK_PPC_HIGHEST, // symbol@highest
|
|
|
|
VK_PPC_HIGHESTA, // symbol@highesta
|
2013-06-25 16:49:50 +00:00
|
|
|
VK_PPC_GOT_LO, // symbol@got@l
|
|
|
|
VK_PPC_GOT_HI, // symbol@got@h
|
|
|
|
VK_PPC_GOT_HA, // symbol@got@ha
|
2013-06-20 22:39:42 +00:00
|
|
|
VK_PPC_TOCBASE, // symbol@tocbase
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_TOC, // symbol@toc
|
|
|
|
VK_PPC_TOC_LO, // symbol@toc@l
|
2013-06-21 14:43:10 +00:00
|
|
|
VK_PPC_TOC_HI, // symbol@toc@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_TOC_HA, // symbol@toc@ha
|
2013-07-01 23:33:29 +00:00
|
|
|
VK_PPC_DTPMOD, // symbol@dtpmod
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_TPREL_LO, // symbol@tprel@l
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_TPREL_HI, // symbol@tprel@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_TPREL_HA, // symbol@tprel@ha
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_TPREL_HIGHER, // symbol@tprel@higher
|
|
|
|
VK_PPC_TPREL_HIGHERA, // symbol@tprel@highera
|
|
|
|
VK_PPC_TPREL_HIGHEST, // symbol@tprel@highest
|
|
|
|
VK_PPC_TPREL_HIGHESTA, // symbol@tprel@highesta
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_DTPREL_LO, // symbol@dtprel@l
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_DTPREL_HI, // symbol@dtprel@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_DTPREL_HA, // symbol@dtprel@ha
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_DTPREL_HIGHER, // symbol@dtprel@higher
|
|
|
|
VK_PPC_DTPREL_HIGHERA, // symbol@dtprel@highera
|
|
|
|
VK_PPC_DTPREL_HIGHEST, // symbol@dtprel@highest
|
|
|
|
VK_PPC_DTPREL_HIGHESTA,// symbol@dtprel@highesta
|
|
|
|
VK_PPC_GOT_TPREL, // symbol@got@tprel
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_GOT_TPREL_LO, // symbol@got@tprel@l
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_GOT_TPREL_HI, // symbol@got@tprel@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_GOT_TPREL_HA, // symbol@got@tprel@ha
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_GOT_DTPREL, // symbol@got@dtprel
|
|
|
|
VK_PPC_GOT_DTPREL_LO, // symbol@got@dtprel@l
|
|
|
|
VK_PPC_GOT_DTPREL_HI, // symbol@got@dtprel@h
|
|
|
|
VK_PPC_GOT_DTPREL_HA, // symbol@got@dtprel@ha
|
2012-12-04 16:18:08 +00:00
|
|
|
VK_PPC_TLS, // symbol@tls
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_GOT_TLSGD, // symbol@got@tlsgd
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_GOT_TLSGD_LO, // symbol@got@tlsgd@l
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_GOT_TLSGD_HI, // symbol@got@tlsgd@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_GOT_TLSGD_HA, // symbol@got@tlsgd@ha
|
[PowerPC] Revert r185476 and fix up TLS variant kinds
In the commit message to r185476 I wrote:
>The PowerPC-specific modifiers VK_PPC_TLSGD and VK_PPC_TLSLD
>correspond exactly to the generic modifiers VK_TLSGD and VK_TLSLD.
>This causes some confusion with the asm parser, since VK_PPC_TLSGD
>is output as @tlsgd, which is then read back in as VK_TLSGD.
>
>To avoid this confusion, this patch removes the PowerPC-specific
>modifiers and uses the generic modifiers throughout. (The only
>drawback is that the generic modifiers are printed in upper case
>while the usual convention on PowerPC is to use lower-case modifiers.
>But this is just a cosmetic issue.)
This was unfortunately incorrect, there is is fact another,
serious drawback to using the default VK_TLSLD/VK_TLSGD
variant kinds: using these causes ELFObjectWriter::RelocNeedsGOT
to return true, which in turn causes the ELFObjectWriter to emit
an undefined reference to _GLOBAL_OFFSET_TABLE_.
This is a problem on powerpc64, because it uses the TOC instead
of the GOT, and the linker does not provide _GLOBAL_OFFSET_TABLE_,
so the symbol remains undefined. This means shared libraries
using TLS built with the integrated assembler are currently
broken.
While the whole RelocNeedsGOT / _GLOBAL_OFFSET_TABLE_ situation
probably ought to be properly fixed at some point, for now I'm
simply reverting the r185476 commit. Now this in turn exposes
the breakage of handling @tlsgd/@tlsld in the asm parser that
this check-in was originally intended to fix.
To avoid this regression, I'm also adding a different fix for
this problem: while common code now parses @tlsgd as VK_TLSGD,
a special hack in the asm parser translates this code to the
platform-specific VK_PPC_TLSGD that the back-end now expects.
While this is not really pretty, it's self-contained and
shouldn't hurt anything else for now. One the underlying
problem is fixed, this hack can be reverted again.
llvm-svn: 185945
2013-07-09 16:41:09 +00:00
|
|
|
VK_PPC_TLSGD, // symbol@tlsgd
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_GOT_TLSLD, // symbol@got@tlsld
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_GOT_TLSLD_LO, // symbol@got@tlsld@l
|
2013-06-21 14:44:15 +00:00
|
|
|
VK_PPC_GOT_TLSLD_HI, // symbol@got@tlsld@h
|
2013-06-21 14:42:20 +00:00
|
|
|
VK_PPC_GOT_TLSLD_HA, // symbol@got@tlsld@ha
|
[PowerPC] Revert r185476 and fix up TLS variant kinds
In the commit message to r185476 I wrote:
>The PowerPC-specific modifiers VK_PPC_TLSGD and VK_PPC_TLSLD
>correspond exactly to the generic modifiers VK_TLSGD and VK_TLSLD.
>This causes some confusion with the asm parser, since VK_PPC_TLSGD
>is output as @tlsgd, which is then read back in as VK_TLSGD.
>
>To avoid this confusion, this patch removes the PowerPC-specific
>modifiers and uses the generic modifiers throughout. (The only
>drawback is that the generic modifiers are printed in upper case
>while the usual convention on PowerPC is to use lower-case modifiers.
>But this is just a cosmetic issue.)
This was unfortunately incorrect, there is is fact another,
serious drawback to using the default VK_TLSLD/VK_TLSGD
variant kinds: using these causes ELFObjectWriter::RelocNeedsGOT
to return true, which in turn causes the ELFObjectWriter to emit
an undefined reference to _GLOBAL_OFFSET_TABLE_.
This is a problem on powerpc64, because it uses the TOC instead
of the GOT, and the linker does not provide _GLOBAL_OFFSET_TABLE_,
so the symbol remains undefined. This means shared libraries
using TLS built with the integrated assembler are currently
broken.
While the whole RelocNeedsGOT / _GLOBAL_OFFSET_TABLE_ situation
probably ought to be properly fixed at some point, for now I'm
simply reverting the r185476 commit. Now this in turn exposes
the breakage of handling @tlsgd/@tlsld in the asm parser that
this check-in was originally intended to fix.
To avoid this regression, I'm also adding a different fix for
this problem: while common code now parses @tlsgd as VK_TLSGD,
a special hack in the asm parser translates this code to the
platform-specific VK_PPC_TLSGD that the back-end now expects.
While this is not really pretty, it's self-contained and
shouldn't hurt anything else for now. One the underlying
problem is fixed, this hack can be reverted again.
llvm-svn: 185945
2013-07-09 16:41:09 +00:00
|
|
|
VK_PPC_TLSLD, // symbol@tlsld
|
2014-11-12 15:16:30 +00:00
|
|
|
VK_PPC_LOCAL, // symbol@local
|
2011-10-25 18:13:20 +00:00
|
|
|
|
2015-05-01 21:14:21 +00:00
|
|
|
VK_COFF_IMGREL32, // symbol@imgrel (image-relative)
|
|
|
|
|
|
|
|
VK_Hexagon_PCREL,
|
|
|
|
VK_Hexagon_LO16,
|
|
|
|
VK_Hexagon_HI16,
|
|
|
|
VK_Hexagon_GPREL,
|
|
|
|
VK_Hexagon_GD_GOT,
|
|
|
|
VK_Hexagon_LD_GOT,
|
|
|
|
VK_Hexagon_GD_PLT,
|
|
|
|
VK_Hexagon_LD_PLT,
|
|
|
|
VK_Hexagon_IE,
|
|
|
|
VK_Hexagon_IE_GOT,
|
2016-01-11 23:38:05 +00:00
|
|
|
|
|
|
|
VK_WebAssembly_FUNCTION, // Function table index, rather than virtual addr
|
2017-02-24 23:18:00 +00:00
|
|
|
VK_WebAssembly_TYPEINDEX,// Type table index
|
2016-01-11 23:38:05 +00:00
|
|
|
|
2016-10-14 04:21:32 +00:00
|
|
|
VK_AMDGPU_GOTPCREL32_LO, // symbol@gotpcrel32@lo
|
|
|
|
VK_AMDGPU_GOTPCREL32_HI, // symbol@gotpcrel32@hi
|
|
|
|
VK_AMDGPU_REL32_LO, // symbol@rel32@lo
|
|
|
|
VK_AMDGPU_REL32_HI, // symbol@rel32@hi
|
|
|
|
|
2015-05-01 21:14:21 +00:00
|
|
|
VK_TPREL,
|
|
|
|
VK_DTPREL
|
2010-03-15 23:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// The symbol reference modifier.
|
2015-05-21 16:40:18 +00:00
|
|
|
const VariantKind Kind;
|
2010-03-15 23:51:06 +00:00
|
|
|
|
2014-10-11 17:57:27 +00:00
|
|
|
/// Specifies how the variant kind should be printed.
|
|
|
|
const unsigned UseParensForSymbolVariant : 1;
|
2013-12-04 22:43:20 +00:00
|
|
|
|
2014-10-11 17:57:27 +00:00
|
|
|
// FIXME: Remove this bit.
|
|
|
|
const unsigned HasSubsectionsViaSymbols : 1;
|
|
|
|
|
|
|
|
/// The symbol being referenced.
|
|
|
|
const MCSymbol *Symbol;
|
|
|
|
|
|
|
|
explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
|
2017-01-19 20:06:32 +00:00
|
|
|
const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
public:
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Construction
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCSymbolRefExpr *create(const MCSymbol *Symbol, MCContext &Ctx) {
|
|
|
|
return MCSymbolRefExpr::create(Symbol, VK_None, Ctx);
|
2010-03-15 23:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCSymbolRefExpr *create(const MCSymbol *Symbol, VariantKind Kind,
|
2017-01-19 20:06:32 +00:00
|
|
|
MCContext &Ctx, SMLoc Loc = SMLoc());
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCSymbolRefExpr *create(StringRef Name, VariantKind Kind,
|
2010-03-15 23:51:06 +00:00
|
|
|
MCContext &Ctx);
|
2011-02-03 23:17:44 +00:00
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Accessors
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
|
|
|
const MCSymbol &getSymbol() const { return *Symbol; }
|
|
|
|
|
2015-05-21 16:40:18 +00:00
|
|
|
VariantKind getKind() const { return Kind; }
|
2014-10-11 17:57:27 +00:00
|
|
|
|
|
|
|
void printVariantKind(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
|
2010-03-15 23:51:06 +00:00
|
|
|
|
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Static Utility Functions
|
2010-03-15 23:51:06 +00:00
|
|
|
/// @{
|
|
|
|
|
|
|
|
static StringRef getVariantKindName(VariantKind Kind);
|
|
|
|
|
|
|
|
static VariantKind getVariantKindForName(StringRef Name);
|
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::SymbolRef;
|
2009-06-29 20:40:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Unary assembler expressions.
|
2009-08-31 08:06:59 +00:00
|
|
|
class MCUnaryExpr : public MCExpr {
|
2009-06-29 20:40:36 +00:00
|
|
|
public:
|
|
|
|
enum Opcode {
|
2009-07-01 15:14:50 +00:00
|
|
|
LNot, ///< Logical negation.
|
|
|
|
Minus, ///< Unary minus.
|
|
|
|
Not, ///< Bitwise negation.
|
|
|
|
Plus ///< Unary plus.
|
2009-06-29 20:40:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
Opcode Op;
|
2009-08-31 08:07:22 +00:00
|
|
|
const MCExpr *Expr;
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2017-03-10 13:08:20 +00:00
|
|
|
MCUnaryExpr(Opcode Op, const MCExpr *Expr, SMLoc Loc)
|
|
|
|
: MCExpr(MCExpr::Unary, Loc), Op(Op), Expr(Expr) {}
|
2009-08-31 08:07:22 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Construction
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCUnaryExpr *create(Opcode Op, const MCExpr *Expr,
|
2017-03-10 13:08:20 +00:00
|
|
|
MCContext &Ctx, SMLoc Loc = SMLoc());
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2017-03-10 13:08:20 +00:00
|
|
|
static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
|
|
|
|
return create(LNot, Expr, Ctx, Loc);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2017-03-10 13:08:20 +00:00
|
|
|
static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
|
|
|
|
return create(Minus, Expr, Ctx, Loc);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2017-03-10 13:08:20 +00:00
|
|
|
static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
|
|
|
|
return create(Not, Expr, Ctx, Loc);
|
2009-06-29 20:40:36 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2017-03-10 13:08:20 +00:00
|
|
|
static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
|
|
|
|
return create(Plus, Expr, Ctx, Loc);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Accessors
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Get the kind of this unary expression.
|
2009-06-29 20:40:36 +00:00
|
|
|
Opcode getOpcode() const { return Op; }
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Get the child of this unary expression.
|
2009-08-31 08:07:22 +00:00
|
|
|
const MCExpr *getSubExpr() const { return Expr; }
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::Unary;
|
2009-06-29 20:40:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Binary assembler expressions.
|
2009-08-31 08:06:59 +00:00
|
|
|
class MCBinaryExpr : public MCExpr {
|
2009-06-29 20:40:36 +00:00
|
|
|
public:
|
|
|
|
enum Opcode {
|
2009-07-01 15:14:50 +00:00
|
|
|
Add, ///< Addition.
|
|
|
|
And, ///< Bitwise and.
|
2010-02-08 23:58:47 +00:00
|
|
|
Div, ///< Signed division.
|
2009-07-01 15:14:50 +00:00
|
|
|
EQ, ///< Equality comparison.
|
2010-02-08 23:58:47 +00:00
|
|
|
GT, ///< Signed greater than comparison (result is either 0 or some
|
|
|
|
///< target-specific non-zero value)
|
|
|
|
GTE, ///< Signed greater than or equal comparison (result is either 0 or
|
|
|
|
///< some target-specific non-zero value).
|
2009-07-01 15:14:50 +00:00
|
|
|
LAnd, ///< Logical and.
|
|
|
|
LOr, ///< Logical or.
|
2010-02-08 23:58:47 +00:00
|
|
|
LT, ///< Signed less than comparison (result is either 0 or
|
|
|
|
///< some target-specific non-zero value).
|
|
|
|
LTE, ///< Signed less than or equal comparison (result is either 0 or
|
|
|
|
///< some target-specific non-zero value).
|
|
|
|
Mod, ///< Signed remainder.
|
2009-07-01 15:14:50 +00:00
|
|
|
Mul, ///< Multiplication.
|
|
|
|
NE, ///< Inequality comparison.
|
|
|
|
Or, ///< Bitwise or.
|
2010-02-08 23:58:47 +00:00
|
|
|
Shl, ///< Shift left.
|
2015-04-28 00:21:32 +00:00
|
|
|
AShr, ///< Arithmetic shift right.
|
|
|
|
LShr, ///< Logical shift right.
|
2009-07-01 15:14:50 +00:00
|
|
|
Sub, ///< Subtraction.
|
|
|
|
Xor ///< Bitwise exclusive or.
|
2009-06-29 20:40:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
Opcode Op;
|
2009-08-31 08:07:22 +00:00
|
|
|
const MCExpr *LHS, *RHS;
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2017-01-19 20:06:32 +00:00
|
|
|
MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS,
|
|
|
|
SMLoc Loc = SMLoc())
|
|
|
|
: MCExpr(MCExpr::Binary, Loc), Op(Op), LHS(LHS), RHS(RHS) {}
|
2009-08-31 08:07:22 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Construction
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,
|
2017-01-19 20:06:32 +00:00
|
|
|
const MCExpr *RHS, MCContext &Ctx,
|
|
|
|
SMLoc Loc = SMLoc());
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createAdd(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Add, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createAnd(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(And, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createDiv(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Div, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createEQ(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(EQ, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createGT(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(GT, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createGTE(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(GTE, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createLAnd(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(LAnd, LHS, RHS, Ctx);
|
2009-06-29 20:40:36 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createLOr(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(LOr, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createLT(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(LT, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createLTE(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(LTE, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createMod(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Mod, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createMul(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Mul, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createNE(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(NE, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createOr(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Or, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createShl(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Shl, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createAShr(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(AShr, LHS, RHS, Ctx);
|
2015-04-28 00:21:32 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createLShr(const MCExpr *LHS, const MCExpr *RHS,
|
2015-04-28 00:21:32 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(LShr, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createSub(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Sub, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2015-05-30 01:25:56 +00:00
|
|
|
static const MCBinaryExpr *createXor(const MCExpr *LHS, const MCExpr *RHS,
|
2009-08-31 08:07:22 +00:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 01:25:56 +00:00
|
|
|
return create(Xor, LHS, RHS, Ctx);
|
2009-08-31 08:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @}
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \name Accessors
|
2009-08-31 08:07:22 +00:00
|
|
|
/// @{
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Get the kind of this binary expression.
|
2009-06-29 20:40:36 +00:00
|
|
|
Opcode getOpcode() const { return Op; }
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Get the left-hand side expression of the binary operator.
|
2009-08-31 08:07:22 +00:00
|
|
|
const MCExpr *getLHS() const { return LHS; }
|
2009-07-01 15:14:50 +00:00
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief Get the right-hand side expression of the binary operator.
|
2009-08-31 08:07:22 +00:00
|
|
|
const MCExpr *getRHS() const { return RHS; }
|
|
|
|
|
|
|
|
/// @}
|
2009-06-29 20:40:36 +00:00
|
|
|
|
2009-08-31 08:07:22 +00:00
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::Binary;
|
2009-06-29 20:40:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-02 00:44:14 +00:00
|
|
|
/// \brief This is an extension point for target-specific MCExpr subclasses to
|
|
|
|
/// implement.
|
2010-02-08 19:41:07 +00:00
|
|
|
///
|
|
|
|
/// NOTE: All subclasses are required to have trivial destructors because
|
|
|
|
/// MCExprs are bump pointer allocated and not destructed.
|
|
|
|
class MCTargetExpr : public MCExpr {
|
2012-09-26 06:36:36 +00:00
|
|
|
virtual void anchor();
|
2017-02-07 23:02:00 +00:00
|
|
|
|
2010-02-08 19:41:07 +00:00
|
|
|
protected:
|
2017-01-19 20:06:32 +00:00
|
|
|
MCTargetExpr() : MCExpr(Target, SMLoc()) {}
|
2017-02-07 23:02:00 +00:00
|
|
|
virtual ~MCTargetExpr() = default;
|
|
|
|
|
2010-02-08 19:41:07 +00:00
|
|
|
public:
|
2015-06-09 00:31:39 +00:00
|
|
|
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
|
2015-05-30 01:25:56 +00:00
|
|
|
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
|
2014-08-10 11:35:12 +00:00
|
|
|
const MCAsmLayout *Layout,
|
|
|
|
const MCFixup *Fixup) const = 0;
|
2014-06-25 15:45:33 +00:00
|
|
|
virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
|
2015-10-05 12:07:05 +00:00
|
|
|
virtual MCFragment *findAssociatedFragment() const = 0;
|
2010-02-08 19:41:07 +00:00
|
|
|
|
2013-01-31 12:12:40 +00:00
|
|
|
virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const = 0;
|
|
|
|
|
2010-02-08 19:41:07 +00:00
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::Target;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-06-29 20:40:36 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
2017-02-07 23:02:00 +00:00
|
|
|
#endif // LLVM_MC_MCEXPR_H
|