LLVM: lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

25

26using namespace llvm;

27

28#define DEBUG_TYPE "riscvmcexpr"

29

33}

34

39

40 if (HasVariant)

43 if (HasVariant)

44 OS << ')';

45}

46

50 return nullptr;

51

53 if (!AUIPCSRE)

54 return nullptr;

55

57 const auto *DF = dyn_cast_or_null(AUIPCSymbol->getFragment());

58

59 if (DF)

60 return nullptr;

61

63 if (DF->getContents().size() == Offset) {

64 DF = dyn_cast_or_null(DF->getNext());

65 if (DF)

66 return nullptr;

68 }

69

70 for (const MCFixup &F : DF->getFixups()) {

71 if (F.getOffset() != Offset)

72 continue;

73

74 switch ((unsigned)F.getKind()) {

75 default:

76 continue;

82 if (DFOut)

83 *DFOut = DF;

84 return &F;

85 }

86 }

87

88 return nullptr;

89}

90

94

95

96

98 return false;

99

100 Res =

102

104}

105

108}

109

127}

128

130 switch (Kind) {

135 return "lo";

137 return "hi";

139 return "pcrel_lo";

141 return "pcrel_hi";

143 return "got_pcrel_hi";

145 return "tprel_lo";

147 return "tprel_hi";

149 return "tprel_add";

151 return "tls_ie_pcrel_hi";

153 return "tlsdesc_hi";

155 return "tlsdesc_load_lo";

157 return "tlsdesc_add_lo";

159 return "tlsdesc_call";

161 return "tls_gd_pcrel_hi";

163 return "call";

165 return "call_plt";

167 return "32_pcrel";

168 }

170}

171

173 switch (Expr->getKind()) {

176 break;

178 break;

179

181 const MCBinaryExpr *BE = cast(Expr);

184 break;

185 }

186

188

189

190 const MCSymbolRefExpr &SymRef = *cast(Expr);

192 break;

193 }

194

197 break;

198 }

199}

200

203 default:

204 return;

209 break;

210 }

211

213}

214

217

225 return false;

226

228 return false;

229

230 if (Value.isAbsolute())

231 return false;

232

233 Res = evaluateAsInt64(Value.getConstant());

234 return true;

235}

236

237int64_t RISCVMCExpr::evaluateAsInt64(int64_t Value) const {

238 switch (Kind) {

239 default:

242 return SignExtend64<12>(Value);

244

245 return ((Value + 0x800) >> 12) & 0xfffff;

246 }

247}

static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm)

static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")

PowerPC TLS Dynamic Call Fixup

This class is intended to be used as a base class for asm properties and features specific to the tar...

Binary assembler expressions.

const MCExpr * getLHS() const

Get the left-hand side expression of the binary operator.

const MCExpr * getRHS() const

Get the right-hand side expression of the binary operator.

Context object for machine code objects.

Base class for the full range of assembler expressions which are needed for parsing.

@ Unary

Unary expressions.

@ Constant

Constant expressions.

@ SymbolRef

References to labels and assigned expressions.

@ Target

Target specific expression.

@ Binary

Binary expressions.

bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const

Try to evaluate the expression to a relocatable value, i.e.

void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const

Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...

Streaming machine code generation interface.

void visitUsedExpr(const MCExpr &Expr)

Represent a reference to a symbol from inside an expression.

const MCSymbol & getSymbol() const

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

uint64_t getOffset() const

MCFragment * getFragment(bool SetUsed=true) const

This represents an "assembler immediate".

int64_t getConstant() const

static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=nullptr, int64_t Val=0, uint32_t RefKind=0)

const MCSymbolRefExpr * getSymB() const

const MCSymbolRefExpr * getSymA() const

VariantKind getKind() const

void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override

static const RISCVMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)

void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override

const MCFixup * getPCRelHiFixup(const MCFragment **DFOut) const

Get the corresponding PC-relative HI fixup that a VK_RISCV_PCREL_LO points to, and optionally the fra...

void visitUsedExpr(MCStreamer &Streamer) const override

@ VK_RISCV_TLSDESC_ADD_LO

@ VK_RISCV_TLSDESC_LOAD_LO

bool evaluateAsConstant(int64_t &Res) const

static StringRef getVariantKindName(VariantKind Kind)

bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const override

const MCExpr * getSubExpr() const

static VariantKind getVariantKindForName(StringRef name)

StringRef - Represent a constant reference to a string, i.e.

A switch()-like statement whose cases are string literals.

StringSwitch & Case(StringLiteral S, T Value)

LLVM Value Representation.

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ fixup_riscv_tls_got_hi20

@ fixup_riscv_tls_gd_hi20

@ fixup_riscv_tlsdesc_hi20

This is an optimization pass for GlobalISel generic memory operations.