diff options
author | Fangrui Song <i@maskray.me> | 2025-06-15 11:52:43 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-06-15 11:52:43 -0700 |
commit | 72de33a406383cb8555234c40e7b31db593e164f (patch) | |
tree | 347419f946bf791a735f9e260269a54e64f8c0c2 /llvm/lib/MC/MCExpr.cpp | |
parent | 254a92d49a4c1e1f7f747b1c2f1ccbfd7f217880 (diff) | |
download | llvm-72de33a406383cb8555234c40e7b31db593e164f.zip llvm-72de33a406383cb8555234c40e7b31db593e164f.tar.gz llvm-72de33a406383cb8555234c40e7b31db593e164f.tar.bz2 |
MC: Add MCAsmInfo::evaluateAsRelocatableImpl and replace VEMCExpr with MCSpecifierExpr
Expressions with specifier can only be folded during relocation
generatin. At parse time the `MCAssembler *` argument might be null, and
targets should not rely on the evaluateAsRelocatable result.
Therefore, we can move evaluateAsRelocatableImpl from MCSpecifierExpr to
MCAsmInfo, so that targets do not need to inherit from MCSpecifierExpr.
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index e83ce05..5ccad6d 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -680,7 +680,10 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, return true; } case Specifier: - return cast<MCSpecifierExpr>(this)->evaluateAsRelocatableImpl(Res, Asm); + // Fold the expression during relocation generation. As parse time Asm might + // be null, and targets should not rely on the folding. + return Asm && Asm->getContext().getAsmInfo()->evaluateAsRelocatableImpl( + cast<MCSpecifierExpr>(*this), Res, Asm); } llvm_unreachable("Invalid assembly expression kind!"); |