LLVM: lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10

15

16namespace llvm {

17

18namespace {

19

20const struct ModifierEntry {

21 const char *const Spelling;

23} ModifierNames[] = {

27

30

33};

34

35}

36

39 return new (Ctx) AVRMCExpr(Kind, Expr, Negated);

40}

41

46 OS << '-' << '(';

49 OS << ')';

50 OS << ')';

51}

52

55

56 bool isRelocatable =

58

59 if (!isRelocatable)

60 return false;

61

62 if (Value.isAbsolute()) {

63 Result = evaluateAsInt64(Value.getConstant());

64 return true;

65 }

66

67 return false;

68}

69

75

76 if (!isRelocatable)

77 return false;

78

79 if (Value.isAbsolute()) {

81 } else {

82 if (!Asm || !Asm->hasLayout())

83 return false;

84

85 MCContext &Context = Asm->getContext();

89 return false;

92 }

93

96 }

97

98 return true;

99}

100

101int64_t AVRMCExpr::evaluateAsInt64(int64_t Value) const {

102 if (Negated)

104

105 switch (Kind) {

108 break;

112 break;

114 Value &= 0xff0000;

116 break;

118 Value &= 0xff000000;

120 break;

123 Value >>= 1;

125 break;

128 Value >>= 1;

131 break;

133 Value >>= 1;

134 Value &= 0xff0000;

136 break;

139 Value >>= 1;

140 break;

141

144 }

145 return static_cast<uint64_t>(Value) & 0xff;

146}

147

150

154 break;

157 break;

160 break;

163 break;

164

167 break;

170 break;

173 break;

177 break;

180 break;

183 break;

184

187 }

188

189 return Kind;

190}

191

194}

195

197 const auto &Modifier =

198 llvm::find_if(ModifierNames, [this](ModifierEntry const &Mod) {

199 return Mod.VariantKind == Kind;

200 });

201

202 if (Modifier != std::end(ModifierNames)) {

203 return Modifier->Spelling;

204 }

205 return nullptr;

206}

207

209 const auto &Modifier =

211 return Mod.Spelling == Name;

212 });

213

214 if (Modifier != std::end(ModifierNames)) {

215 return Modifier->VariantKind;

216 }

218}

219

220}

PowerPC TLS Dynamic Call Fixup

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

A expression in AVR machine code.

static const AVRMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isNegated, MCContext &Ctx)

Creates an AVR machine code expression.

void visitUsedExpr(MCStreamer &streamer) const override

static VariantKind getKindByName(StringRef Name)

AVR::Fixups getFixupKind() const

Gets the fixup which corresponds to the expression.

bool evaluateAsConstant(int64_t &Result) const

Evaluates the fixup as a constant value.

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

VariantKind getKind() const

Gets the type of the expression.

const MCExpr * getSubExpr() const

VariantKind

Specifies the type of an expression.

@ VK_AVR_PM_LO8

Corresponds to pm_lo8().

@ VK_AVR_LO8

Corresponds to lo8().

@ VK_AVR_PM_HI8

Corresponds to pm_hi8().

@ VK_AVR_PM

Corresponds to pm(), reference to program memory.

@ VK_AVR_HHI8

Corresponds to hhi8().

@ VK_AVR_HI8_GS

Corresponds to hi8(gs()).

@ VK_AVR_HH8

Corresponds to hlo8() and hh8().

@ VK_AVR_LO8_GS

Corresponds to lo8(gs()).

@ VK_AVR_PM_HH8

Corresponds to pm_hh8().

@ VK_AVR_GS

Corresponds to gs().

@ VK_AVR_HI8

Corresponds to hi8().

const char * getName() const

Gets the name of the expression.

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

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

Context object for machine code objects.

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

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.

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

This represents an "assembler immediate".

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

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

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.

Fixups

The set of supported fixups.

@ fixup_16_pm

A 16-bit program memory address.

@ fixup_hh8_ldi

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 24-bit value ...

@ fixup_ms8_ldi_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 32-bi...

@ fixup_lo8_ldi_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a negated 16-bi...

@ fixup_ms8_ldi

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 32-bit value ...

@ fixup_lo8_ldi

Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a 16-bit value ...

@ fixup_hi8_ldi_pm_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 16-bi...

@ fixup_hi8_ldi

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 16-bit value ...

@ fixup_lo8_ldi_pm

Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a 16-bit progra...

@ fixup_hh8_ldi_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 24-bi...

@ fixup_hh8_ldi_pm

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 24-bit progra...

@ fixup_lo8_ldi_pm_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a negated 16-bi...

@ fixup_hi8_ldi_pm

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 16-bit progra...

@ fixup_hh8_ldi_pm_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 24-bi...

@ fixup_hi8_ldi_neg

Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 16-bi...

This is an optimization pass for GlobalISel generic memory operations.

@ Mod

The access may modify the value stored in memory.

auto find_if(R &&Range, UnaryPredicate P)

Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.