[MLIR][SPIRVToLLVM] Implementation of spv.func conversion, and return ops
authorGeorge Mitenkov <georgemitenk0v@gmail.com>
Tue, 23 Jun 2020 15:26:44 +0000 (11:26 -0400)
committerLei Zhang <antiagainst@google.com>
Tue, 23 Jun 2020 15:34:11 +0000 (11:34 -0400)
commita4dc61344f08f7581b8794c5819ffdf9c708ecfe
tree6d01c7b2abf29a2e644c5d0f33fd5667d64b86d6
parentadf7973fd35d899a1500d2f379b4e6874b4de20f
[MLIR][SPIRVToLLVM] Implementation of spv.func conversion, and return ops

This patch provides an implementation for `spv.func` conversion. The pattern
is populated in a separate method added to the pass. At the moment, the type
signature conversion only includes the supported types. The conversion pattern
also matches SPIR-V function control attributes to LLVM function attributes.
Those are modelled as `passthrough` attributes in LLVM dialect. The following
mapping are used:
- None: no attributes passed
- Inline: `alwaysinline` seems to be the right equivalent (`inlinehint` is
  semantically weaker in my opinion)
- DontInline: `noinline`
- Pure and Const: I think those can be modelled as `readonly` and `readnone`
  attributes respectively.

Also, 2 patterns added for return ops conversion (`spv.Return` for void return
and `spv.ReturnValue` for a single value return).

Differential Revision: https://reviews.llvm.org/D81931
mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp
mlir/test/Conversion/SPIRVToLLVM/func-to-llvm.mlir [new file with mode: 0644]