[mlir] Make it possible to directly supply constant values to LLVM GEPOp
authorAlex Zinenko <zinenko@google.com>
Thu, 6 Jan 2022 22:29:15 +0000 (23:29 +0100)
committerAlex Zinenko <zinenko@google.com>
Fri, 7 Jan 2022 08:56:01 +0000 (09:56 +0100)
commitcafaa3503643c047b670dcc387e22096930d2d6c
tree400d35d20e8998ba1b91f2334c9f45b549e96eaa
parent348bc76e3548c52dbcd442590ca0a7f5b09b7534
[mlir] Make it possible to directly supply constant values to LLVM GEPOp

In LLVM IR, the GEP indices that correspond to structures are required to be
i32 constants. MLIR models constants as just values defined by special
operations, and there is no verification that it is the case for structure
indices in GEP. Furthermore, some common transformations such as control flow
simplification may lead to the operands becoming non-constant. Make it possible
to directly supply constant values to LLVM GEPOp to guarantee they remain
constant until the translation to LLVM IR. This is not yet a requirement and
the verifier is not modified, this will be introduced separately.

Reviewed By: wsmoses

Differential Revision: https://reviews.llvm.org/D116757
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
mlir/lib/Conversion/LLVMCommon/Pattern.cpp
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/test/Dialect/LLVMIR/roundtrip.mlir
mlir/test/Target/LLVMIR/llvmir.mlir