-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[CIR] Remove redundant operation trait and use AllTypesMatch instead #144950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This mirrors incubator changes from llvm/clangir#1679
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Henrich Lauko (xlauko) ChangesThis mirrors incubator changes from llvm/clangir#1679 Full diff: https://github.com/llvm/llvm-project/pull/144950.diff 3 Files Affected:
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(); }
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/17887 Here is the relevant piece of the build log for the reference
|
…lvm#144950) This mirrors incubator changes from llvm/clangir#1679
This mirrors incubator changes from llvm/clangir#1679