LLVM: lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
19
20using namespace llvm;
21
30
31namespace {
32const struct ModifierEntry {
35} ModifierNames[] = {
37 {"hh8", AVR::S_HH8},
39
42
45};
46
47}
48
50 const auto &Modifier =
51 llvm::find_if(ModifierNames, [&Name](ModifierEntry const &Mod) {
52 return Mod.Spelling == Name;
53 });
54
55 if (Modifier != std::end(ModifierNames)) {
56 return Modifier->specifier;
57 }
59}
60
62 const auto &Modifier =
63 llvm::find_if(ModifierNames, [this](ModifierEntry const &Mod) {
65 });
66
67 if (Modifier != std::end(ModifierNames)) {
68 return Modifier->Spelling;
69 }
70 return nullptr;
71}
72
75
79 break;
82 break;
85 break;
88 break;
89
92 break;
95 break;
98 break;
102 break;
105 break;
108 break;
109
110 default:
112 }
113
114 return Kind;
115}
116
119 auto &E = static_cast<const AVRMCExpr &>(Expr);
121 OS << E.getName() << '(';
122 if (E.isNegated())
123 OS << '-' << '(';
125 if (E.isNegated())
126 OS << ')';
127 OS << ')';
128}
129
130int64_t AVRMCExpr::evaluateAsInt64(int64_t Value) const {
131 if (Negated)
133
137 break;
141 break;
143 Value &= 0xff0000;
145 break;
147 Value &= 0xff000000;
149 break;
152 Value >>= 1;
154 break;
157 Value >>= 1;
160 break;
162 Value >>= 1;
163 Value &= 0xff0000;
165 break;
168 Value >>= 1;
169 break;
170
172 default:
174 }
176}
177
178
179
183 auto &E = static_cast<const AVRMCExpr &>(Expr);
185 bool isRelocatable = E.getSubExpr()->evaluateAsRelocatable(Value, Asm);
186 if (!isRelocatable)
187 return false;
188
189 if (Value.isAbsolute()) {
191 } else {
192 if (!Asm || !Asm->hasLayout())
193 return false;
194
196 if (Value.getSpecifier())
197 return false;
199 if (E.getSpecifier() == AVR::S_PM)
201
202
203 Result =
205 }
206
207 return true;
208}
209
213 if (!isRelocatable)
214 return false;
215
216 if (Value.isAbsolute()) {
217 Result = evaluateAsInt64(Value.getConstant());
218 return true;
219 }
220
221 return false;
222}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AVRMCAsmInfo(const Triple &TT, const MCTargetOptions &Options)
Definition AVRMCAsmInfo.cpp:22
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
Definition AVRMCAsmInfo.cpp:117
bool evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const override
Definition AVRMCAsmInfo.cpp:180
A expression in AVR machine code.
bool evaluateAsConstant(int64_t &Result) const
Evaluates the fixup as a constant value.
Definition AVRMCAsmInfo.cpp:210
const char * getName() const
Gets the name of the expression.
Definition AVRMCAsmInfo.cpp:61
static Specifier parseSpecifier(StringRef Name)
Definition AVRMCAsmInfo.cpp:49
AVR::Fixups getFixupKind() const
Gets the fixup which corresponds to the expression.
Definition AVRMCAsmInfo.cpp:73
void printExpr(raw_ostream &, const MCExpr &) const
bool UsesELFSectionDirectiveForBSS
This is true if this target uses ELF '.section' directive before the '.bss' one.
bool SupportsDebugInformation
True if target supports emission of debugging information.
const char * SeparatorString
This string, if specified, is used to separate instructions from each other when on the same line.
unsigned CodePointerSize
Code pointer size in bytes. Default is 4.
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
StringRef CommentString
This indicates the comment string used by the assembler.
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
const MCExpr * getSubExpr() const
Spec getSpecifier() const
static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB=nullptr, int64_t Val=0, uint32_t Specifier=0)
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
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...
@ S_LO8
Corresponds to lo8().
@ S_LO8_GS
Corresponds to lo8(gs()).
@ S_HH8
Corresponds to hlo8() and hh8().
@ S_PM_HH8
Corresponds to pm_hh8().
@ S_HHI8
Corresponds to hhi8().
@ S_PM_LO8
Corresponds to pm_lo8().
@ S_PM
Corresponds to pm(), reference to program memory.
@ S_GS
Corresponds to gs().
@ S_HI8_GS
Corresponds to hi8(gs()).
@ S_PM_HI8
Corresponds to pm_hi8().
@ S_HI8
Corresponds to hi8().
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.