aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/LLVMCommon
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Conversion/LLVMCommon')
-rw-r--r--mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp118
-rw-r--r--mlir/lib/Conversion/LLVMCommon/Pattern.cpp99
-rw-r--r--mlir/lib/Conversion/LLVMCommon/PrintCallHelper.cpp12
-rw-r--r--mlir/lib/Conversion/LLVMCommon/StructBuilder.cpp4
-rw-r--r--mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp16
-rw-r--r--mlir/lib/Conversion/LLVMCommon/VectorPattern.cpp8
6 files changed, 130 insertions, 127 deletions
diff --git a/mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp b/mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp
index e34d5f7..fce7a3f 100644
--- a/mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp
@@ -32,7 +32,7 @@ MemRefDescriptor::MemRefDescriptor(Value descriptor)
MemRefDescriptor MemRefDescriptor::poison(OpBuilder &builder, Location loc,
Type descriptorType) {
- Value descriptor = builder.create<LLVM::PoisonOp>(loc, descriptorType);
+ Value descriptor = LLVM::PoisonOp::create(builder, loc, descriptorType);
return MemRefDescriptor(descriptor);
}
@@ -99,21 +99,21 @@ void MemRefDescriptor::setAlignedPtr(OpBuilder &builder, Location loc,
// integer attribute.
static Value createIndexAttrConstant(OpBuilder &builder, Location loc,
Type resultType, int64_t value) {
- return builder.create<LLVM::ConstantOp>(loc, resultType,
- builder.getIndexAttr(value));
+ return LLVM::ConstantOp::create(builder, loc, resultType,
+ builder.getIndexAttr(value));
}
/// Builds IR extracting the offset from the descriptor.
Value MemRefDescriptor::offset(OpBuilder &builder, Location loc) {
- return builder.create<LLVM::ExtractValueOp>(loc, value,
- kOffsetPosInMemRefDescriptor);
+ return LLVM::ExtractValueOp::create(builder, loc, value,
+ kOffsetPosInMemRefDescriptor);
}
/// Builds IR inserting the offset into the descriptor.
void MemRefDescriptor::setOffset(OpBuilder &builder, Location loc,
Value offset) {
- value = builder.create<LLVM::InsertValueOp>(loc, value, offset,
- kOffsetPosInMemRefDescriptor);
+ value = LLVM::InsertValueOp::create(builder, loc, value, offset,
+ kOffsetPosInMemRefDescriptor);
}
/// Builds IR inserting the offset into the descriptor.
@@ -125,8 +125,9 @@ void MemRefDescriptor::setConstantOffset(OpBuilder &builder, Location loc,
/// Builds IR extracting the pos-th size from the descriptor.
Value MemRefDescriptor::size(OpBuilder &builder, Location loc, unsigned pos) {
- return builder.create<LLVM::ExtractValueOp>(
- loc, value, ArrayRef<int64_t>({kSizePosInMemRefDescriptor, pos}));
+ return LLVM::ExtractValueOp::create(
+ builder, loc, value,
+ ArrayRef<int64_t>({kSizePosInMemRefDescriptor, pos}));
}
Value MemRefDescriptor::size(OpBuilder &builder, Location loc, Value pos,
@@ -137,23 +138,25 @@ Value MemRefDescriptor::size(OpBuilder &builder, Location loc, Value pos,
// Copy size values to stack-allocated memory.
auto one = createIndexAttrConstant(builder, loc, indexType, 1);
- auto sizes = builder.create<LLVM::ExtractValueOp>(
- loc, value, llvm::ArrayRef<int64_t>({kSizePosInMemRefDescriptor}));
- auto sizesPtr = builder.create<LLVM::AllocaOp>(loc, ptrTy, arrayTy, one,
- /*alignment=*/0);
- builder.create<LLVM::StoreOp>(loc, sizes, sizesPtr);
+ auto sizes = LLVM::ExtractValueOp::create(
+ builder, loc, value,
+ llvm::ArrayRef<int64_t>({kSizePosInMemRefDescriptor}));
+ auto sizesPtr = LLVM::AllocaOp::create(builder, loc, ptrTy, arrayTy, one,
+ /*alignment=*/0);
+ LLVM::StoreOp::create(builder, loc, sizes, sizesPtr);
// Load an return size value of interest.
- auto resultPtr = builder.create<LLVM::GEPOp>(loc, ptrTy, arrayTy, sizesPtr,
- ArrayRef<LLVM::GEPArg>{0, pos});
- return builder.create<LLVM::LoadOp>(loc, indexType, resultPtr);
+ auto resultPtr = LLVM::GEPOp::create(builder, loc, ptrTy, arrayTy, sizesPtr,
+ ArrayRef<LLVM::GEPArg>{0, pos});
+ return LLVM::LoadOp::create(builder, loc, indexType, resultPtr);
}
/// Builds IR inserting the pos-th size into the descriptor
void MemRefDescriptor::setSize(OpBuilder &builder, Location loc, unsigned pos,
Value size) {
- value = builder.create<LLVM::InsertValueOp>(
- loc, value, size, ArrayRef<int64_t>({kSizePosInMemRefDescriptor, pos}));
+ value = LLVM::InsertValueOp::create(
+ builder, loc, value, size,
+ ArrayRef<int64_t>({kSizePosInMemRefDescriptor, pos}));
}
void MemRefDescriptor::setConstantSize(OpBuilder &builder, Location loc,
@@ -164,15 +167,16 @@ void MemRefDescriptor::setConstantSize(OpBuilder &builder, Location loc,
/// Builds IR extracting the pos-th stride from the descriptor.
Value MemRefDescriptor::stride(OpBuilder &builder, Location loc, unsigned pos) {
- return builder.create<LLVM::ExtractValueOp>(
- loc, value, ArrayRef<int64_t>({kStridePosInMemRefDescriptor, pos}));
+ return LLVM::ExtractValueOp::create(
+ builder, loc, value,
+ ArrayRef<int64_t>({kStridePosInMemRefDescriptor, pos}));
}
/// Builds IR inserting the pos-th stride into the descriptor
void MemRefDescriptor::setStride(OpBuilder &builder, Location loc, unsigned pos,
Value stride) {
- value = builder.create<LLVM::InsertValueOp>(
- loc, value, stride,
+ value = LLVM::InsertValueOp::create(
+ builder, loc, value, stride,
ArrayRef<int64_t>({kStridePosInMemRefDescriptor, pos}));
}
@@ -207,8 +211,8 @@ Value MemRefDescriptor::bufferPtr(OpBuilder &builder, Location loc,
? offset(builder, loc)
: createIndexAttrConstant(builder, loc, indexType, offsetCst);
Type elementType = converter.convertType(type.getElementType());
- ptr = builder.create<LLVM::GEPOp>(loc, ptr.getType(), elementType, ptr,
- offsetVal);
+ ptr = LLVM::GEPOp::create(builder, loc, ptr.getType(), elementType, ptr,
+ offsetVal);
return ptr;
}
@@ -303,7 +307,7 @@ UnrankedMemRefDescriptor::UnrankedMemRefDescriptor(Value descriptor)
UnrankedMemRefDescriptor UnrankedMemRefDescriptor::poison(OpBuilder &builder,
Location loc,
Type descriptorType) {
- Value descriptor = builder.create<LLVM::PoisonOp>(loc, descriptorType);
+ Value descriptor = LLVM::PoisonOp::create(builder, loc, descriptorType);
return UnrankedMemRefDescriptor(descriptor);
}
Value UnrankedMemRefDescriptor::rank(OpBuilder &builder, Location loc) const {
@@ -380,19 +384,19 @@ void UnrankedMemRefDescriptor::computeSizes(
builder, loc, indexType,
llvm::divideCeil(typeConverter.getPointerBitwidth(addressSpace), 8));
Value doublePointerSize =
- builder.create<LLVM::MulOp>(loc, indexType, two, pointerSize);
+ LLVM::MulOp::create(builder, loc, indexType, two, pointerSize);
// (1 + 2 * rank) * sizeof(index)
Value rank = desc.rank(builder, loc);
- Value doubleRank = builder.create<LLVM::MulOp>(loc, indexType, two, rank);
+ Value doubleRank = LLVM::MulOp::create(builder, loc, indexType, two, rank);
Value doubleRankIncremented =
- builder.create<LLVM::AddOp>(loc, indexType, doubleRank, one);
- Value rankIndexSize = builder.create<LLVM::MulOp>(
- loc, indexType, doubleRankIncremented, indexSize);
+ LLVM::AddOp::create(builder, loc, indexType, doubleRank, one);
+ Value rankIndexSize = LLVM::MulOp::create(builder, loc, indexType,
+ doubleRankIncremented, indexSize);
// Total allocation size.
- Value allocationSize = builder.create<LLVM::AddOp>(
- loc, indexType, doublePointerSize, rankIndexSize);
+ Value allocationSize = LLVM::AddOp::create(
+ builder, loc, indexType, doublePointerSize, rankIndexSize);
sizes.push_back(allocationSize);
}
}
@@ -400,13 +404,13 @@ void UnrankedMemRefDescriptor::computeSizes(
Value UnrankedMemRefDescriptor::allocatedPtr(
OpBuilder &builder, Location loc, Value memRefDescPtr,
LLVM::LLVMPointerType elemPtrType) {
- return builder.create<LLVM::LoadOp>(loc, elemPtrType, memRefDescPtr);
+ return LLVM::LoadOp::create(builder, loc, elemPtrType, memRefDescPtr);
}
void UnrankedMemRefDescriptor::setAllocatedPtr(
OpBuilder &builder, Location loc, Value memRefDescPtr,
LLVM::LLVMPointerType elemPtrType, Value allocatedPtr) {
- builder.create<LLVM::StoreOp>(loc, allocatedPtr, memRefDescPtr);
+ LLVM::StoreOp::create(builder, loc, allocatedPtr, memRefDescPtr);
}
static std::pair<Value, Type>
@@ -423,9 +427,9 @@ Value UnrankedMemRefDescriptor::alignedPtr(
castToElemPtrPtr(builder, loc, memRefDescPtr, elemPtrType);
Value alignedGep =
- builder.create<LLVM::GEPOp>(loc, elemPtrPtrType, elemPtrType,
- elementPtrPtr, ArrayRef<LLVM::GEPArg>{1});
- return builder.create<LLVM::LoadOp>(loc, elemPtrType, alignedGep);
+ LLVM::GEPOp::create(builder, loc, elemPtrPtrType, elemPtrType,
+ elementPtrPtr, ArrayRef<LLVM::GEPArg>{1});
+ return LLVM::LoadOp::create(builder, loc, elemPtrType, alignedGep);
}
void UnrankedMemRefDescriptor::setAlignedPtr(
@@ -435,9 +439,9 @@ void UnrankedMemRefDescriptor::setAlignedPtr(
castToElemPtrPtr(builder, loc, memRefDescPtr, elemPtrType);
Value alignedGep =
- builder.create<LLVM::GEPOp>(loc, elemPtrPtrType, elemPtrType,
- elementPtrPtr, ArrayRef<LLVM::GEPArg>{1});
- builder.create<LLVM::StoreOp>(loc, alignedPtr, alignedGep);
+ LLVM::GEPOp::create(builder, loc, elemPtrPtrType, elemPtrType,
+ elementPtrPtr, ArrayRef<LLVM::GEPArg>{1});
+ LLVM::StoreOp::create(builder, loc, alignedPtr, alignedGep);
}
Value UnrankedMemRefDescriptor::offsetBasePtr(
@@ -446,8 +450,8 @@ Value UnrankedMemRefDescriptor::offsetBasePtr(
auto [elementPtrPtr, elemPtrPtrType] =
castToElemPtrPtr(builder, loc, memRefDescPtr, elemPtrType);
- return builder.create<LLVM::GEPOp>(loc, elemPtrPtrType, elemPtrType,
- elementPtrPtr, ArrayRef<LLVM::GEPArg>{2});
+ return LLVM::GEPOp::create(builder, loc, elemPtrPtrType, elemPtrType,
+ elementPtrPtr, ArrayRef<LLVM::GEPArg>{2});
}
Value UnrankedMemRefDescriptor::offset(OpBuilder &builder, Location loc,
@@ -456,8 +460,8 @@ Value UnrankedMemRefDescriptor::offset(OpBuilder &builder, Location loc,
LLVM::LLVMPointerType elemPtrType) {
Value offsetPtr =
offsetBasePtr(builder, loc, typeConverter, memRefDescPtr, elemPtrType);
- return builder.create<LLVM::LoadOp>(loc, typeConverter.getIndexType(),
- offsetPtr);
+ return LLVM::LoadOp::create(builder, loc, typeConverter.getIndexType(),
+ offsetPtr);
}
void UnrankedMemRefDescriptor::setOffset(OpBuilder &builder, Location loc,
@@ -467,7 +471,7 @@ void UnrankedMemRefDescriptor::setOffset(OpBuilder &builder, Location loc,
Value offset) {
Value offsetPtr =
offsetBasePtr(builder, loc, typeConverter, memRefDescPtr, elemPtrType);
- builder.create<LLVM::StoreOp>(loc, offset, offsetPtr);
+ LLVM::StoreOp::create(builder, loc, offset, offsetPtr);
}
Value UnrankedMemRefDescriptor::sizeBasePtr(
@@ -477,8 +481,8 @@ Value UnrankedMemRefDescriptor::sizeBasePtr(
Type structTy = LLVM::LLVMStructType::getLiteral(
indexTy.getContext(), {elemPtrType, elemPtrType, indexTy, indexTy});
auto resultType = LLVM::LLVMPointerType::get(builder.getContext());
- return builder.create<LLVM::GEPOp>(loc, resultType, structTy, memRefDescPtr,
- ArrayRef<LLVM::GEPArg>{0, 3});
+ return LLVM::GEPOp::create(builder, loc, resultType, structTy, memRefDescPtr,
+ ArrayRef<LLVM::GEPArg>{0, 3});
}
Value UnrankedMemRefDescriptor::size(OpBuilder &builder, Location loc,
@@ -489,8 +493,8 @@ Value UnrankedMemRefDescriptor::size(OpBuilder &builder, Location loc,
auto ptrType = LLVM::LLVMPointerType::get(builder.getContext());
Value sizeStoreGep =
- builder.create<LLVM::GEPOp>(loc, ptrType, indexTy, sizeBasePtr, index);
- return builder.create<LLVM::LoadOp>(loc, indexTy, sizeStoreGep);
+ LLVM::GEPOp::create(builder, loc, ptrType, indexTy, sizeBasePtr, index);
+ return LLVM::LoadOp::create(builder, loc, indexTy, sizeStoreGep);
}
void UnrankedMemRefDescriptor::setSize(OpBuilder &builder, Location loc,
@@ -501,8 +505,8 @@ void UnrankedMemRefDescriptor::setSize(OpBuilder &builder, Location loc,
auto ptrType = LLVM::LLVMPointerType::get(builder.getContext());
Value sizeStoreGep =
- builder.create<LLVM::GEPOp>(loc, ptrType, indexTy, sizeBasePtr, index);
- builder.create<LLVM::StoreOp>(loc, size, sizeStoreGep);
+ LLVM::GEPOp::create(builder, loc, ptrType, indexTy, sizeBasePtr, index);
+ LLVM::StoreOp::create(builder, loc, size, sizeStoreGep);
}
Value UnrankedMemRefDescriptor::strideBasePtr(
@@ -511,7 +515,7 @@ Value UnrankedMemRefDescriptor::strideBasePtr(
Type indexTy = typeConverter.getIndexType();
auto ptrType = LLVM::LLVMPointerType::get(builder.getContext());
- return builder.create<LLVM::GEPOp>(loc, ptrType, indexTy, sizeBasePtr, rank);
+ return LLVM::GEPOp::create(builder, loc, ptrType, indexTy, sizeBasePtr, rank);
}
Value UnrankedMemRefDescriptor::stride(OpBuilder &builder, Location loc,
@@ -522,8 +526,8 @@ Value UnrankedMemRefDescriptor::stride(OpBuilder &builder, Location loc,
auto ptrType = LLVM::LLVMPointerType::get(builder.getContext());
Value strideStoreGep =
- builder.create<LLVM::GEPOp>(loc, ptrType, indexTy, strideBasePtr, index);
- return builder.create<LLVM::LoadOp>(loc, indexTy, strideStoreGep);
+ LLVM::GEPOp::create(builder, loc, ptrType, indexTy, strideBasePtr, index);
+ return LLVM::LoadOp::create(builder, loc, indexTy, strideStoreGep);
}
void UnrankedMemRefDescriptor::setStride(OpBuilder &builder, Location loc,
@@ -534,6 +538,6 @@ void UnrankedMemRefDescriptor::setStride(OpBuilder &builder, Location loc,
auto ptrType = LLVM::LLVMPointerType::get(builder.getContext());
Value strideStoreGep =
- builder.create<LLVM::GEPOp>(loc, ptrType, indexTy, strideBasePtr, index);
- builder.create<LLVM::StoreOp>(loc, stride, strideStoreGep);
+ LLVM::GEPOp::create(builder, loc, ptrType, indexTy, strideBasePtr, index);
+ LLVM::StoreOp::create(builder, loc, stride, strideStoreGep);
}
diff --git a/mlir/lib/Conversion/LLVMCommon/Pattern.cpp b/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
index c5f72f7..2568044 100644
--- a/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
@@ -57,8 +57,8 @@ Value ConvertToLLVMPattern::createIndexAttrConstant(OpBuilder &builder,
Location loc,
Type resultType,
int64_t value) {
- return builder.create<LLVM::ConstantOp>(loc, resultType,
- builder.getIndexAttr(value));
+ return LLVM::ConstantOp::create(builder, loc, resultType,
+ builder.getIndexAttr(value));
}
Value ConvertToLLVMPattern::getStridedElementPtr(
@@ -123,7 +123,7 @@ void ConvertToLLVMPattern::getMemRefDescriptorSizes(
runningStride = sizes[i];
else if (stride == ShapedType::kDynamic)
runningStride =
- rewriter.create<LLVM::MulOp>(loc, runningStride, sizes[i]);
+ LLVM::MulOp::create(rewriter, loc, runningStride, sizes[i]);
else
runningStride = createIndexAttrConstant(rewriter, loc, indexType, stride);
}
@@ -131,10 +131,10 @@ void ConvertToLLVMPattern::getMemRefDescriptorSizes(
// Buffer size in bytes.
Type elementType = typeConverter->convertType(memRefType.getElementType());
auto elementPtrType = LLVM::LLVMPointerType::get(rewriter.getContext());
- Value nullPtr = rewriter.create<LLVM::ZeroOp>(loc, elementPtrType);
- Value gepPtr = rewriter.create<LLVM::GEPOp>(
- loc, elementPtrType, elementType, nullPtr, runningStride);
- size = rewriter.create<LLVM::PtrToIntOp>(loc, getIndexType(), gepPtr);
+ Value nullPtr = LLVM::ZeroOp::create(rewriter, loc, elementPtrType);
+ Value gepPtr = LLVM::GEPOp::create(rewriter, loc, elementPtrType,
+ elementType, nullPtr, runningStride);
+ size = LLVM::PtrToIntOp::create(rewriter, loc, getIndexType(), gepPtr);
} else {
size = runningStride;
}
@@ -149,10 +149,10 @@ Value ConvertToLLVMPattern::getSizeInBytes(
// which is a common pattern of getting the size of a type in bytes.
Type llvmType = typeConverter->convertType(type);
auto convertedPtrType = LLVM::LLVMPointerType::get(rewriter.getContext());
- auto nullPtr = rewriter.create<LLVM::ZeroOp>(loc, convertedPtrType);
- auto gep = rewriter.create<LLVM::GEPOp>(loc, convertedPtrType, llvmType,
- nullPtr, ArrayRef<LLVM::GEPArg>{1});
- return rewriter.create<LLVM::PtrToIntOp>(loc, getIndexType(), gep);
+ auto nullPtr = LLVM::ZeroOp::create(rewriter, loc, convertedPtrType);
+ auto gep = LLVM::GEPOp::create(rewriter, loc, convertedPtrType, llvmType,
+ nullPtr, ArrayRef<LLVM::GEPArg>{1});
+ return LLVM::PtrToIntOp::create(rewriter, loc, getIndexType(), gep);
}
Value ConvertToLLVMPattern::getNumElements(
@@ -175,7 +175,7 @@ Value ConvertToLLVMPattern::getNumElements(
staticSize == ShapedType::kDynamic
? dynamicSizes[dynamicIndex++]
: createIndexAttrConstant(rewriter, loc, indexType, staticSize);
- numElements = rewriter.create<LLVM::MulOp>(loc, numElements, size);
+ numElements = LLVM::MulOp::create(rewriter, loc, numElements, size);
} else {
numElements =
staticSize == ShapedType::kDynamic
@@ -272,18 +272,17 @@ LogicalResult ConvertToLLVMPattern::copyUnrankedDescriptors(
// Allocate memory, copy, and free the source if necessary.
Value memory =
- toDynamic
- ? builder
- .create<LLVM::CallOp>(loc, mallocFunc.value(), allocationSize)
- .getResult()
- : builder.create<LLVM::AllocaOp>(loc, getPtrType(),
- IntegerType::get(getContext(), 8),
- allocationSize,
- /*alignment=*/0);
+ toDynamic ? LLVM::CallOp::create(builder, loc, mallocFunc.value(),
+ allocationSize)
+ .getResult()
+ : LLVM::AllocaOp::create(builder, loc, getPtrType(),
+ IntegerType::get(getContext(), 8),
+ allocationSize,
+ /*alignment=*/0);
Value source = desc.memRefDescPtr(builder, loc);
- builder.create<LLVM::MemcpyOp>(loc, memory, source, allocationSize, false);
+ LLVM::MemcpyOp::create(builder, loc, memory, source, allocationSize, false);
if (!toDynamic)
- builder.create<LLVM::CallOp>(loc, freeFunc.value(), source);
+ LLVM::CallOp::create(builder, loc, freeFunc.value(), source);
// Create a new descriptor. The same descriptor can be returned multiple
// times, attempting to modify its pointer can lead to memory leaks
@@ -349,8 +348,8 @@ LogicalResult LLVM::detail::oneToOneRewrite(
SmallVector<Value, 4> results;
results.reserve(numResults);
for (unsigned i = 0; i < numResults; ++i) {
- results.push_back(rewriter.create<LLVM::ExtractValueOp>(
- op->getLoc(), newOp->getResult(0), i));
+ results.push_back(LLVM::ExtractValueOp::create(rewriter, op->getLoc(),
+ newOp->getResult(0), i));
}
rewriter.replaceOp(op, results);
return success();
@@ -371,8 +370,8 @@ LogicalResult LLVM::detail::intrinsicRewrite(
if (numResults != 0)
resType = typeConverter.packOperationResults(op->getResultTypes());
- auto callIntrOp = rewriter.create<LLVM::CallIntrinsicOp>(
- loc, resType, rewriter.getStringAttr(intrinsic), operands);
+ auto callIntrOp = LLVM::CallIntrinsicOp::create(
+ rewriter, loc, resType, rewriter.getStringAttr(intrinsic), operands);
// Propagate attributes.
callIntrOp->setAttrs(op->getAttrDictionary());
@@ -388,7 +387,7 @@ LogicalResult LLVM::detail::intrinsicRewrite(
results.reserve(numResults);
Value intrRes = callIntrOp.getResults();
for (unsigned i = 0; i < numResults; ++i)
- results.push_back(rewriter.create<LLVM::ExtractValueOp>(loc, intrRes, i));
+ results.push_back(LLVM::ExtractValueOp::create(rewriter, loc, intrRes, i));
rewriter.replaceOp(op, results);
return success();
@@ -406,7 +405,7 @@ static unsigned getBitWidth(Type type) {
static Value createI32Constant(OpBuilder &builder, Location loc,
int32_t value) {
Type i32 = builder.getI32Type();
- return builder.create<LLVM::ConstantOp>(loc, i32, value);
+ return LLVM::ConstantOp::create(builder, loc, i32, value);
}
SmallVector<Value> mlir::LLVM::decomposeValue(OpBuilder &builder, Location loc,
@@ -418,17 +417,17 @@ SmallVector<Value> mlir::LLVM::decomposeValue(OpBuilder &builder, Location loc,
unsigned srcBitWidth = getBitWidth(srcType);
unsigned dstBitWidth = getBitWidth(dstType);
if (srcBitWidth == dstBitWidth) {
- Value cast = builder.create<LLVM::BitcastOp>(loc, dstType, src);
+ Value cast = LLVM::BitcastOp::create(builder, loc, dstType, src);
return {cast};
}
if (dstBitWidth > srcBitWidth) {
auto smallerInt = builder.getIntegerType(srcBitWidth);
if (srcType != smallerInt)
- src = builder.create<LLVM::BitcastOp>(loc, smallerInt, src);
+ src = LLVM::BitcastOp::create(builder, loc, smallerInt, src);
auto largerInt = builder.getIntegerType(dstBitWidth);
- Value res = builder.create<LLVM::ZExtOp>(loc, largerInt, src);
+ Value res = LLVM::ZExtOp::create(builder, loc, largerInt, src);
return {res};
}
assert(srcBitWidth % dstBitWidth == 0 &&
@@ -436,12 +435,12 @@ SmallVector<Value> mlir::LLVM::decomposeValue(OpBuilder &builder, Location loc,
int64_t numElements = srcBitWidth / dstBitWidth;
auto vecType = VectorType::get(numElements, dstType);
- src = builder.create<LLVM::BitcastOp>(loc, vecType, src);
+ src = LLVM::BitcastOp::create(builder, loc, vecType, src);
SmallVector<Value> res;
for (auto i : llvm::seq(numElements)) {
Value idx = createI32Constant(builder, loc, i);
- Value elem = builder.create<LLVM::ExtractElementOp>(loc, src, idx);
+ Value elem = LLVM::ExtractElementOp::create(builder, loc, src, idx);
res.emplace_back(elem);
}
@@ -461,28 +460,28 @@ Value mlir::LLVM::composeValue(OpBuilder &builder, Location loc, ValueRange src,
if (dstBitWidth < srcBitWidth) {
auto largerInt = builder.getIntegerType(srcBitWidth);
if (res.getType() != largerInt)
- res = builder.create<LLVM::BitcastOp>(loc, largerInt, res);
+ res = LLVM::BitcastOp::create(builder, loc, largerInt, res);
auto smallerInt = builder.getIntegerType(dstBitWidth);
- res = builder.create<LLVM::TruncOp>(loc, smallerInt, res);
+ res = LLVM::TruncOp::create(builder, loc, smallerInt, res);
}
if (res.getType() != dstType)
- res = builder.create<LLVM::BitcastOp>(loc, dstType, res);
+ res = LLVM::BitcastOp::create(builder, loc, dstType, res);
return res;
}
int64_t numElements = src.size();
auto srcType = VectorType::get(numElements, src.front().getType());
- Value res = builder.create<LLVM::PoisonOp>(loc, srcType);
+ Value res = LLVM::PoisonOp::create(builder, loc, srcType);
for (auto &&[i, elem] : llvm::enumerate(src)) {
Value idx = createI32Constant(builder, loc, i);
- res = builder.create<LLVM::InsertElementOp>(loc, srcType, res, elem, idx);
+ res = LLVM::InsertElementOp::create(builder, loc, srcType, res, elem, idx);
}
if (res.getType() != dstType)
- res = builder.create<LLVM::BitcastOp>(loc, dstType, res);
+ res = LLVM::BitcastOp::create(builder, loc, dstType, res);
return res;
}
@@ -518,20 +517,20 @@ Value mlir::LLVM::getStridedElementPtr(OpBuilder &builder, Location loc,
Value stride =
ShapedType::isDynamic(strides[i])
? memRefDescriptor.stride(builder, loc, i)
- : builder.create<LLVM::ConstantOp>(
- loc, indexType, builder.getIndexAttr(strides[i]));
- increment =
- builder.create<LLVM::MulOp>(loc, increment, stride, intOverflowFlags);
+ : LLVM::ConstantOp::create(builder, loc, indexType,
+ builder.getIndexAttr(strides[i]));
+ increment = LLVM::MulOp::create(builder, loc, increment, stride,
+ intOverflowFlags);
}
- index = index ? builder.create<LLVM::AddOp>(loc, index, increment,
- intOverflowFlags)
+ index = index ? LLVM::AddOp::create(builder, loc, index, increment,
+ intOverflowFlags)
: increment;
}
Type elementPtrType = memRefDescriptor.getElementPtrType();
- return index ? builder.create<LLVM::GEPOp>(
- loc, elementPtrType,
- converter.convertType(type.getElementType()), base, index,
- noWrapFlags)
- : base;
+ return index
+ ? LLVM::GEPOp::create(builder, loc, elementPtrType,
+ converter.convertType(type.getElementType()),
+ base, index, noWrapFlags)
+ : base;
}
diff --git a/mlir/lib/Conversion/LLVMCommon/PrintCallHelper.cpp b/mlir/lib/Conversion/LLVMCommon/PrintCallHelper.cpp
index 49c73fb..d95aeba 100644
--- a/mlir/lib/Conversion/LLVMCommon/PrintCallHelper.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/PrintCallHelper.cpp
@@ -66,23 +66,23 @@ LogicalResult mlir::LLVM::createPrintStrCall(
DenseElementsAttr::get(dataAttrType, llvm::ArrayRef(elementVals));
auto arrayTy =
LLVM::LLVMArrayType::get(IntegerType::get(ctx, 8), elementVals.size());
- auto globalOp = builder.create<LLVM::GlobalOp>(
- loc, arrayTy, /*constant=*/true, LLVM::Linkage::Private,
+ auto globalOp = LLVM::GlobalOp::create(
+ builder, loc, arrayTy, /*constant=*/true, LLVM::Linkage::Private,
ensureSymbolNameIsUnique(moduleOp, symbolName, symbolTables), dataAttr);
auto ptrTy = LLVM::LLVMPointerType::get(builder.getContext());
// Emit call to `printStr` in runtime library.
builder.restoreInsertionPoint(ip);
auto msgAddr =
- builder.create<LLVM::AddressOfOp>(loc, ptrTy, globalOp.getName());
+ LLVM::AddressOfOp::create(builder, loc, ptrTy, globalOp.getName());
SmallVector<LLVM::GEPArg> indices(1, 0);
Value gep =
- builder.create<LLVM::GEPOp>(loc, ptrTy, arrayTy, msgAddr, indices);
+ LLVM::GEPOp::create(builder, loc, ptrTy, arrayTy, msgAddr, indices);
FailureOr<LLVM::LLVMFuncOp> printer =
LLVM::lookupOrCreatePrintStringFn(builder, moduleOp, runtimeFunctionName);
if (failed(printer))
return failure();
- builder.create<LLVM::CallOp>(loc, TypeRange(),
- SymbolRefAttr::get(printer.value()), gep);
+ LLVM::CallOp::create(builder, loc, TypeRange(),
+ SymbolRefAttr::get(printer.value()), gep);
return success();
}
diff --git a/mlir/lib/Conversion/LLVMCommon/StructBuilder.cpp b/mlir/lib/Conversion/LLVMCommon/StructBuilder.cpp
index 1cd0bd8..13ed4628 100644
--- a/mlir/lib/Conversion/LLVMCommon/StructBuilder.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/StructBuilder.cpp
@@ -24,10 +24,10 @@ StructBuilder::StructBuilder(Value v) : value(v), structType(v.getType()) {
Value StructBuilder::extractPtr(OpBuilder &builder, Location loc,
unsigned pos) const {
- return builder.create<LLVM::ExtractValueOp>(loc, value, pos);
+ return LLVM::ExtractValueOp::create(builder, loc, value, pos);
}
void StructBuilder::setPtr(OpBuilder &builder, Location loc, unsigned pos,
Value ptr) {
- value = builder.create<LLVM::InsertValueOp>(loc, value, ptr, pos);
+ value = LLVM::InsertValueOp::create(builder, loc, value, ptr, pos);
}
diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
index 7312594..1a9bf56 100644
--- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
@@ -91,7 +91,7 @@ static Value unrankedMemRefMaterialization(OpBuilder &builder,
packUnrankedMemRefDesc(builder, resultType, inputs, loc, converter);
if (!packed)
return Value();
- return builder.create<UnrealizedConversionCastOp>(loc, resultType, packed)
+ return UnrealizedConversionCastOp::create(builder, loc, resultType, packed)
.getResult(0);
}
@@ -107,7 +107,7 @@ static Value rankedMemRefMaterialization(OpBuilder &builder,
packRankedMemRefDesc(builder, resultType, inputs, loc, converter);
if (!packed)
return Value();
- return builder.create<UnrealizedConversionCastOp>(loc, resultType, packed)
+ return UnrealizedConversionCastOp::create(builder, loc, resultType, packed)
.getResult(0);
}
@@ -224,12 +224,12 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
// non-LLVM types persist after an LLVM conversion.
addSourceMaterialization([&](OpBuilder &builder, Type resultType,
ValueRange inputs, Location loc) {
- return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
+ return UnrealizedConversionCastOp::create(builder, loc, resultType, inputs)
.getResult(0);
});
addTargetMaterialization([&](OpBuilder &builder, Type resultType,
ValueRange inputs, Location loc) {
- return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
+ return UnrealizedConversionCastOp::create(builder, loc, resultType, inputs)
.getResult(0);
});
@@ -731,12 +731,12 @@ Value LLVMTypeConverter::promoteOneMemRefDescriptor(Location loc, Value operand,
// Alloca with proper alignment. We do not expect optimizations of this
// alloca op and so we omit allocating at the entry block.
auto ptrType = LLVM::LLVMPointerType::get(builder.getContext());
- Value one = builder.create<LLVM::ConstantOp>(loc, builder.getI64Type(),
- builder.getIndexAttr(1));
+ Value one = LLVM::ConstantOp::create(builder, loc, builder.getI64Type(),
+ builder.getIndexAttr(1));
Value allocated =
- builder.create<LLVM::AllocaOp>(loc, ptrType, operand.getType(), one);
+ LLVM::AllocaOp::create(builder, loc, ptrType, operand.getType(), one);
// Store into the alloca'ed descriptor.
- builder.create<LLVM::StoreOp>(loc, operand, allocated);
+ LLVM::StoreOp::create(builder, loc, operand, allocated);
return allocated;
}
diff --git a/mlir/lib/Conversion/LLVMCommon/VectorPattern.cpp b/mlir/lib/Conversion/LLVMCommon/VectorPattern.cpp
index bf3f317..e7dd0b5 100644
--- a/mlir/lib/Conversion/LLVMCommon/VectorPattern.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/VectorPattern.cpp
@@ -87,17 +87,17 @@ LogicalResult LLVM::detail::handleMultidimensionalVectors(
auto result1DVectorTy = resultTypeInfo.llvm1DVectorTy;
auto resultNDVectoryTy = resultTypeInfo.llvmNDVectorTy;
auto loc = op->getLoc();
- Value desc = rewriter.create<LLVM::PoisonOp>(loc, resultNDVectoryTy);
+ Value desc = LLVM::PoisonOp::create(rewriter, loc, resultNDVectoryTy);
nDVectorIterate(resultTypeInfo, rewriter, [&](ArrayRef<int64_t> position) {
// For this unrolled `position` corresponding to the `linearIndex`^th
// element, extract operand vectors
SmallVector<Value, 4> extractedOperands;
for (const auto &operand : llvm::enumerate(operands)) {
- extractedOperands.push_back(rewriter.create<LLVM::ExtractValueOp>(
- loc, operand.value(), position));
+ extractedOperands.push_back(LLVM::ExtractValueOp::create(
+ rewriter, loc, operand.value(), position));
}
Value newVal = createOperand(result1DVectorTy, extractedOperands);
- desc = rewriter.create<LLVM::InsertValueOp>(loc, desc, newVal, position);
+ desc = LLVM::InsertValueOp::create(rewriter, loc, desc, newVal, position);
});
rewriter.replaceOp(op, desc);
return success();