StdToLLVM conversion: drop getMemRefElementType utility function
authorAlex Zinenko <zinenko@google.com>
Tue, 17 Dec 2019 19:38:53 +0000 (11:38 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Tue, 17 Dec 2019 19:43:59 +0000 (11:43 -0800)
This function has become redundant with MemRefDescriptor::getElementType and is
no longer necessary. Use the MemRefDescriptor pervasively to concentrate
descriptor-related logic in one place and drop the utility function.

PiperOrigin-RevId: 286024168

mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp

index fa65120..9b2113a 100644 (file)
@@ -253,17 +253,6 @@ Type LLVMTypeConverter::convertStandardType(Type type) {
   return {};
 }
 
-// Convert the element type of the memref `t` to to an LLVM type using
-// `lowering`, get a pointer LLVM type pointing to the converted `t`, wrap it
-// into the MLIR LLVM dialect type and return.
-static Type getMemRefElementPtrType(MemRefType t, LLVMTypeConverter &lowering) {
-  auto elementType = t.getElementType();
-  auto converted = lowering.convertType(elementType);
-  if (!converted)
-    return {};
-  return converted.cast<LLVM::LLVMType>().getPointerTo(t.getMemorySpace());
-}
-
 LLVMOpLowering::LLVMOpLowering(StringRef rootOpName, MLIRContext *context,
                                LLVMTypeConverter &lowering_,
                                PatternBenefit benefit)
@@ -1429,7 +1418,7 @@ struct LoadStoreOpLowering : public LLVMLegalizationPattern<Derived> {
                     ArrayRef<Value *> indices,
                     ConversionPatternRewriter &rewriter,
                     llvm::Module &module) const {
-    auto ptrType = getMemRefElementPtrType(type, this->lowering);
+    LLVM::LLVMType ptrType = MemRefDescriptor(memRefDesc).getElementType();
     int64_t offset;
     SmallVector<int64_t, 4> strides;
     auto successStrides = getStridesAndOffset(type, strides, offset);