[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:13 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");
----------------
Pierre-vh wrote:

nit: you can pass `tokenId` as another parameter and just print it here, so you avoid hardcoding the max/or and new additions here can be seamless.

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


More information about the llvm-commits mailing list