25 #define DEBUG_TYPE "mcexpr"
29 STATISTIC(MCExprEvaluate,
"Number of MCExpr evaluations");
36 return cast<MCTargetExpr>(
this)->printImpl(OS, MAI);
38 OS << cast<MCConstantExpr>(*this).getValue();
46 bool UseParens = Sym.
getName()[0] ==
'$';
76 if (isa<MCConstantExpr>(BE.
getLHS()) || isa<MCSymbolRefExpr>(BE.
getLHS())) {
88 if (RHSC->getValue() < 0) {
89 OS << RHSC->getValue();
101 case MCBinaryExpr::GTE: OS << ">="; break;
102 case MCBinaryExpr::LAnd: OS << "&&"; break;
103 case MCBinaryExpr::LOr: OS << "||"; break;
104 case MCBinaryExpr::LShr: OS << ">>"; break;
105 case MCBinaryExpr::LT: OS << '<
'; break;
106 case MCBinaryExpr::LTE: OS << "<="; break;
107 case MCBinaryExpr::Mod: OS << '%
'; break;
108 case MCBinaryExpr::Mul: OS << '*
'; break;
109 case MCBinaryExpr::NE: OS << "!="; break;
110 case MCBinaryExpr::Or: OS << '|
'; break;
111 case MCBinaryExpr::Shl: OS << "<<"; break;
112 case MCBinaryExpr::Sub: OS << '-
'; break;
113 case MCBinaryExpr::Xor: OS << '^
'; break;
116 // Only print parens around the LHS if it is non-trivial.
117 if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
118 BE.getRHS()->print(OS, MAI);
121 BE.getRHS()->print(OS, MAI);
128 llvm_unreachable("Invalid expression kind!");
131 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
132 void MCExpr::dump() const {
140 const MCBinaryExpr *MCBinaryExpr::create(Opcode Opc, const MCExpr *LHS,
141 const MCExpr *RHS, MCContext &Ctx) {
142 return new (Ctx) MCBinaryExpr(Opc, LHS, RHS);
145 const MCUnaryExpr *MCUnaryExpr::create(Opcode Opc, const MCExpr *Expr,
147 return new (Ctx) MCUnaryExpr(Opc, Expr);
150 const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx) {
151 return new (Ctx) MCConstantExpr(Value);
156 MCSymbolRefExpr::MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
157 const MCAsmInfo *MAI)
158 : MCExpr(MCExpr::SymbolRef), Kind(Kind),
159 UseParensForSymbolVariant(MAI->useParensForSymbolVariant()),
160 HasSubsectionsViaSymbols(MAI->hasSubsectionsViaSymbols()),
165 const MCSymbolRefExpr *MCSymbolRefExpr::create(const MCSymbol *Sym,
168 return new (Ctx) MCSymbolRefExpr(Sym, Kind, Ctx.getAsmInfo());
171 const MCSymbolRefExpr *MCSymbolRefExpr::create(StringRef Name, VariantKind Kind,
173 return create(Ctx.getOrCreateSymbol(Name), Kind, Ctx);
176 StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
178 case VK_Invalid: return "<<invalid>>";
179 case VK_None: return "<<none>>";
181 case VK_GOT: return "GOT";
182 case VK_GOTOFF: return "GOTOFF";
183 case VK_GOTPCREL: return "GOTPCREL";
184 case VK_GOTTPOFF: return "GOTTPOFF";
185 case VK_INDNTPOFF: return "INDNTPOFF";
186 case VK_NTPOFF: return "NTPOFF";
187 case VK_GOTNTPOFF: return "GOTNTPOFF";
188 case VK_PLT: return "PLT";
189 case VK_TLSGD: return "TLSGD";
190 case VK_TLSLD: return "TLSLD";
191 case VK_TLSLDM: return "TLSLDM";
192 case VK_TPOFF: return "TPOFF";
193 case VK_DTPOFF: return "DTPOFF";
194 case VK_TLVP: return "TLVP";
195 case VK_TLVPPAGE: return "TLVPPAGE";
196 case VK_TLVPPAGEOFF: return "TLVPPAGEOFF";
197 case VK_PAGE: return "PAGE";
198 case VK_PAGEOFF: return "PAGEOFF";
199 case VK_GOTPAGE: return "GOTPAGE";
200 case VK_GOTPAGEOFF: return "GOTPAGEOFF";
201 case VK_SECREL: return "SECREL32";
202 case VK_SIZE: return "SIZE";
203 case VK_WEAKREF: return "WEAKREF";
204 case VK_ARM_NONE: return "none";
205 case VK_ARM_TARGET1: return "target1";
206 case VK_ARM_TARGET2: return "target2";
207 case VK_ARM_PREL31: return "prel31";
208 case VK_ARM_SBREL: return "sbrel";
209 case VK_ARM_TLSLDO: return "tlsldo";
210 case VK_ARM_TLSCALL: return "tlscall";
211 case VK_ARM_TLSDESC: return "tlsdesc";
212 case VK_ARM_TLSDESCSEQ: return "tlsdescseq";
213 case VK_PPC_LO: return "l";
214 case VK_PPC_HI: return "h";
215 case VK_PPC_HA: return "ha";
216 case VK_PPC_HIGHER: return "higher";
217 case VK_PPC_HIGHERA: return "highera";
218 case VK_PPC_HIGHEST: return "highest";
219 case VK_PPC_HIGHESTA: return "highesta";
220 case VK_PPC_GOT_LO: return "got@l";
221 case VK_PPC_GOT_HI: return "got@h";
222 case VK_PPC_GOT_HA: return "got@ha";
223 case VK_PPC_TOCBASE: return "tocbase";
224 case VK_PPC_TOC: return "toc";
225 case VK_PPC_TOC_LO: return "toc@l";
226 case VK_PPC_TOC_HI: return "toc@h";
227 case VK_PPC_TOC_HA: return "toc@ha";
228 case VK_PPC_DTPMOD: return "dtpmod";
229 case VK_PPC_TPREL: return "tprel";
230 case VK_PPC_TPREL_LO: return "tprel@l";
231 case VK_PPC_TPREL_HI: return "tprel@h";
232 case VK_PPC_TPREL_HA: return "tprel@ha";
233 case VK_PPC_TPREL_HIGHER: return "tprel@higher";
234 case VK_PPC_TPREL_HIGHERA: return "tprel@highera";
235 case VK_PPC_TPREL_HIGHEST: return "tprel@highest";
236 case VK_PPC_TPREL_HIGHESTA: return "tprel@highesta";
237 case VK_PPC_DTPREL: return "dtprel";
238 case VK_PPC_DTPREL_LO: return "dtprel@l";
239 case VK_PPC_DTPREL_HI: return "dtprel@h";
240 case VK_PPC_DTPREL_HA: return "dtprel@ha";
241 case VK_PPC_DTPREL_HIGHER: return "dtprel@higher";
242 case VK_PPC_DTPREL_HIGHERA: return "dtprel@highera";
243 case VK_PPC_DTPREL_HIGHEST: return "dtprel@highest";
244 case VK_PPC_DTPREL_HIGHESTA: return "dtprel@highesta";
245 case VK_PPC_GOT_TPREL: return "got@tprel";
246 case VK_PPC_GOT_TPREL_LO: return "got@tprel@l";
247 case VK_PPC_GOT_TPREL_HI: return "got@tprel@h";
248 case VK_PPC_GOT_TPREL_HA: return "got@tprel@ha";
249 case VK_PPC_GOT_DTPREL: return "got@dtprel";
250 case VK_PPC_GOT_DTPREL_LO: return "got@dtprel@l";
251 case VK_PPC_GOT_DTPREL_HI: return "got@dtprel@h";
252 case VK_PPC_GOT_DTPREL_HA: return "got@dtprel@ha";
253 case VK_PPC_TLS: return "tls";
254 case VK_PPC_GOT_TLSGD: return "got@tlsgd";
255 case VK_PPC_GOT_TLSGD_LO: return "got@tlsgd@l";
256 case VK_PPC_GOT_TLSGD_HI: return "got@tlsgd@h";
257 case VK_PPC_GOT_TLSGD_HA: return "got@tlsgd@ha";
258 case VK_PPC_TLSGD: return "tlsgd";
259 case VK_PPC_GOT_TLSLD: return "got@tlsld";
260 case VK_PPC_GOT_TLSLD_LO: return "got@tlsld@l";
261 case VK_PPC_GOT_TLSLD_HI: return "got@tlsld@h";
262 case VK_PPC_GOT_TLSLD_HA: return "got@tlsld@ha";
263 case VK_PPC_TLSLD: return "tlsld";
264 case VK_PPC_LOCAL: return "local";
265 case VK_Mips_GPREL: return "GPREL";
266 case VK_Mips_GOT_CALL: return "GOT_CALL";
267 case VK_Mips_GOT16: return "GOT16";
268 case VK_Mips_GOT: return "GOT";
269 case VK_Mips_ABS_HI: return "ABS_HI";
270 case VK_Mips_ABS_LO: return "ABS_LO";
271 case VK_Mips_TLSGD: return "TLSGD";
272 case VK_Mips_TLSLDM: return "TLSLDM";
273 case VK_Mips_DTPREL_HI: return "DTPREL_HI";
274 case VK_Mips_DTPREL_LO: return "DTPREL_LO";
275 case VK_Mips_GOTTPREL: return "GOTTPREL";
276 case VK_Mips_TPREL_HI: return "TPREL_HI";
277 case VK_Mips_TPREL_LO: return "TPREL_LO";
278 case VK_Mips_GPOFF_HI: return "GPOFF_HI";
279 case VK_Mips_GPOFF_LO: return "GPOFF_LO";
280 case VK_Mips_GOT_DISP: return "GOT_DISP";
281 case VK_Mips_GOT_PAGE: return "GOT_PAGE";
282 case VK_Mips_GOT_OFST: return "GOT_OFST";
283 case VK_Mips_HIGHER: return "HIGHER";
284 case VK_Mips_HIGHEST: return "HIGHEST";
285 case VK_Mips_GOT_HI16: return "GOT_HI16";
286 case VK_Mips_GOT_LO16: return "GOT_LO16";
287 case VK_Mips_CALL_HI16: return "CALL_HI16";
288 case VK_Mips_CALL_LO16: return "CALL_LO16";
289 case VK_Mips_PCREL_HI16: return "PCREL_HI16";
290 case VK_Mips_PCREL_LO16: return "PCREL_LO16";
291 case VK_COFF_IMGREL32: return "IMGREL";
292 case VK_Hexagon_PCREL: return "PCREL";
293 case VK_Hexagon_LO16: return "LO16";
294 case VK_Hexagon_HI16: return "HI16";
295 case VK_Hexagon_GPREL: return "GPREL";
296 case VK_Hexagon_GD_GOT: return "GDGOT";
297 case VK_Hexagon_LD_GOT: return "LDGOT";
298 case VK_Hexagon_GD_PLT: return "GDPLT";
299 case VK_Hexagon_LD_PLT: return "LDPLT";
300 case VK_Hexagon_IE: return "IE";
301 case VK_Hexagon_IE_GOT: return "IEGOT";
302 case VK_TPREL: return "tprel";
303 case VK_DTPREL: return "dtprel";
305 llvm_unreachable("Invalid variant kind");
308 MCSymbolRefExpr::VariantKind
309 MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
310 return StringSwitch<VariantKind>(Name.lower())
312 .Case("gotoff", VK_GOTOFF)
313 .Case("gotpcrel", VK_GOTPCREL)
314 .Case("got_prel", VK_GOTPCREL)
315 .Case("gottpoff", VK_GOTTPOFF)
316 .Case("indntpoff", VK_INDNTPOFF)
317 .Case("ntpoff", VK_NTPOFF)
318 .Case("gotntpoff", VK_GOTNTPOFF)
320 .Case("tlsgd", VK_TLSGD)
321 .Case("tlsld", VK_TLSLD)
322 .Case("tlsldm", VK_TLSLDM)
323 .Case("tpoff", VK_TPOFF)
324 .Case("dtpoff", VK_DTPOFF)
325 .Case("tlvp", VK_TLVP)
326 .Case("tlvppage", VK_TLVPPAGE)
327 .Case("tlvppageoff", VK_TLVPPAGEOFF)
328 .Case("page", VK_PAGE)
329 .Case("pageoff", VK_PAGEOFF)
330 .Case("gotpage", VK_GOTPAGE)
331 .Case("gotpageoff", VK_GOTPAGEOFF)
332 .Case("imgrel", VK_COFF_IMGREL32)
333 .Case("secrel32", VK_SECREL)
334 .Case("size", VK_SIZE)
335 .Case("l", VK_PPC_LO)
336 .Case("h", VK_PPC_HI)
337 .Case("ha", VK_PPC_HA)
338 .Case("higher", VK_PPC_HIGHER)
339 .Case("highera", VK_PPC_HIGHERA)
340 .Case("highest", VK_PPC_HIGHEST)
341 .Case("highesta", VK_PPC_HIGHESTA)
342 .Case("got@l", VK_PPC_GOT_LO)
343 .Case("got@h", VK_PPC_GOT_HI)
344 .Case("got@ha", VK_PPC_GOT_HA)
345 .Case("local", VK_PPC_LOCAL)
346 .Case("tocbase", VK_PPC_TOCBASE)
347 .Case("toc", VK_PPC_TOC)
348 .Case("toc@l", VK_PPC_TOC_LO)
349 .Case("toc@h", VK_PPC_TOC_HI)
350 .Case("toc@ha", VK_PPC_TOC_HA)
351 .Case("tls", VK_PPC_TLS)
352 .Case("dtpmod", VK_PPC_DTPMOD)
353 .Case("tprel", VK_PPC_TPREL)
354 .Case("tprel@l", VK_PPC_TPREL_LO)
355 .Case("tprel@h", VK_PPC_TPREL_HI)
356 .Case("tprel@ha", VK_PPC_TPREL_HA)
357 .Case("tprel@higher", VK_PPC_TPREL_HIGHER)
358 .Case("tprel@highera", VK_PPC_TPREL_HIGHERA)
359 .Case("tprel@highest", VK_PPC_TPREL_HIGHEST)
360 .Case("tprel@highesta", VK_PPC_TPREL_HIGHESTA)
361 .Case("dtprel", VK_PPC_DTPREL)
362 .Case("dtprel@l", VK_PPC_DTPREL_LO)
363 .Case("dtprel@h", VK_PPC_DTPREL_HI)
364 .Case("dtprel@ha", VK_PPC_DTPREL_HA)
365 .Case("dtprel@higher", VK_PPC_DTPREL_HIGHER)
366 .Case("dtprel@highera", VK_PPC_DTPREL_HIGHERA)
367 .Case("dtprel@highest", VK_PPC_DTPREL_HIGHEST)
368 .Case("dtprel@highesta", VK_PPC_DTPREL_HIGHESTA)
369 .Case("got@tprel", VK_PPC_GOT_TPREL)
370 .Case("got@tprel@l", VK_PPC_GOT_TPREL_LO)
371 .Case("got@tprel@h", VK_PPC_GOT_TPREL_HI)
372 .Case("got@tprel@ha", VK_PPC_GOT_TPREL_HA)
373 .Case("got@dtprel", VK_PPC_GOT_DTPREL)
374 .Case("got@dtprel@l", VK_PPC_GOT_DTPREL_LO)
375 .Case("got@dtprel@h", VK_PPC_GOT_DTPREL_HI)
376 .Case("got@dtprel@ha", VK_PPC_GOT_DTPREL_HA)
377 .Case("got@tlsgd", VK_PPC_GOT_TLSGD)
378 .Case("got@tlsgd@l", VK_PPC_GOT_TLSGD_LO)
379 .Case("got@tlsgd@h", VK_PPC_GOT_TLSGD_HI)
380 .Case("got@tlsgd@ha", VK_PPC_GOT_TLSGD_HA)
381 .Case("got@tlsld", VK_PPC_GOT_TLSLD)
382 .Case("got@tlsld@l", VK_PPC_GOT_TLSLD_LO)
383 .Case("got@tlsld@h", VK_PPC_GOT_TLSLD_HI)
384 .Case("got@tlsld@ha", VK_PPC_GOT_TLSLD_HA)
385 .Case("none", VK_ARM_NONE)
386 .Case("target1", VK_ARM_TARGET1)
387 .Case("target2", VK_ARM_TARGET2)
388 .Case("prel31", VK_ARM_PREL31)
389 .Case("sbrel", VK_ARM_SBREL)
390 .Case("tlsldo", VK_ARM_TLSLDO)
391 .Case("tlscall", VK_ARM_TLSCALL)
392 .Case("tlsdesc", VK_ARM_TLSDESC)
393 .Default(VK_Invalid);
396 void MCSymbolRefExpr::printVariantKind(raw_ostream &OS) const {
397 if (UseParensForSymbolVariant)
398 OS << '(
' << MCSymbolRefExpr::getVariantKindName(getKind()) << ')
';
400 OS << '@
' << MCSymbolRefExpr::getVariantKindName(getKind());
405 void MCTargetExpr::anchor() {}
409 bool MCExpr::evaluateAsAbsolute(int64_t &Res) const {
410 return evaluateAsAbsolute(Res, nullptr, nullptr, nullptr);
413 bool MCExpr::evaluateAsAbsolute(int64_t &Res,
414 const MCAsmLayout &Layout) const {
415 return evaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, nullptr);
418 bool MCExpr::evaluateAsAbsolute(int64_t &Res,
419 const MCAsmLayout &Layout,
420 const SectionAddrMap &Addrs) const {
421 return evaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, &Addrs);
424 bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const {
425 return evaluateAsAbsolute(Res, &Asm, nullptr, nullptr);
428 bool MCExpr::evaluateKnownAbsolute(int64_t &Res,
429 const MCAsmLayout &Layout) const {
430 return evaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, nullptr,
434 bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
435 const MCAsmLayout *Layout,
436 const SectionAddrMap *Addrs) const {
437 // FIXME: The use if InSet = Addrs is a hack. Setting InSet causes us
438 // absolutize differences across sections and that is what the MachO writer
440 return evaluateAsAbsolute(Res, Asm, Layout, Addrs, Addrs);
443 bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
444 const MCAsmLayout *Layout,
445 const SectionAddrMap *Addrs, bool InSet) const {
448 // Fast path constants.
449 if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(this)) {
450 Res = CE->getValue();
455 evaluateAsRelocatableImpl(Value, Asm, Layout, nullptr, Addrs, InSet);
457 // Record the current value.
458 Res = Value.getConstant();
460 return IsRelocatable && Value.isAbsolute();
464 static void AttemptToFoldSymbolOffsetDifference(
465 const MCAssembler *Asm, const MCAsmLayout *Layout,
466 const SectionAddrMap *Addrs, bool InSet, const MCSymbolRefExpr *&A,
467 const MCSymbolRefExpr *&B, int64_t &Addend) {
471 const MCSymbol &SA = A->getSymbol();
472 const MCSymbol &SB = B->getSymbol();
474 if (SA.isUndefined() || SB.isUndefined())
477 if (!Asm->getWriter().isSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
480 if (SA.getFragment() == SB.getFragment()) {
481 Addend += (SA.getOffset() - SB.getOffset());
483 // Pointers to Thumb symbols need to have their low-bit set to allow
485 if (Asm->isThumbFunc(&SA))
488 // Clear the symbol expr pointers to indicate we have folded these
497 const MCSection &SecA = *SA.getFragment()->getParent();
498 const MCSection &SecB = *SB.getFragment()->getParent();
500 if ((&SecA != &SecB) && !Addrs)
504 Addend += Layout->getSymbolOffset(A->getSymbol()) -
505 Layout->getSymbolOffset(B->getSymbol());
506 if (Addrs && (&SecA != &SecB))
507 Addend += (Addrs->lookup(&SecA) - Addrs->lookup(&SecB));
509 // Pointers to Thumb symbols need to have their low-bit set to allow
511 if (Asm->isThumbFunc(&SA))
514 // Clear the symbol expr pointers to indicate we have folded these
539 EvaluateSymbolicAdd(const MCAssembler *Asm, const MCAsmLayout *Layout,
540 const SectionAddrMap *Addrs, bool InSet, const MCValue &LHS,
541 const MCSymbolRefExpr *RHS_A, const MCSymbolRefExpr *RHS_B,
542 int64_t RHS_Cst, MCValue &Res) {
543 // FIXME: This routine (and other evaluation parts) are *incredibly* sloppy
544 // about dealing with modifiers. This will ultimately bite us, one day.
545 const MCSymbolRefExpr *LHS_A = LHS.getSymA();
546 const MCSymbolRefExpr *LHS_B = LHS.getSymB();
547 int64_t LHS_Cst = LHS.getConstant();
549 // Fold the result constant immediately.
550 int64_t Result_Cst = LHS_Cst + RHS_Cst;
552 assert((!Layout || Asm) &&
553 "Must have an assembler object if layout is given!");
555 // If we have a layout, we can fold resolved differences.
557 // First, fold out any differences which are fully resolved. By
558 // reassociating terms in
559 // Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst).
560 // we have the four possible differences:
565 // Since we are attempting to be as aggressive as possible about folding, we
566 // attempt to evaluate each possible alternative.
567 AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, LHS_A, LHS_B,
569 AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, LHS_A, RHS_B,
571 AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, RHS_A, LHS_B,
573 AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, RHS_A, RHS_B,
577 // We can't represent the addition or subtraction of two symbols.
578 if ((LHS_A && RHS_A) || (LHS_B && RHS_B))
629 ++stats::MCExprEvaluate;
637 Res =
MCValue::get(cast<MCConstantExpr>(
this)->getValue());
648 if (Sym.getVariableValue()->evaluateAsRelocatableImpl(
649 Res, Asm, Layout, Fixup, Addrs, InSet || IsMachO)) {
680 if (!Value.isAbsolute())
686 if (Value.getSymA() && !Value.getSymB())
689 -Value.getConstant());
692 if (!Value.isAbsolute())
716 if (!LHSValue.isAbsolute() || !RHSValue.isAbsolute()) {
723 RHSValue.getSymB(), RHSValue.getSymA(),
724 -RHSValue.getConstant(), Res);
728 RHSValue.getSymA(), RHSValue.getSymB(),
729 RHSValue.getConstant(), Res);
736 int64_t LHS = LHSValue.getConstant(), RHS = RHSValue.getConstant();
788 return cast<MCUnaryExpr>(
this)->getSubExpr()->findAssociatedSection();
806 return LHS_S ? LHS_S : RHS_S;
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Signed less than comparison (result is either 0 or some target-specific non-zero value).
virtual bool isWeak(const MCSymbol &Sym) const
True if this symbol (which is a variable) is weak.
const MCSymbol & getSymbol() const
STATISTIC(NumFunctions,"Total number of functions")
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Signed less than or equal comparison (result is either 0 or some target-specific non-zero value)...
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void printVariantKind(raw_ostream &OS) const
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Encapsulates the layout of an assembly file at a particular point in time.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCExpr * getVariableValue() const
getVariableValue() - Get the value for variable symbols.
Base class for the full range of assembler expressions which are needed for parsing.
Represent a reference to a symbol from inside an expression.
static bool canExpand(const MCSymbol &Sym, const MCAssembler *Asm, bool InSet)
MCObjectWriter & getWriter() const
Unary assembler expressions.
This class is intended to be used as a base class for asm properties and features specific to the tar...
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const
This is an important base class in LLVM.
static bool EvaluateSymbolicAdd(const MCAssembler *Asm, const MCAsmLayout *Layout, const SectionAddrMap *Addrs, bool InSet, const MCValue &LHS, const MCSymbolRefExpr *RHS_A, const MCSymbolRefExpr *RHS_B, int64_t RHS_Cst, MCValue &Res)
Evaluate the result of an add between (conceptually) two MCValues.
bool evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const
Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables...
MCSection * findAssociatedSection() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
const MCSymbolRefExpr * getSymB() const
Binary assembler expressions.
PowerPC TLS Dynamic Call Fixup
const MCSymbolRefExpr * getSymA() const
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
bool hasSubsectionsViaSymbols() const
static MCSection * AbsolutePseudoSection
Signed greater than comparison (result is either 0 or some target-specific non-zero value) ...
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Signed greater than or equal comparison (result is either 0 or some target-specific non-zero value)...
Target - Wrapper for Target specific information.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
This is a value type class that represents a single symbol in the list of symbols in the object file...
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
const MCExpr * getSubExpr() const
Get the child of this unary expression.
StringRef getName() const
getName - Get the symbol name.
static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=nullptr, int64_t Val=0, uint32_t RefKind=0)
Opcode getOpcode() const
Get the kind of this binary expression.
References to labels and assigned expressions.
VariantKind getKind() const
LLVM Value Representation.
MCAssembler & getAssembler() const
Get the assembler object this is a layout for.
This class implements an extremely fast bulk output stream that can only output to a stream...
Target specific expression.
Opcode getOpcode() const
Get the kind of this unary expression.