https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/144950
This mirrors incubator changes from https://github.com/llvm/clangir/pull/1679 >From f6207dc635fdd9f87000798eb3ddb61eb45190b5 Mon Sep 17 00:00:00 2001 From: xlauko <xla...@mail.muni.cz> Date: Thu, 19 Jun 2025 22:03:29 +0200 Subject: [PATCH] [CIR] Remove redundant operation trait and use AllTypesMatch instead This mirrors incubator changes from https://github.com/llvm/clangir/pull/1679 --- .../include/clang/CIR/Dialect/IR/CIRDialect.h | 25 ------------------- clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 +------ clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 19 -------------- 3 files changed, 1 insertion(+), 52 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h index aa1494ab4df1e..5de1722cf5bc2 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h @@ -33,31 +33,6 @@ #include "clang/CIR/Interfaces/CIROpInterfaces.h" #include "clang/CIR/MissingFeatures.h" -namespace mlir { -namespace OpTrait { - -namespace impl { -// These functions are out-of-line implementations of the methods in the -// corresponding trait classes. This avoids them being template -// instantiated/duplicated. -LogicalResult verifySameFirstOperandAndResultType(Operation *op); -} // namespace impl - -/// This class provides verification for ops that are known to have the same -/// first operand and result type. -/// -template <typename ConcreteType> -class SameFirstOperandAndResultType - : public TraitBase<ConcreteType, SameFirstOperandAndResultType> { -public: - static llvm::LogicalResult verifyTrait(Operation *op) { - return impl::verifySameFirstOperandAndResultType(op); - } -}; - -} // namespace OpTrait -} // namespace mlir - using BuilderCallbackRef = llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>; using BuilderOpStateCallbackRef = llvm::function_ref<void( diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 852d3aa131148..f5253f4af6a9a 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -80,13 +80,6 @@ class LLVMLoweringInfo { class CIR_Op<string mnemonic, list<Trait> traits = []> : Op<CIR_Dialect, mnemonic, traits>, LLVMLoweringInfo; -//===----------------------------------------------------------------------===// -// CIR Op Traits -//===----------------------------------------------------------------------===// - -def SameFirstOperandAndResultType : - NativeOpTrait<"SameFirstOperandAndResultType">; - //===----------------------------------------------------------------------===// // CastOp //===----------------------------------------------------------------------===// @@ -243,7 +236,7 @@ def CastOp : CIR_Op<"cast", //===----------------------------------------------------------------------===// def PtrStrideOp : CIR_Op<"ptr_stride", - [Pure, SameFirstOperandAndResultType]> { + [Pure, AllTypesMatch<["base", "result"]>]> { let summary = "Pointer access with stride"; let description = [{ Given a base pointer as first operand, provides a new pointer after applying diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 16248059c4975..27f4ecb5ab85d 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -1374,25 +1374,6 @@ void cir::FuncOp::print(OpAsmPrinter &p) { } } -//===----------------------------------------------------------------------===// -// CIR defined traits -//===----------------------------------------------------------------------===// - -LogicalResult -mlir::OpTrait::impl::verifySameFirstOperandAndResultType(Operation *op) { - if (failed(verifyAtLeastNOperands(op, 1)) || failed(verifyOneResult(op))) - return failure(); - - const Type type = op->getResult(0).getType(); - const Type opType = op->getOperand(0).getType(); - - if (type != opType) - return op->emitOpError() - << "requires the same type for first operand and result"; - - return success(); -} - // TODO(CIR): The properties of functions that require verification haven't // been implemented yet. mlir::LogicalResult cir::FuncOp::verify() { return success(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits