[mlir] initial support for opaque pointers in the LLVM dialect
authorAlex Zinenko <zinenko@google.com>
Wed, 13 Apr 2022 16:29:17 +0000 (18:29 +0200)
committerAlex Zinenko <zinenko@google.com>
Thu, 14 Apr 2022 11:23:29 +0000 (13:23 +0200)
commit2366a43b3c50be09f70ba4bd795d95349ab90908
tree6ba2400d551d93b6867f53d339193f2c0fcdba80
parent0c44115e5120167fc573e36dd878f4f95f5d63e6
[mlir] initial support for opaque pointers in the LLVM dialect

LLVM IR has introduced and is moving forward with the concept of opaque
pointers, i.e. pointer types that are not carrying around the pointee type.
Instead, memory-related operations indicate the type of the data being accessed
through the opaque pointer. Introduce the initial support for opaque pointers
in the LLVM dialect:

  - `LLVMPointerType` to support omitting the element type;
  - alloca/load/store/gep to support opaque pointers in their operands and
    results; this requires alloca and gep to store the element type as an
    attribute;
  - memory-related intrinsics to support opaque pointers in their operands;
  - translation to LLVM IR for the ops above is no longer using methods
    deprecated in LLVM API due to the introduction of opaque pointers.

Unlike LLVM IR, MLIR can afford to support both opaque and non-opaque pointers
at the same time and simplify the transition. Translation to LLVM IR of MLIR
that involves opaque pointers requires the LLVMContext to be configured to
always use opaque pointers.

Reviewed By: wsmoses

Differential Revision: https://reviews.llvm.org/D123310
13 files changed:
mlir/docs/Dialects/LLVM.md
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h
mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
mlir/test/Dialect/LLVMIR/invalid.mlir
mlir/test/Dialect/LLVMIR/opaque-ptr.mlir [new file with mode: 0644]
mlir/test/Dialect/LLVMIR/types.mlir
mlir/test/Target/LLVMIR/opaque-ptr.mlir [new file with mode: 0644]