[llvm] [AMDGPU] Add AMDGPU specific variadic operation MCExprs (PR #82022)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 00:25:03 PST 2024
================
@@ -0,0 +1,73 @@
+//===- 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/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/MC/MCExpr.h"
+
+namespace llvm {
+
+/// AMDGPU target specific variadic MCExpr operations.
+///
+/// Takes in a minimum of 1 argument to be used with an operation. The supported
+/// operations are:
+/// - (logic) or
+/// - max
+///
+/// \note If the 'or'/'max' operations are provided only a single argument, the
+/// operation will act as a no-op and simply resolve as the provided argument.
+///
+class AMDGPUVariadicMCExpr : public MCTargetExpr {
+public:
+ enum AMDGPUVariadicKind { AGVK_None, AGVK_Or, AGVK_Max };
----------------
Pierre-vh wrote:
tiny nit: you can remove the `AMDGPU` prefix here as it's already contained in `AMDGPUVariadicMCExpr`
also just noticed this: we don't need the `None` kind if it's not supported. I think we'll `unreachable` if we try to evaluate a none.
If you want to keep the none kind add an assert that `Kind != AGVK_None` in the constructor so we don't accidentally construct those
https://github.com/llvm/llvm-project/pull/82022
More information about the llvm-commits
mailing list