My Project
SPIRVDialect.h
Go to the documentation of this file.
1 //===- SPIRVDialect.h - MLIR SPIR-V dialect ---------------------*- C++ -*-===//
2 //
3 // Part of the MLIR 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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the SPIR-V dialect in MLIR.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
14 #define MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
15 
16 #include "mlir/IR/Dialect.h"
17 
18 namespace mlir {
19 namespace spirv {
20 
21 enum class Decoration : uint32_t;
22 
23 class SPIRVDialect : public Dialect {
24 public:
25  explicit SPIRVDialect(MLIRContext *context);
26 
27  static StringRef getDialectNamespace() { return "spv"; }
28 
30  static bool isValidType(Type type);
31 
33  static bool isValidScalarType(Type type);
34 
37  static std::string getAttributeName(Decoration decoration);
38 
40  Type parseType(DialectAsmParser &parser) const override;
41 
43  void printType(Type type, DialectAsmPrinter &os) const override;
44 
46  Operation *materializeConstant(OpBuilder &builder, Attribute value, Type type,
47  Location loc) override;
48 
51  LogicalResult verifyOperationAttribute(Operation *op,
52  NamedAttribute attribute) override;
53 
56  LogicalResult verifyRegionArgAttribute(Operation *op, unsigned regionIndex,
57  unsigned argIndex,
58  NamedAttribute attribute) override;
59 
62  LogicalResult verifyRegionResultAttribute(Operation *op, unsigned regionIndex,
63  unsigned resultIndex,
64  NamedAttribute attribute) override;
65 };
66 
67 } // end namespace spirv
68 } // end namespace mlir
69 
70 #endif // MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
Definition: InferTypeOpInterface.cpp:20
Definition: Operation.h:27
Definition: SPIRVDialect.h:23
Definition: Location.h:52
std::pair< Identifier, Attribute > NamedAttribute
Definition: Attributes.h:264
Definition: LogicalResult.h:18
static StringRef getDialectNamespace()
Definition: SPIRVDialect.h:27
Definition: Attributes.h:53
Definition: Dialect.h:39
Type parseType(llvm::StringRef typeStr, MLIRContext *context)
Definition: Types.h:84
Definition: DialectImplementation.h:33
Definition: MLIRContext.h:34
Definition: Builders.h:158
Definition: DialectImplementation.h:100