|
15 | 15 | #include "llvm/MC/MCAssembler.h" |
16 | 16 | #include "llvm/MC/MCContext.h" |
17 | 17 | #include "llvm/MC/MCObjectWriter.h" |
| 18 | +#include "llvm/MC/MCStreamer.h" |
18 | 19 | #include "llvm/MC/MCSymbol.h" |
19 | 20 | #include "llvm/MC/MCValue.h" |
20 | 21 | #include "llvm/Support/Casting.h" |
@@ -171,6 +172,9 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, |
171 | 172 | OS << ')'; |
172 | 173 | return; |
173 | 174 | } |
| 175 | + |
| 176 | + case MCExpr::Specifier: |
| 177 | + return cast<MCSpecifierExpr>(this)->printImpl(OS, MAI); |
174 | 178 | } |
175 | 179 |
|
176 | 180 | llvm_unreachable("Invalid expression kind!"); |
@@ -207,6 +211,9 @@ bool MCExpr::isSymbolUsedInExpression(const MCSymbol *Sym) const { |
207 | 211 | static_cast<const MCUnaryExpr *>(this)->getSubExpr(); |
208 | 212 | return SubExpr->isSymbolUsedInExpression(Sym); |
209 | 213 | } |
| 214 | + case MCExpr::Specifier: |
| 215 | + return static_cast<const MCSpecifierExpr *>(this)->isSymbolUsedInExpression( |
| 216 | + Sym); |
210 | 217 | } |
211 | 218 |
|
212 | 219 | llvm_unreachable("Unknown expr kind!"); |
@@ -702,6 +709,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, |
702 | 709 |
|
703 | 710 | return true; |
704 | 711 | } |
| 712 | + case Specifier: |
| 713 | + return cast<MCSpecifierExpr>(this)->evaluateAsRelocatableImpl(Res, Asm); |
705 | 714 | } |
706 | 715 |
|
707 | 716 | llvm_unreachable("Invalid assembly expression kind!"); |
@@ -750,7 +759,21 @@ MCFragment *MCExpr::findAssociatedFragment() const { |
750 | 759 | // Otherwise, return the first non-null fragment. |
751 | 760 | return LHS_F ? LHS_F : RHS_F; |
752 | 761 | } |
| 762 | + |
| 763 | + case Specifier: |
| 764 | + return cast<MCSpecifierExpr>(this)->getSubExpr()->findAssociatedFragment(); |
753 | 765 | } |
754 | 766 |
|
755 | 767 | llvm_unreachable("Invalid assembly expression kind!"); |
756 | 768 | } |
| 769 | + |
| 770 | +MCSpecifierExpr::~MCSpecifierExpr() {} |
| 771 | + |
| 772 | +bool MCSpecifierExpr::evaluateAsRelocatableImpl(MCValue &Res, |
| 773 | + const MCAssembler *Asm) const { |
| 774 | + if (!getSubExpr()->evaluateAsRelocatable(Res, Asm)) |
| 775 | + return false; |
| 776 | + |
| 777 | + Res.setSpecifier(specifier); |
| 778 | + return !Res.getSubSym(); |
| 779 | +} |
0 commit comments