MLIR  20.0.0git
SPIRVToLLVM.h
Go to the documentation of this file.
1 //===- SPIRVToLLVM.h - SPIR-V to LLVM Patterns ------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Provides patterns to convert SPIR-V dialect to LLVM dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_CONVERSION_SPIRVTOLLVM_SPIRVTOLLVM_H
14 #define MLIR_CONVERSION_SPIRVTOLLVM_SPIRVTOLLVM_H
15 
17 
19 
20 namespace mlir {
21 class LLVMTypeConverter;
22 class MLIRContext;
23 class ModuleOp;
24 
25 template <typename SPIRVOp>
26 class SPIRVToLLVMConversion : public OpConversionPattern<SPIRVOp> {
27 public:
30  PatternBenefit benefit = 1)
31  : OpConversionPattern<SPIRVOp>(typeConverter, context, benefit) {}
32 };
33 
34 /// Encodes global variable's descriptor set and binding into its name if they
35 /// both exist.
36 void encodeBindAttribute(ModuleOp module);
37 
38 /// Populates type conversions with additional SPIR-V types.
40  LLVMTypeConverter &typeConverter,
41  spirv::ClientAPI clientAPIForAddressSpaceMapping =
42  spirv::ClientAPI::Unknown);
43 
44 /// Populates the given list with patterns that convert from SPIR-V to LLVM.
46  const LLVMTypeConverter &typeConverter, RewritePatternSet &patterns,
47  spirv::ClientAPI clientAPIForAddressSpaceMapping =
48  spirv::ClientAPI::Unknown);
49 
50 /// Populates the given list with patterns for function conversion from SPIR-V
51 /// to LLVM.
53  const LLVMTypeConverter &typeConverter, RewritePatternSet &patterns);
54 
55 /// Populates the given patterns for module conversion from SPIR-V to LLVM.
57  const LLVMTypeConverter &typeConverter, RewritePatternSet &patterns);
58 
59 } // namespace mlir
60 
61 #endif // MLIR_CONVERSION_SPIRVTOLLVM_SPIRVTOLLVM_H
const TypeConverter * typeConverter
An optional type converter for use by this pattern.
Conversion from types to the LLVM IR dialect.
Definition: TypeConverter.h:35
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:60
OpConversionPattern is a wrapper around ConversionPattern that allows for matching and rewriting agai...
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
Definition: PatternMatch.h:34
SPIRVToLLVMConversion(MLIRContext *context, const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1)
Definition: SPIRVToLLVM.h:28
Include the generated interface declarations.
void populateSPIRVToLLVMTypeConversion(LLVMTypeConverter &typeConverter, spirv::ClientAPI clientAPIForAddressSpaceMapping=spirv::ClientAPI::Unknown)
Populates type conversions with additional SPIR-V types.
void populateSPIRVToLLVMFunctionConversionPatterns(const LLVMTypeConverter &typeConverter, RewritePatternSet &patterns)
Populates the given list with patterns for function conversion from SPIR-V to LLVM.
const FrozenRewritePatternSet & patterns
void populateSPIRVToLLVMConversionPatterns(const LLVMTypeConverter &typeConverter, RewritePatternSet &patterns, spirv::ClientAPI clientAPIForAddressSpaceMapping=spirv::ClientAPI::Unknown)
Populates the given list with patterns that convert from SPIR-V to LLVM.
void encodeBindAttribute(ModuleOp module)
Encodes global variable's descriptor set and binding into its name if they both exist.
void populateSPIRVToLLVMModuleConversionPatterns(const LLVMTypeConverter &typeConverter, RewritePatternSet &patterns)
Populates the given patterns for module conversion from SPIR-V to LLVM.