[Mlir-commits] [mlir] 884d310 - [mlir][LLVM] Add OpBuilder for opaque pointer GEPs without struct indices

Markus Böck llvmlistbot at llvm.org
Sat Jul 16 01:56:21 PDT 2022


Author: Markus Böck
Date: 2022-07-16T10:55:49+02:00
New Revision: 884d310d8774400abe572443362b7732f23c1ed4

URL: https://github.com/llvm/llvm-project/commit/884d310d8774400abe572443362b7732f23c1ed4
DIFF: https://github.com/llvm/llvm-project/commit/884d310d8774400abe572443362b7732f23c1ed4.diff

LOG: [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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 0e2ec6df65c7c..afeec12b1b748 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -434,6 +434,12 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [NoSideEffect]> {
     OpBuilder<(ins "Type":$resultType, "Value":$basePtr, "ValueRange":$indices,
                "ArrayRef<int32_t>":$structIndices,
                CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "Type":$resultType, "Type":$basePtrType, "Value":$basePtr,
+               "ValueRange":$indices,
+               CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>,
+	OpBuilder<(ins "Type":$resultType, "Type":$basePtrType, "Value":$basePtr,
+               "ValueRange":$indices,
+               CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>,
     OpBuilder<(ins "Type":$resultType, "Type":$basePtrType, "Value":$basePtr,
                "ValueRange":$indices, "ArrayRef<int32_t>":$structIndices,
                CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index ea3bfbabac132..b3f8012c496cd 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -567,6 +567,13 @@ static Type extractVectorElementType(Type type) {
   return type;
 }
 
+void GEPOp::build(OpBuilder &builder, OperationState &result, Type resultType,
+                  Type elementType, Value basePtr, ValueRange indices,
+                  ArrayRef<NamedAttribute> attributes) {
+  build(builder, result, resultType, elementType, basePtr, indices,
+        SmallVector<int32_t>(indices.size(), kDynamicIndex), attributes);
+}
+
 void GEPOp::build(OpBuilder &builder, OperationState &result, Type resultType,
                   Value basePtr, ValueRange indices,
                   ArrayRef<int32_t> structIndices,


        


More information about the Mlir-commits mailing list