[llvm] [AMDGPU] MCExpr printing helper with KnownBits support (PR #95951)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 11:00:28 PDT 2024


================
@@ -105,6 +106,16 @@ class AMDGPUMCExpr : public MCTargetExpr {
   }
 };
 
+// Tries to leverage KnownBits for MCExprs to reduce and limit any composed
+// MCExprs printing. E.g., for an expression such as
+// ((unevaluatable_sym | 1) & 1) won't evaluate due to unevaluatable_sym and
+// would verbosely print the full expression; however, KnownBits should deduce
+// the value to be 1. Particularly useful for AMDGPU metadata MCExprs.
+void AMDGPUMCExprPrint(const MCExpr *Expr, raw_ostream &OS,
+                       const MCAsmInfo *MAI);
+
+const MCExpr *TryFold(const MCExpr *Expr, MCContext &Ctx);
----------------
JanekvO wrote:

Renamed to `AMDGPUFoldMCExpr` and now lives in the `AMDGPU` namespace. Let me know whether that's fine.

https://github.com/llvm/llvm-project/pull/95951


More information about the llvm-commits mailing list