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

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 00:07:08 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 {
----------------
Pierre-vh wrote:

If you create a base class you'd need a way to tell which derived class is being used for `classof`.
Otherwise someone may add another derived class of `AMDGPUMCExpr` and expect it to work

You can either:
- Make `AMDGPUVariadicMCExpr` derive from `MCTargetExpr` and remove this class entirely, so if someone wants to add another class they'll be aware of the work that need to be done
- Implement the boilerplate for LLVM RTTI yourself, so add a `Kind` enum in `AMDGPUMCExpr` + add a Kind field & make classof act accordingly


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


More information about the llvm-commits mailing list