1 //===- TestDialect.h - MLIR Dialect for testing -----------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines a fake 'test' dialect that can be used for testing things
10 // that do not have a respective counterpart in the main source directories.
12 //===----------------------------------------------------------------------===//
14 #ifndef MLIR_TESTDIALECT_H
15 #define MLIR_TESTDIALECT_H
17 #include "TestAttributes.h"
18 #include "TestInterfaces.h"
19 #include "TestTypes.h"
20 #include "mlir/Bytecode/BytecodeImplementation.h"
21 #include "mlir/Dialect/DLTI/DLTI.h"
22 #include "mlir/Dialect/DLTI/Traits.h"
23 #include "mlir/Dialect/Func/IR/FuncOps.h"
24 #include "mlir/Dialect/Linalg/IR/Linalg.h"
25 #include "mlir/Dialect/Traits.h"
26 #include "mlir/IR/AsmState.h"
27 #include "mlir/IR/BuiltinOps.h"
28 #include "mlir/IR/BuiltinTypes.h"
29 #include "mlir/IR/Dialect.h"
30 #include "mlir/IR/DialectResourceBlobManager.h"
31 #include "mlir/IR/ExtensibleDialect.h"
32 #include "mlir/IR/OpDefinition.h"
33 #include "mlir/IR/OpImplementation.h"
34 #include "mlir/IR/RegionKindInterface.h"
35 #include "mlir/IR/SymbolTable.h"
36 #include "mlir/Interfaces/CallInterfaces.h"
37 #include "mlir/Interfaces/ControlFlowInterfaces.h"
38 #include "mlir/Interfaces/CopyOpInterface.h"
39 #include "mlir/Interfaces/DerivedAttributeOpInterface.h"
40 #include "mlir/Interfaces/InferIntRangeInterface.h"
41 #include "mlir/Interfaces/InferTypeOpInterface.h"
42 #include "mlir/Interfaces/LoopLikeInterface.h"
43 #include "mlir/Interfaces/SideEffectInterfaces.h"
44 #include "mlir/Interfaces/ValueBoundsOpInterface.h"
45 #include "mlir/Interfaces/ViewLikeInterface.h"
46 #include "llvm/ADT/SetVector.h"
51 class RewritePatternSet
;
52 } // end namespace mlir
54 //===----------------------------------------------------------------------===//
56 //===----------------------------------------------------------------------===//
58 #include "TestOpsDialect.h.inc"
62 //===----------------------------------------------------------------------===//
63 // TestDialect version utilities
64 //===----------------------------------------------------------------------===//
66 struct TestDialectVersion
: public mlir::DialectVersion
{
67 TestDialectVersion() = default;
68 TestDialectVersion(uint32_t majorVersion
, uint32_t minorVersion
)
69 : major_(majorVersion
), minor_(minorVersion
){};
70 // We cannot use 'major' and 'minor' here because these identifiers may
71 // already be used by <sys/types.h> on many POSIX systems including Linux and
81 // Op deliberately defined in C++ code rather than ODS to test that C++
82 // Ops can still use the old `fold` method.
83 class ManualCppOpWithFold
84 : public mlir::Op
<ManualCppOpWithFold
, mlir::OpTrait::OneResult
> {
88 static llvm::StringRef
getOperationName() {
89 return "test.manual_cpp_op_with_fold";
92 static llvm::ArrayRef
<llvm::StringRef
> getAttributeNames() { return {}; }
94 mlir::OpFoldResult
fold(llvm::ArrayRef
<mlir::Attribute
> attributes
);
97 void registerTestDialect(::mlir::DialectRegistry
®istry
);
98 void populateTestReductionPatterns(::mlir::RewritePatternSet
&patterns
);
99 void testSideEffectOpGetEffect(
101 llvm::SmallVectorImpl
<
102 mlir::SideEffects::EffectInstance
<mlir::TestEffects::Effect
>> &effects
);
105 #endif // MLIR_TESTDIALECT_H