Skip to content

Commit bfce1aa

Browse files
authored
[AMDGPU] MCExpr printing helper with KnownBits support (#95951)
Walks over the MCExpr and uses KnownBits to deduce whether an expression is known and if so, prints said known value. Should support the most common MCExpr cases for AMDGPU metadata.
1 parent 846f790 commit bfce1aa

13 files changed

+611
-237
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,10 @@ void AMDGPUAsmPrinter::emitCommonFunctionComments(
395395
SmallString<128> AMDGPUAsmPrinter::getMCExprStr(const MCExpr *Value) {
396396
SmallString<128> Str;
397397
raw_svector_ostream OSS(Str);
398-
int64_t IVal;
399-
if (Value->evaluateAsAbsolute(IVal)) {
400-
OSS << static_cast<uint64_t>(IVal);
401-
} else {
402-
Value->print(OSS, MAI);
403-
}
398+
auto &Streamer = getTargetStreamer()->getStreamer();
399+
auto &Context = Streamer.getContext();
400+
const MCExpr *New = foldAMDGPUMCExpr(Value, Context);
401+
printAMDGPUMCExpr(New, OSS, MAI);
404402
return Str;
405403
}
406404

0 commit comments

Comments
 (0)