[llvm] [AMDGPU] Add AMDGPU specific variadic operation MCExprs (PR #82022)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 04:31:14 PST 2024
================
@@ -8130,6 +8132,53 @@ void AMDGPUAsmParser::onBeginOfFile() {
getTargetStreamer().EmitDirectiveAMDGCNTarget();
}
+/// Parse AMDGPU specific expressions.
+///
+/// expr ::= or(expr, ...) |
+/// max(expr, ...)
+///
+bool AMDGPUAsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
+ using AGVK = AMDGPUVariadicMCExpr::AMDGPUVariadicKind;
+
+ auto ParseVariadicExpr = [&](AGVK Kind, const MCExpr *&Result,
+ SMLoc &EndLoc) {
+ SmallVector<const MCExpr *, 4> Exprs;
+ while (true) {
+ if (trySkipToken(AsmToken::RParen)) {
+ if (Exprs.empty()) {
+ Error(getToken().getLoc(), "empty max/or expression");
+ return true;
+ }
+ Result = AMDGPUVariadicMCExpr::create(Kind, Exprs, getContext());
+ return false;
+ }
+ const MCExpr *Expr;
+ if (getParser().parseExpression(Expr, EndLoc))
+ return true;
+ Exprs.push_back(Expr);
+ if (!trySkipToken(AsmToken::Comma) && !isToken(AsmToken::RParen)) {
+ Error(getToken().getLoc(), "unexpected token in max/or expression");
----------------
Pierre-vh wrote:
same here
https://github.com/llvm/llvm-project/pull/82022
More information about the llvm-commits
mailing list