My Project
SPIRVLowering.h
Go to the documentation of this file.
1 //===- SPIRVLowering.h - SPIR-V lowering utilities -------------*- 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 // Defines utilities to use while targeting SPIR-V dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
14 #define MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
15 
18 
19 namespace mlir {
20 
26 class SPIRVTypeConverter final : public TypeConverter {
27 public:
28  using TypeConverter::TypeConverter;
29 
31  Type convertType(Type type) override;
32 
34  static Type getIndexType(MLIRContext *context);
35 };
36 
38 template <typename SourceOp>
39 class SPIRVOpLowering : public OpConversionPattern<SourceOp> {
40 public:
42  PatternBenefit benefit = 1)
43  : OpConversionPattern<SourceOp>(context, benefit),
44  typeConverter(typeConverter) {}
45 
46 protected:
48 };
49 
50 namespace spirv {
51 enum class BuiltIn : uint32_t;
52 
55 Value getBuiltinVariableValue(Operation *op, BuiltIn builtin,
56  OpBuilder &builder);
57 
60 LogicalResult setABIAttrs(FuncOp funcOp, EntryPointABIAttr entryPointInfo,
61  ArrayRef<InterfaceVarABIAttr> argABIInfo);
62 } // namespace spirv
63 } // namespace mlir
64 
65 #endif // MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
Definition: InferTypeOpInterface.cpp:20
Base class to define a conversion pattern to lower SourceOp into SPIR-V.
Definition: SPIRVLowering.h:39
Definition: DialectConversion.h:222
Definition: LogicalResult.h:18
LogicalResult setABIAttrs(FuncOp funcOp, EntryPointABIAttr entryPointInfo, ArrayRef< InterfaceVarABIAttr > argABIInfo)
Definition: PatternMatch.h:29
Definition: Types.h:84
Definition: Value.h:38
SPIRVTypeConverter & typeConverter
Definition: SPIRVLowering.h:47
Definition: DialectConversion.h:39
Definition: MLIRContext.h:34
Type convertType(Type type) override
Converts the given standard type to SPIR-V correspondence.
Definition: SPIRVLowering.cpp:124
enum BuiltIn uint32_t Value getBuiltinVariableValue(Operation *op, BuiltIn builtin, OpBuilder &builder)
SPIRVOpLowering(MLIRContext *context, SPIRVTypeConverter &typeConverter, PatternBenefit benefit=1)
Definition: SPIRVLowering.h:41
Definition: SPIRVLowering.h:26
static Type getIndexType(MLIRContext *context)
Gets the SPIR-V correspondence for the standard index type.
Definition: SPIRVLowering.cpp:25