[llvm] [AMDGPU] Add AMDGPU specific variadic operation MCExprs (PR #82022)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 06:38:43 PST 2024


================
@@ -0,0 +1,64 @@
+//===- AMDGPUMCExpr.h - AMDGPU specific MC expression classes ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCEXPR_H
+#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCEXPR_H
+
+#include "llvm/MC/MCExpr.h"
+
+namespace llvm {
+
+class AMDGPUMCExpr : public MCTargetExpr {
+  static bool classof(const MCExpr *E) {
+    return E->getKind() == MCExpr::Target;
+  }
+  void fixELFSymbolsInTLSFixups(MCAssembler &) const override{};
+};
+
+class AMDGPUVariadicMCExpr : public AMDGPUMCExpr {
+public:
+  enum AMDGPUVariadicKind { AGVK_None, AGVK_Or, AGVK_Max };
+
+private:
+  AMDGPUVariadicKind Kind;
+  std::vector<const MCExpr *> Args;
+
+  AMDGPUVariadicMCExpr(AMDGPUVariadicKind Kind,
+                       const std::vector<const MCExpr *> &Args)
+      : Kind(Kind), Args(Args) {
+    assert(Args.size() >= 1 && "Can't take the maximum of 0 expressions.");
----------------
JanekvO wrote:

I've left it to 1 argument minimum for now. Didn't want to constrain in case there new operations are to be added (if any, that is) that could become a non-no-op for 1 argument. However, if undesirable, I can also constrain to 2 arguments minimum.

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


More information about the llvm-commits mailing list