From 884d310d8774400abe572443362b7732f23c1ed4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20B=C3=B6ck?= Date: Sat, 16 Jul 2022 10:55:49 +0200 Subject: [PATCH] [mlir][LLVM] Add OpBuilder for opaque pointer GEPs without struct indices An OpBuilder already exists for GEPs that does not have any struct indices for existing typed pointers, but no such builder exists for GEPs utilizing opaque pointers that has an explicit `basePtrType`. Differential Revision: https://reviews.llvm.org/D129376 --- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 6 ++++++ mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 0e2ec6d..afeec12 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -435,6 +435,12 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [NoSideEffect]> { "ArrayRef":$structIndices, CArg<"ArrayRef", "{}">:$attributes)>, OpBuilder<(ins "Type":$resultType, "Type":$basePtrType, "Value":$basePtr, + "ValueRange":$indices, + CArg<"ArrayRef", "{}">:$attributes)>, + OpBuilder<(ins "Type":$resultType, "Type":$basePtrType, "Value":$basePtr, + "ValueRange":$indices, + CArg<"ArrayRef", "{}">:$attributes)>, + OpBuilder<(ins "Type":$resultType, "Type":$basePtrType, "Value":$basePtr, "ValueRange":$indices, "ArrayRef":$structIndices, CArg<"ArrayRef", "{}">:$attributes)> ]; diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index ea3bfba..b3f8012 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -568,6 +568,13 @@ static Type extractVectorElementType(Type type) { } void GEPOp::build(OpBuilder &builder, OperationState &result, Type resultType, + Type elementType, Value basePtr, ValueRange indices, + ArrayRef attributes) { + build(builder, result, resultType, elementType, basePtr, indices, + SmallVector(indices.size(), kDynamicIndex), attributes); +} + +void GEPOp::build(OpBuilder &builder, OperationState &result, Type resultType, Value basePtr, ValueRange indices, ArrayRef structIndices, ArrayRef attributes) { -- 2.7.4