[llvm] [AMDGPU] MCExpr printing helper with KnownBits support (PR #95951)
Janek van Oirschot via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 06:13:04 PDT 2024
================
@@ -314,3 +315,142 @@ AMDGPUVariadicMCExpr::createOccupancy(unsigned InitOcc, const MCExpr *NumSGPRs,
CreateExpr(InitOcc), NumSGPRs, NumVGPRs},
Ctx);
}
+
+static KnownBits AMDGPUMCExprKnownBits(const MCExpr *Expr, raw_ostream &OS,
----------------
JanekvO wrote:
> Would it be a step too far to actually incorporate the KnownBits handling into the MCExpr/MCTargetExpr APIs?
I had been considering this but I don't know in what form this would be in. Would this be part of `MCExpr` `print` interface or would this be part of `MCExpr` `evaluateAsXXX` interface? Or perhaps a new call entirely. Additionally, I wasn't sure how keen people would be knowing that this might be costly in terms of deducing so with all the uncertainty and unknowns I went with the safe target specific route for now. Would definitely be nice to have in the generic part so let me know what everybody thinks.
> I think the remaining cases can also be improved by just applying the same algorithm you have here at every level of subexpression, rather than once for the whole expression.
Agree, that would help readability of these `MCExpr`! May have a cost associated with it in terms of unused allocated memory, unfortunately (there is no `free` functionality for any `MCExpr` part of the `MCContext`).
> If we also handled some identity cases for operations the result gets pretty manageable.
That'd be consistent with the aforementioned point of creating new `MCExpr` (i.e., `MCExpr` folding).
Thank you for the comment so far!
https://github.com/llvm/llvm-project/pull/95951
More information about the llvm-commits
mailing list