LLVM: include/llvm/MC/MCExpr.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_MC_MCEXPR_H

10#define LLVM_MC_MCEXPR_H

11

14#include

15

16namespace llvm {

17

18class MCAsmInfo;

19class MCAssembler;

20class MCContext;

21class MCFixup;

22class MCFragment;

23class MCSection;

24class MCStreamer;

26class MCValue;

27class raw_ostream;

28class StringRef;

29

31

32

33

35public:

37 Binary,

39 SymbolRef,

40 Unary,

41 Target

43

44private:

45 static const unsigned NumSubclassDataBits = 24;

46 static_assert(

47 NumSubclassDataBits == CHAR_BIT * (sizeof(unsigned) - sizeof(ExprKind)),

48 "ExprKind and SubclassData together should take up one word");

49

51

52 unsigned SubclassData : NumSubclassDataBits;

54

55 bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,

57

58protected:

60 : Kind(Kind), SubclassData(SubclassData), Loc(Loc) {

61 assert(SubclassData < (1 << NumSubclassDataBits) &&

62 "Subclass data too large");

63 }

64

68

70

71public:

74

75

76

77

80

81

82

83

84

86 bool InParens = false) const;

87 void dump() const;

88

89

90

92

93

94

95

96

97

98

99

100

101 bool evaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm,

103 bool evaluateAsAbsolute(int64_t &Res) const;

104 bool evaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;

105 bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const;

106

107

108

109

111

112

113

114

115

116

117

118

121

122

123

124

125

126

128

129

130

131

132

134

135

136};

137

139 E.print(OS, nullptr);

140 return OS;

141}

142

143

146

147

148 static const unsigned SizeInBytesBits = 8;

149 static const unsigned SizeInBytesMask = (1 << SizeInBytesBits) - 1;

150 static const unsigned PrintInHexBit = 1 << SizeInBytesBits;

151

152 static unsigned encodeSubclassData(bool PrintInHex, unsigned SizeInBytes) {

153 assert(SizeInBytes <= sizeof(int64_t) && "Excessive size");

154 return SizeInBytes | (PrintInHex ? PrintInHexBit : 0);

155 }

156

159 encodeSubclassData(PrintInHex, SizeInBytes)), Value(Value) {}

160

161public:

162

163

164

166 bool PrintInHex = false,

167 unsigned SizeInBytes = 0);

168

169

170

171

172

176 }

177

179

180

181

184 }

185};

186

187

188

189

190

191

193public:

197

217 VK_TLVP,

226 VK_WEAKREF,

233

236

245

254

326

328

338

345

353

368

372

373private:

374

376

377

378

379 static const unsigned VariantKindBits = 16;

380 static const unsigned VariantKindMask = (1 << VariantKindBits) - 1;

381

382

383 static const unsigned HasSubsectionsViaSymbolsBit = 1 << VariantKindBits;

384

385 static unsigned encodeSubclassData(VariantKind Kind,

386 bool HasSubsectionsViaSymbols) {

387 return (unsigned)Kind |

388 (HasSubsectionsViaSymbols ? HasSubsectionsViaSymbolsBit : 0);

389 }

390

391 explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,

392 const MCAsmInfo *MAI, SMLoc Loc = SMLoc());

393

394public:

395

396

397

400 }

401

406

407

408

409

410

412

415 }

416

418 return (getSubclassData() & HasSubsectionsViaSymbolsBit) != 0;

419 }

420

421

422

423

424

426

428

429

430

433 }

434};

435

436

438public:

440 LNot,

442 Not,

443 Plus

445

446private:

448

451

452public:

453

454

455

456 static const MCUnaryExpr *create(Opcode Op, const MCExpr *Expr,

457 MCContext &Ctx, SMLoc Loc = SMLoc());

458

461 }

462

465 }

466

468 return create(Not, Expr, Ctx, Loc);

469 }

470

473 }

474

475

476

477

478

479

481

482

484

485

486

489 }

490};

491

492

494public:

497 And,

498 Div,

499 EQ,

500 GT,

501

502 GTE,

503

505 LOr,

506 LT,

507

508 LTE,

509

510 Mod,

511 Mul,

512 NE,

513 Or,

515 Shl,

516 AShr,

517 LShr,

518 Sub,

519 Xor

521

522private:

523 const MCExpr *LHS, *RHS;

524

528

529public:

530

531

532

533 static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,

534 const MCExpr *RHS, MCContext &Ctx,

535 SMLoc Loc = SMLoc());

536

540 }

541

545 }

546

550 }

551

555 }

556

560 }

561

565 }

566

570 }

571

575 }

576

580 }

581

585 }

586

590 }

591

595 }

596

600 }

601

605 }

606

610 }

611

615 }

616

620 }

621

625 }

626

630 }

631

632

633

634

635

636

638

639

641

642

644

645

646

649 }

650};

651

652

653

654

655

656

658 virtual void anchor();

659

660protected:

663

664public:

668

671 return false;

672 }

673

674

678

680

683 }

684};

685

686}

687

688#endif

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file defines the DenseMap class.

PowerPC TLS Dynamic Call Fixup

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This class represents an Operation in the Expression.

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.

static const MCBinaryExpr * createEQ(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createLAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

const MCExpr * getRHS() const

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

static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static bool classof(const MCExpr *E)

static const MCBinaryExpr * createLT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

Opcode getOpcode() const

Get the kind of this binary expression.

static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createLOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createNE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createGTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createLTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createAShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createGT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())

static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

@ AShr

Arithmetic shift right.

@ LShr

Logical shift right.

@ GTE

Signed greater than or equal comparison (result is either 0 or some target-specific non-zero value).

@ GT

Signed greater than comparison (result is either 0 or some target-specific non-zero value)

@ Xor

Bitwise exclusive or.

@ 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).

@ NE

Inequality comparison.

static bool classof(const MCExpr *E)

bool useHexFormat() const

unsigned getSizeInBytes() const

static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)

Context object for machine code objects.

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

bool evaluateAsValue(MCValue &Res, const MCAssembler &Asm) const

Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables.

MCExpr & operator=(const MCExpr &)=delete

bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const

MCExpr(ExprKind Kind, SMLoc Loc, unsigned SubclassData=0)

@ Unary

Unary expressions.

@ Constant

Constant expressions.

@ SymbolRef

References to labels and assigned expressions.

@ Target

Target specific expression.

@ Binary

Binary expressions.

MCExpr(const MCExpr &)=delete

bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const

Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.

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

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

unsigned getSubclassData() const

bool isSymbolUsedInExpression(const MCSymbol *Sym) const

Returns whether the given symbol is used anywhere in the expression or subexpressions.

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

MCFragment * findAssociatedFragment() const

Find the "associated section" for this expression, which is currently defined as the absolute section...

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

Streaming machine code generation interface.

Represent a reference to a symbol from inside an expression.

const MCSymbol & getSymbol() const

static bool classof(const MCExpr *E)

static StringRef getVariantKindName(VariantKind Kind)

static VariantKind getVariantKindForName(StringRef Name)

@ VK_AMDGPU_GOTPCREL32_LO

@ VK_AMDGPU_GOTPCREL32_HI

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)

VariantKind getKind() const

bool hasSubsectionsViaSymbols() const

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

This is an extension point for target-specific MCExpr subclasses to implement.

static bool classof(const MCExpr *E)

virtual void visitUsedExpr(MCStreamer &Streamer) const =0

virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const =0

virtual bool isSymbolUsedInExpression(const MCSymbol *Sym) const

virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const =0

virtual MCFragment * findAssociatedFragment() const =0

virtual bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const =0

virtual bool isEqualTo(const MCExpr *x) const

virtual bool inlineAssignedExpr() const

virtual ~MCTargetExpr()=default

Unary assembler expressions.

Opcode getOpcode() const

Get the kind of this unary expression.

static bool classof(const MCExpr *E)

static const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())

static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())

const MCExpr * getSubExpr() const

Get the child of this unary expression.

static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())

static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())

static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())

This represents an "assembler immediate".

Represents a location in source code.

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

Target - Wrapper for Target specific information.

LLVM Value Representation.

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

This is an optimization pass for GlobalISel generic memory operations.

DWARFExpression::Operation Op

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)