Fixed version of 122160 (the previous one would fold undefined symbols).
[oota-llvm.git] / lib / MC / MCExpr.cpp
1 //===- MCExpr.cpp - Assembly Level Expression Implementation --------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #define DEBUG_TYPE "mcexpr"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/ADT/Statistic.h"
13 #include "llvm/ADT/StringSwitch.h"
14 #include "llvm/MC/MCAsmLayout.h"
15 #include "llvm/MC/MCAssembler.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCSymbol.h"
18 #include "llvm/MC/MCValue.h"
19 #include "llvm/Support/Debug.h"
20 #include "llvm/Support/raw_ostream.h"
21 #include "llvm/Target/TargetAsmBackend.h"
22 using namespace llvm;
23
24 namespace {
25 namespace stats {
26 STATISTIC(MCExprEvaluate, "Number of MCExpr evaluations");
27 }
28 }
29
30 void MCExpr::print(raw_ostream &OS) const {
31   switch (getKind()) {
32   case MCExpr::Target:
33     return cast<MCTargetExpr>(this)->PrintImpl(OS);
34   case MCExpr::Constant:
35     OS << cast<MCConstantExpr>(*this).getValue();
36     return;
37
38   case MCExpr::SymbolRef: {
39     const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*this);
40     const MCSymbol &Sym = SRE.getSymbol();
41     // Parenthesize names that start with $ so that they don't look like
42     // absolute names.
43     bool UseParens = Sym.getName()[0] == '$';
44
45     if (SRE.getKind() == MCSymbolRefExpr::VK_ARM_HI16 ||
46         SRE.getKind() == MCSymbolRefExpr::VK_ARM_LO16)
47       OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
48
49     if (SRE.getKind() == MCSymbolRefExpr::VK_PPC_HA16 ||
50         SRE.getKind() == MCSymbolRefExpr::VK_PPC_LO16) {
51       OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
52       UseParens = true;
53     }
54
55     if (UseParens)
56       OS << '(' << Sym << ')';
57     else
58       OS << Sym;
59
60     if (SRE.getKind() == MCSymbolRefExpr::VK_ARM_PLT ||
61         SRE.getKind() == MCSymbolRefExpr::VK_ARM_TLSGD ||
62         SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOT ||
63         SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTOFF ||
64         SRE.getKind() == MCSymbolRefExpr::VK_ARM_TPOFF ||
65         SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTTPOFF)
66       OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
67     else if (SRE.getKind() != MCSymbolRefExpr::VK_None &&
68              SRE.getKind() != MCSymbolRefExpr::VK_ARM_HI16 &&
69              SRE.getKind() != MCSymbolRefExpr::VK_ARM_LO16 &&
70              SRE.getKind() != MCSymbolRefExpr::VK_PPC_HA16 &&
71              SRE.getKind() != MCSymbolRefExpr::VK_PPC_LO16)
72       OS << '@' << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
73
74     return;
75   }
76
77   case MCExpr::Unary: {
78     const MCUnaryExpr &UE = cast<MCUnaryExpr>(*this);
79     switch (UE.getOpcode()) {
80     default: assert(0 && "Invalid opcode!");
81     case MCUnaryExpr::LNot:  OS << '!'; break;
82     case MCUnaryExpr::Minus: OS << '-'; break;
83     case MCUnaryExpr::Not:   OS << '~'; break;
84     case MCUnaryExpr::Plus:  OS << '+'; break;
85     }
86     OS << *UE.getSubExpr();
87     return;
88   }
89
90   case MCExpr::Binary: {
91     const MCBinaryExpr &BE = cast<MCBinaryExpr>(*this);
92
93     // Only print parens around the LHS if it is non-trivial.
94     if (isa<MCConstantExpr>(BE.getLHS()) || isa<MCSymbolRefExpr>(BE.getLHS())) {
95       OS << *BE.getLHS();
96     } else {
97       OS << '(' << *BE.getLHS() << ')';
98     }
99
100     switch (BE.getOpcode()) {
101     default: assert(0 && "Invalid opcode!");
102     case MCBinaryExpr::Add:
103       // Print "X-42" instead of "X+-42".
104       if (const MCConstantExpr *RHSC = dyn_cast<MCConstantExpr>(BE.getRHS())) {
105         if (RHSC->getValue() < 0) {
106           OS << RHSC->getValue();
107           return;
108         }
109       }
110
111       OS <<  '+';
112       break;
113     case MCBinaryExpr::And:  OS <<  '&'; break;
114     case MCBinaryExpr::Div:  OS <<  '/'; break;
115     case MCBinaryExpr::EQ:   OS << "=="; break;
116     case MCBinaryExpr::GT:   OS <<  '>'; break;
117     case MCBinaryExpr::GTE:  OS << ">="; break;
118     case MCBinaryExpr::LAnd: OS << "&&"; break;
119     case MCBinaryExpr::LOr:  OS << "||"; break;
120     case MCBinaryExpr::LT:   OS <<  '<'; break;
121     case MCBinaryExpr::LTE:  OS << "<="; break;
122     case MCBinaryExpr::Mod:  OS <<  '%'; break;
123     case MCBinaryExpr::Mul:  OS <<  '*'; break;
124     case MCBinaryExpr::NE:   OS << "!="; break;
125     case MCBinaryExpr::Or:   OS <<  '|'; break;
126     case MCBinaryExpr::Shl:  OS << "<<"; break;
127     case MCBinaryExpr::Shr:  OS << ">>"; break;
128     case MCBinaryExpr::Sub:  OS <<  '-'; break;
129     case MCBinaryExpr::Xor:  OS <<  '^'; break;
130     }
131
132     // Only print parens around the LHS if it is non-trivial.
133     if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
134       OS << *BE.getRHS();
135     } else {
136       OS << '(' << *BE.getRHS() << ')';
137     }
138     return;
139   }
140   }
141
142   assert(0 && "Invalid expression kind!");
143 }
144
145 void MCExpr::dump() const {
146   print(dbgs());
147   dbgs() << '\n';
148 }
149
150 /* *** */
151
152 const MCBinaryExpr *MCBinaryExpr::Create(Opcode Opc, const MCExpr *LHS,
153                                          const MCExpr *RHS, MCContext &Ctx) {
154   return new (Ctx) MCBinaryExpr(Opc, LHS, RHS);
155 }
156
157 const MCUnaryExpr *MCUnaryExpr::Create(Opcode Opc, const MCExpr *Expr,
158                                        MCContext &Ctx) {
159   return new (Ctx) MCUnaryExpr(Opc, Expr);
160 }
161
162 const MCConstantExpr *MCConstantExpr::Create(int64_t Value, MCContext &Ctx) {
163   return new (Ctx) MCConstantExpr(Value);
164 }
165
166 /* *** */
167
168 const MCSymbolRefExpr *MCSymbolRefExpr::Create(const MCSymbol *Sym,
169                                                VariantKind Kind,
170                                                MCContext &Ctx) {
171   return new (Ctx) MCSymbolRefExpr(Sym, Kind);
172 }
173
174 const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, VariantKind Kind,
175                                                MCContext &Ctx) {
176   return Create(Ctx.GetOrCreateSymbol(Name), Kind, Ctx);
177 }
178
179 StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
180   switch (Kind) {
181   default:
182   case VK_Invalid: return "<<invalid>>";
183   case VK_None: return "<<none>>";
184
185   case VK_GOT: return "GOT";
186   case VK_GOTOFF: return "GOTOFF";
187   case VK_GOTPCREL: return "GOTPCREL";
188   case VK_GOTTPOFF: return "GOTTPOFF";
189   case VK_INDNTPOFF: return "INDNTPOFF";
190   case VK_NTPOFF: return "NTPOFF";
191   case VK_GOTNTPOFF: return "GOTNTPOFF";
192   case VK_PLT: return "PLT";
193   case VK_TLSGD: return "TLSGD";
194   case VK_TLSLD: return "TLSLD";
195   case VK_TLSLDM: return "TLSLDM";
196   case VK_TPOFF: return "TPOFF";
197   case VK_DTPOFF: return "DTPOFF";
198   case VK_TLVP: return "TLVP";
199   case VK_ARM_HI16: return ":upper16:";
200   case VK_ARM_LO16: return ":lower16:";
201   case VK_ARM_PLT: return "(PLT)";
202   case VK_ARM_GOT: return "(GOT)";
203   case VK_ARM_GOTOFF: return "(GOTOFF)";
204   case VK_ARM_TPOFF: return "(tpoff)";
205   case VK_ARM_GOTTPOFF: return "(gottpoff)";
206   case VK_ARM_TLSGD: return "(tlsgd)";
207   case VK_PPC_TOC: return "toc";
208   case VK_PPC_HA16: return "ha16";
209   case VK_PPC_LO16: return "lo16";
210   }
211 }
212
213 MCSymbolRefExpr::VariantKind
214 MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
215   return StringSwitch<VariantKind>(Name)
216     .Case("GOT", VK_GOT)
217     .Case("GOTOFF", VK_GOTOFF)
218     .Case("GOTPCREL", VK_GOTPCREL)
219     .Case("GOTTPOFF", VK_GOTTPOFF)
220     .Case("INDNTPOFF", VK_INDNTPOFF)
221     .Case("NTPOFF", VK_NTPOFF)
222     .Case("GOTNTPOFF", VK_GOTNTPOFF)
223     .Case("PLT", VK_PLT)
224     .Case("TLSGD", VK_TLSGD)
225     .Case("TLSLD", VK_TLSLD)
226     .Case("TLSLDM", VK_TLSLDM)
227     .Case("TPOFF", VK_TPOFF)
228     .Case("DTPOFF", VK_DTPOFF)
229     .Case("TLVP", VK_TLVP)
230     .Default(VK_Invalid);
231 }
232
233 /* *** */
234
235 void MCTargetExpr::Anchor() {}
236
237 /* *** */
238
239 bool MCExpr::EvaluateAsAbsolute(int64_t &Res) const {
240   return EvaluateAsAbsolute(Res, 0, 0, 0);
241 }
242
243 bool MCExpr::EvaluateAsAbsolute(int64_t &Res,
244                                 const MCAsmLayout &Layout) const {
245   return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, 0);
246 }
247
248 bool MCExpr::EvaluateAsAbsolute(int64_t &Res,
249                                 const MCAsmLayout &Layout,
250                                 const SectionAddrMap &Addrs) const {
251   return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, &Addrs);
252 }
253
254 bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const {
255   return EvaluateAsAbsolute(Res, &Asm, 0, 0);
256 }
257
258 bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
259                                 const MCAsmLayout *Layout,
260                                 const SectionAddrMap *Addrs) const {
261   MCValue Value;
262
263   // Fast path constants.
264   if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(this)) {
265     Res = CE->getValue();
266     return true;
267   }
268
269   // FIXME: The use if InSet = Addrs is a hack. Setting InSet causes us
270   // absolutize differences across sections and that is what the MachO writer
271   // uses Addrs for.
272   if (!EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs) ||
273       !Value.isAbsolute()) {
274     // EvaluateAsAbsolute is defined to return the "current value" of
275     // the expression if we are given a Layout object, even in cases
276     // when the value is not fixed.
277     if (Layout) {
278       Res = Value.getConstant();
279       if (Value.getSymA()) {
280        Res += Layout->getSymbolOffset(
281           &Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol()));
282       }
283       if (Value.getSymB()) {
284        Res -= Layout->getSymbolOffset(
285           &Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol()));
286       }
287     }
288     return false;
289   }
290
291   Res = Value.getConstant();
292   return true;
293 }
294
295 /// \brief Helper method for \see EvaluateSymbolAdd().
296 static void AttemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
297                                                 const MCAsmLayout *Layout,
298                                                 const SectionAddrMap *Addrs,
299                                                 bool InSet,
300                                                 const MCSymbolRefExpr *&A,
301                                                 const MCSymbolRefExpr *&B,
302                                                 int64_t &Addend) {
303   if (!A || !B)
304     return;
305
306   const MCSymbol &SA = A->getSymbol();
307   const MCSymbol &SB = B->getSymbol();
308
309   if (SA.isUndefined() || SB.isUndefined())
310     return;
311
312   if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
313     return;
314
315   MCSymbolData &AD = Asm->getSymbolData(SA);
316   MCSymbolData &BD = Asm->getSymbolData(SB);
317
318   if (AD.getFragment() == BD.getFragment()) {
319     Addend += (AD.getOffset() - BD.getOffset());
320
321     // Clear the symbol expr pointers to indicate we have folded these
322     // operands.
323     A = B = 0;
324     return;
325   }
326
327   if (!Layout)
328     return;
329
330   const MCSectionData &SecA = *AD.getFragment()->getParent();
331   const MCSectionData &SecB = *BD.getFragment()->getParent();
332
333   if ((&SecA != &SecB) && !Addrs)
334     return;
335
336   // Eagerly evaluate.
337   Addend += (Layout->getSymbolOffset(&Asm->getSymbolData(A->getSymbol())) -
338              Layout->getSymbolOffset(&Asm->getSymbolData(B->getSymbol())));
339   if (Addrs && (&SecA != &SecB))
340     Addend += (Addrs->lookup(&SecA) - Addrs->lookup(&SecB));
341
342   // Clear the symbol expr pointers to indicate we have folded these
343   // operands.
344   A = B = 0;
345 }
346
347 /// \brief Evaluate the result of an add between (conceptually) two MCValues.
348 ///
349 /// This routine conceptually attempts to construct an MCValue:
350 ///   Result = (Result_A - Result_B + Result_Cst)
351 /// from two MCValue's LHS and RHS where
352 ///   Result = LHS + RHS
353 /// and
354 ///   Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst).
355 ///
356 /// This routine attempts to aggresively fold the operands such that the result
357 /// is representable in an MCValue, but may not always succeed.
358 ///
359 /// \returns True on success, false if the result is not representable in an
360 /// MCValue.
361
362 /// NOTE: It is really important to have both the Asm and Layout arguments.
363 /// They might look redundant, but this function can be used before layout
364 /// is done (see the object streamer for example) and having the Asm argument
365 /// lets us avoid relaxations early.
366 static bool EvaluateSymbolicAdd(const MCAssembler *Asm,
367                                 const MCAsmLayout *Layout,
368                                 const SectionAddrMap *Addrs,
369                                 bool InSet,
370                                 const MCValue &LHS,const MCSymbolRefExpr *RHS_A,
371                                 const MCSymbolRefExpr *RHS_B, int64_t RHS_Cst,
372                                 MCValue &Res) {
373   // FIXME: This routine (and other evaluation parts) are *incredibly* sloppy
374   // about dealing with modifiers. This will ultimately bite us, one day.
375   const MCSymbolRefExpr *LHS_A = LHS.getSymA();
376   const MCSymbolRefExpr *LHS_B = LHS.getSymB();
377   int64_t LHS_Cst = LHS.getConstant();
378
379   // Fold the result constant immediately.
380   int64_t Result_Cst = LHS_Cst + RHS_Cst;
381
382   assert((!Layout || Asm) &&
383          "Must have an assembler object if layout is given!");
384
385   // If we have a layout, we can fold resolved differences.
386   if (Asm) {
387     // First, fold out any differences which are fully resolved. By
388     // reassociating terms in
389     //   Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst).
390     // we have the four possible differences:
391     //   (LHS_A - LHS_B),
392     //   (LHS_A - RHS_B),
393     //   (RHS_A - LHS_B),
394     //   (RHS_A - RHS_B).
395     // Since we are attempting to be as aggresive as possible about folding, we
396     // attempt to evaluate each possible alternative.
397     AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, LHS_A, LHS_B,
398                                         Result_Cst);
399     AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, LHS_A, RHS_B,
400                                         Result_Cst);
401     AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, RHS_A, LHS_B,
402                                         Result_Cst);
403     AttemptToFoldSymbolOffsetDifference(Asm, Layout, Addrs, InSet, RHS_A, RHS_B,
404                                         Result_Cst);
405   }
406
407   // We can't represent the addition or subtraction of two symbols.
408   if ((LHS_A && RHS_A) || (LHS_B && RHS_B))
409     return false;
410
411   // At this point, we have at most one additive symbol and one subtractive
412   // symbol -- find them.
413   const MCSymbolRefExpr *A = LHS_A ? LHS_A : RHS_A;
414   const MCSymbolRefExpr *B = LHS_B ? LHS_B : RHS_B;
415
416   // If we have a negated symbol, then we must have also have a non-negated
417   // symbol in order to encode the expression.
418   if (B && !A)
419     return false;
420
421   Res = MCValue::get(A, B, Result_Cst);
422   return true;
423 }
424
425 bool MCExpr::EvaluateAsRelocatable(MCValue &Res,
426                                    const MCAsmLayout *Layout) const {
427   if (Layout)
428     return EvaluateAsRelocatableImpl(Res, &Layout->getAssembler(), Layout,
429                                      0, false);
430   else
431     return EvaluateAsRelocatableImpl(Res, 0, 0, 0, false);
432 }
433
434 bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res,
435                                        const MCAssembler *Asm,
436                                        const MCAsmLayout *Layout,
437                                        const SectionAddrMap *Addrs,
438                                        bool InSet) const {
439   ++stats::MCExprEvaluate;
440
441   switch (getKind()) {
442   case Target:
443     return cast<MCTargetExpr>(this)->EvaluateAsRelocatableImpl(Res, Layout);
444
445   case Constant:
446     Res = MCValue::get(cast<MCConstantExpr>(this)->getValue());
447     return true;
448
449   case SymbolRef: {
450     const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(this);
451     const MCSymbol &Sym = SRE->getSymbol();
452
453     // Evaluate recursively if this is a variable.
454     if (Sym.isVariable() && SRE->getKind() == MCSymbolRefExpr::VK_None) {
455       bool Ret = Sym.getVariableValue()->EvaluateAsRelocatableImpl(Res, Asm,
456                                                                    Layout,
457                                                                    Addrs,
458                                                                    true);
459       // If we failed to simplify this to a constant, let the target
460       // handle it.
461       if (Ret && !Res.getSymA() && !Res.getSymB())
462         return true;
463     }
464
465     Res = MCValue::get(SRE, 0, 0);
466     return true;
467   }
468
469   case Unary: {
470     const MCUnaryExpr *AUE = cast<MCUnaryExpr>(this);
471     MCValue Value;
472
473     if (!AUE->getSubExpr()->EvaluateAsRelocatableImpl(Value, Asm, Layout,
474                                                       Addrs, InSet))
475       return false;
476
477     switch (AUE->getOpcode()) {
478     case MCUnaryExpr::LNot:
479       if (!Value.isAbsolute())
480         return false;
481       Res = MCValue::get(!Value.getConstant());
482       break;
483     case MCUnaryExpr::Minus:
484       /// -(a - b + const) ==> (b - a - const)
485       if (Value.getSymA() && !Value.getSymB())
486         return false;
487       Res = MCValue::get(Value.getSymB(), Value.getSymA(),
488                          -Value.getConstant());
489       break;
490     case MCUnaryExpr::Not:
491       if (!Value.isAbsolute())
492         return false;
493       Res = MCValue::get(~Value.getConstant());
494       break;
495     case MCUnaryExpr::Plus:
496       Res = Value;
497       break;
498     }
499
500     return true;
501   }
502
503   case Binary: {
504     const MCBinaryExpr *ABE = cast<MCBinaryExpr>(this);
505     MCValue LHSValue, RHSValue;
506
507     if (!ABE->getLHS()->EvaluateAsRelocatableImpl(LHSValue, Asm, Layout,
508                                                   Addrs, InSet) ||
509         !ABE->getRHS()->EvaluateAsRelocatableImpl(RHSValue, Asm, Layout,
510                                                   Addrs, InSet))
511       return false;
512
513     // We only support a few operations on non-constant expressions, handle
514     // those first.
515     if (!LHSValue.isAbsolute() || !RHSValue.isAbsolute()) {
516       switch (ABE->getOpcode()) {
517       default:
518         return false;
519       case MCBinaryExpr::Sub:
520         // Negate RHS and add.
521         return EvaluateSymbolicAdd(Asm, Layout, Addrs, InSet, LHSValue,
522                                    RHSValue.getSymB(), RHSValue.getSymA(),
523                                    -RHSValue.getConstant(),
524                                    Res);
525
526       case MCBinaryExpr::Add:
527         return EvaluateSymbolicAdd(Asm, Layout, Addrs, InSet, LHSValue,
528                                    RHSValue.getSymA(), RHSValue.getSymB(),
529                                    RHSValue.getConstant(),
530                                    Res);
531       }
532     }
533
534     // FIXME: We need target hooks for the evaluation. It may be limited in
535     // width, and gas defines the result of comparisons and right shifts
536     // differently from Apple as.
537     int64_t LHS = LHSValue.getConstant(), RHS = RHSValue.getConstant();
538     int64_t Result = 0;
539     switch (ABE->getOpcode()) {
540     case MCBinaryExpr::Add:  Result = LHS + RHS; break;
541     case MCBinaryExpr::And:  Result = LHS & RHS; break;
542     case MCBinaryExpr::Div:  Result = LHS / RHS; break;
543     case MCBinaryExpr::EQ:   Result = LHS == RHS; break;
544     case MCBinaryExpr::GT:   Result = LHS > RHS; break;
545     case MCBinaryExpr::GTE:  Result = LHS >= RHS; break;
546     case MCBinaryExpr::LAnd: Result = LHS && RHS; break;
547     case MCBinaryExpr::LOr:  Result = LHS || RHS; break;
548     case MCBinaryExpr::LT:   Result = LHS < RHS; break;
549     case MCBinaryExpr::LTE:  Result = LHS <= RHS; break;
550     case MCBinaryExpr::Mod:  Result = LHS % RHS; break;
551     case MCBinaryExpr::Mul:  Result = LHS * RHS; break;
552     case MCBinaryExpr::NE:   Result = LHS != RHS; break;
553     case MCBinaryExpr::Or:   Result = LHS | RHS; break;
554     case MCBinaryExpr::Shl:  Result = LHS << RHS; break;
555     case MCBinaryExpr::Shr:  Result = LHS >> RHS; break;
556     case MCBinaryExpr::Sub:  Result = LHS - RHS; break;
557     case MCBinaryExpr::Xor:  Result = LHS ^ RHS; break;
558     }
559
560     Res = MCValue::get(Result);
561     return true;
562   }
563   }
564
565   assert(0 && "Invalid assembly expression kind!");
566   return false;
567 }