Skip to content

Commit 97e8266

Browse files
authored
[CIR] Remove redundant operation trait and use AllTypesMatch instead (#144950)
This mirrors incubator changes from llvm/clangir#1679
1 parent b215c8e commit 97e8266

File tree

3 files changed

+1
-52
lines changed

3 files changed

+1
-52
lines changed

clang/include/clang/CIR/Dialect/IR/CIRDialect.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,6 @@
3333
#include "clang/CIR/Interfaces/CIROpInterfaces.h"
3434
#include "clang/CIR/MissingFeatures.h"
3535

36-
namespace mlir {
37-
namespace OpTrait {
38-
39-
namespace impl {
40-
// These functions are out-of-line implementations of the methods in the
41-
// corresponding trait classes. This avoids them being template
42-
// instantiated/duplicated.
43-
LogicalResult verifySameFirstOperandAndResultType(Operation *op);
44-
} // namespace impl
45-
46-
/// This class provides verification for ops that are known to have the same
47-
/// first operand and result type.
48-
///
49-
template <typename ConcreteType>
50-
class SameFirstOperandAndResultType
51-
: public TraitBase<ConcreteType, SameFirstOperandAndResultType> {
52-
public:
53-
static llvm::LogicalResult verifyTrait(Operation *op) {
54-
return impl::verifySameFirstOperandAndResultType(op);
55-
}
56-
};
57-
58-
} // namespace OpTrait
59-
} // namespace mlir
60-
6136
using BuilderCallbackRef =
6237
llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>;
6338
using BuilderOpStateCallbackRef = llvm::function_ref<void(

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ class LLVMLoweringInfo {
8080
class CIR_Op<string mnemonic, list<Trait> traits = []> :
8181
Op<CIR_Dialect, mnemonic, traits>, LLVMLoweringInfo;
8282

83-
//===----------------------------------------------------------------------===//
84-
// CIR Op Traits
85-
//===----------------------------------------------------------------------===//
86-
87-
def SameFirstOperandAndResultType :
88-
NativeOpTrait<"SameFirstOperandAndResultType">;
89-
9083
//===----------------------------------------------------------------------===//
9184
// CastOp
9285
//===----------------------------------------------------------------------===//
@@ -243,7 +236,7 @@ def CastOp : CIR_Op<"cast",
243236
//===----------------------------------------------------------------------===//
244237

245238
def PtrStrideOp : CIR_Op<"ptr_stride",
246-
[Pure, SameFirstOperandAndResultType]> {
239+
[Pure, AllTypesMatch<["base", "result"]>]> {
247240
let summary = "Pointer access with stride";
248241
let description = [{
249242
Given a base pointer as first operand, provides a new pointer after applying

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,25 +1374,6 @@ void cir::FuncOp::print(OpAsmPrinter &p) {
13741374
}
13751375
}
13761376

1377-
//===----------------------------------------------------------------------===//
1378-
// CIR defined traits
1379-
//===----------------------------------------------------------------------===//
1380-
1381-
LogicalResult
1382-
mlir::OpTrait::impl::verifySameFirstOperandAndResultType(Operation *op) {
1383-
if (failed(verifyAtLeastNOperands(op, 1)) || failed(verifyOneResult(op)))
1384-
return failure();
1385-
1386-
const Type type = op->getResult(0).getType();
1387-
const Type opType = op->getOperand(0).getType();
1388-
1389-
if (type != opType)
1390-
return op->emitOpError()
1391-
<< "requires the same type for first operand and result";
1392-
1393-
return success();
1394-
}
1395-
13961377
// TODO(CIR): The properties of functions that require verification haven't
13971378
// been implemented yet.
13981379
mlir::LogicalResult cir::FuncOp::verify() { return success(); }

0 commit comments

Comments
 (0)