forked from OSchip/llvm-project
[flang][NFC] Use prefixed accessors for fircg dialect
The raw accessor is going away soon so switch to prefixed accessors in the fircg dialect. The main dialect was switched some months ago. https://github.com/llvm/llvm-project/issues/58090 Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D135061
This commit is contained in:
parent
d90633a74b
commit
a89b04805a
|
@ -20,7 +20,6 @@ include "flang/Optimizer/Dialect/FIRTypes.td"
|
||||||
def fircg_Dialect : Dialect {
|
def fircg_Dialect : Dialect {
|
||||||
let name = "fircg";
|
let name = "fircg";
|
||||||
let cppNamespace = "::fir::cg";
|
let cppNamespace = "::fir::cg";
|
||||||
let emitAccessorPrefix = kEmitAccessorPrefix_Raw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base class for FIR CG operations.
|
// Base class for FIR CG operations.
|
||||||
|
@ -69,20 +68,20 @@ def fircg_XEmboxOp : fircg_Op<"ext_embox", [AttrSizedOperandSegments]> {
|
||||||
|
|
||||||
let extraClassDeclaration = [{
|
let extraClassDeclaration = [{
|
||||||
// The rank of the entity being emboxed
|
// The rank of the entity being emboxed
|
||||||
unsigned getRank() { return shape().size(); }
|
unsigned getRank() { return getShape().size(); }
|
||||||
|
|
||||||
// The rank of the result. A slice op can reduce the rank.
|
// The rank of the result. A slice op can reduce the rank.
|
||||||
unsigned getOutRank();
|
unsigned getOutRank();
|
||||||
|
|
||||||
// The shape operands are mandatory and always start at 1.
|
// The shape operands are mandatory and always start at 1.
|
||||||
unsigned shapeOffset() { return 1; }
|
unsigned shapeOffset() { return 1; }
|
||||||
unsigned shiftOffset() { return shapeOffset() + shape().size(); }
|
unsigned shiftOffset() { return shapeOffset() + getShape().size(); }
|
||||||
unsigned sliceOffset() { return shiftOffset() + shift().size(); }
|
unsigned sliceOffset() { return shiftOffset() + getShift().size(); }
|
||||||
unsigned subcomponentOffset() { return sliceOffset() + slice().size(); }
|
unsigned subcomponentOffset() { return sliceOffset() + getSlice().size(); }
|
||||||
unsigned substrOffset() {
|
unsigned substrOffset() {
|
||||||
return subcomponentOffset() + subcomponent().size();
|
return subcomponentOffset() + getSubcomponent().size();
|
||||||
}
|
}
|
||||||
unsigned lenParamOffset() { return substrOffset() + substr().size(); }
|
unsigned lenParamOffset() { return substrOffset() + getSubstr().size(); }
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,11 +129,11 @@ def fircg_XReboxOp : fircg_Op<"ext_rebox", [AttrSizedOperandSegments]> {
|
||||||
unsigned getOutRank();
|
unsigned getOutRank();
|
||||||
|
|
||||||
unsigned shapeOffset() { return 1; }
|
unsigned shapeOffset() { return 1; }
|
||||||
unsigned shiftOffset() { return shapeOffset() + shape().size(); }
|
unsigned shiftOffset() { return shapeOffset() + getShape().size(); }
|
||||||
unsigned sliceOffset() { return shiftOffset() + shift().size(); }
|
unsigned sliceOffset() { return shiftOffset() + getShift().size(); }
|
||||||
unsigned subcomponentOffset() { return sliceOffset() + slice().size(); }
|
unsigned subcomponentOffset() { return sliceOffset() + getSlice().size(); }
|
||||||
unsigned substrOffset() {
|
unsigned substrOffset() {
|
||||||
return subcomponentOffset() + subcomponent().size();
|
return subcomponentOffset() + getSubcomponent().size();
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
@ -188,13 +187,13 @@ def fircg_XArrayCoorOp : fircg_Op<"ext_array_coor", [AttrSizedOperandSegments]>
|
||||||
|
|
||||||
// Shape is optional, but if it exists, it will be at offset 1.
|
// Shape is optional, but if it exists, it will be at offset 1.
|
||||||
unsigned shapeOffset() { return 1; }
|
unsigned shapeOffset() { return 1; }
|
||||||
unsigned shiftOffset() { return shapeOffset() + shape().size(); }
|
unsigned shiftOffset() { return shapeOffset() + getShape().size(); }
|
||||||
unsigned sliceOffset() { return shiftOffset() + shift().size(); }
|
unsigned sliceOffset() { return shiftOffset() + getShift().size(); }
|
||||||
unsigned subcomponentOffset() { return sliceOffset() + slice().size(); }
|
unsigned subcomponentOffset() { return sliceOffset() + getSlice().size(); }
|
||||||
unsigned indicesOffset() {
|
unsigned indicesOffset() {
|
||||||
return subcomponentOffset() + subcomponent().size();
|
return subcomponentOffset() + getSubcomponent().size();
|
||||||
}
|
}
|
||||||
unsigned lenParamsOffset() { return indicesOffset() + indices().size(); }
|
unsigned lenParamsOffset() { return indicesOffset() + getIndices().size(); }
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ fir::FIRCodeGenDialect::~FIRCodeGenDialect() {
|
||||||
#include "flang/Optimizer/CodeGen/CGOps.cpp.inc"
|
#include "flang/Optimizer/CodeGen/CGOps.cpp.inc"
|
||||||
|
|
||||||
unsigned fir::cg::XEmboxOp::getOutRank() {
|
unsigned fir::cg::XEmboxOp::getOutRank() {
|
||||||
if (slice().empty())
|
if (getSlice().empty())
|
||||||
return getRank();
|
return getRank();
|
||||||
auto outRank = fir::SliceOp::getOutputRank(slice());
|
auto outRank = fir::SliceOp::getOutputRank(getSlice());
|
||||||
assert(outRank >= 1);
|
assert(outRank >= 1);
|
||||||
return outRank;
|
return outRank;
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,17 @@ unsigned fir::cg::XReboxOp::getOutRank() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned fir::cg::XReboxOp::getRank() {
|
unsigned fir::cg::XReboxOp::getRank() {
|
||||||
if (auto seqTy = fir::dyn_cast_ptrOrBoxEleTy(box().getType())
|
if (auto seqTy = fir::dyn_cast_ptrOrBoxEleTy(getBox().getType())
|
||||||
.dyn_cast<fir::SequenceType>())
|
.dyn_cast<fir::SequenceType>())
|
||||||
return seqTy.getDimension();
|
return seqTy.getDimension();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned fir::cg::XArrayCoorOp::getRank() {
|
unsigned fir::cg::XArrayCoorOp::getRank() {
|
||||||
auto memrefTy = memref().getType();
|
auto memrefTy = getMemref().getType();
|
||||||
if (memrefTy.isa<fir::BoxType>())
|
if (memrefTy.isa<fir::BoxType>())
|
||||||
if (auto seqty =
|
if (auto seqty =
|
||||||
fir::dyn_cast_ptrOrBoxEleTy(memrefTy).dyn_cast<fir::SequenceType>())
|
fir::dyn_cast_ptrOrBoxEleTy(memrefTy).dyn_cast<fir::SequenceType>())
|
||||||
return seqty.getDimension();
|
return seqty.getDimension();
|
||||||
return shape().size();
|
return getShape().size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1349,8 +1349,8 @@ struct EmboxCommonConversion : public FIROpConversion<OP> {
|
||||||
|
|
||||||
llvm::SmallVector<mlir::Value> typeparams = lenParams;
|
llvm::SmallVector<mlir::Value> typeparams = lenParams;
|
||||||
if constexpr (!std::is_same_v<BOX, fir::EmboxOp>) {
|
if constexpr (!std::is_same_v<BOX, fir::EmboxOp>) {
|
||||||
if (!box.substr().empty() && fir::hasDynamicSize(boxTy.getEleTy()))
|
if (!box.getSubstr().empty() && fir::hasDynamicSize(boxTy.getEleTy()))
|
||||||
typeparams.push_back(box.substr()[1]);
|
typeparams.push_back(box.getSubstr()[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write each of the fields with the appropriate values
|
// Write each of the fields with the appropriate values
|
||||||
|
@ -1461,7 +1461,7 @@ struct EmboxCommonConversion : public FIROpConversion<OP> {
|
||||||
"fir.embox codegen dynamic size component in derived type");
|
"fir.embox codegen dynamic size component in derived type");
|
||||||
indices.append(operands.begin() + xbox.subcomponentOffset(),
|
indices.append(operands.begin() + xbox.subcomponentOffset(),
|
||||||
operands.begin() + xbox.subcomponentOffset() +
|
operands.begin() + xbox.subcomponentOffset() +
|
||||||
xbox.subcomponent().size());
|
xbox.getSubcomponent().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the embox is not in a globalOp body, allocate storage for the box;
|
/// If the embox is not in a globalOp body, allocate storage for the box;
|
||||||
|
@ -1534,11 +1534,11 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
|
||||||
// Generate the triples in the dims field of the descriptor
|
// Generate the triples in the dims field of the descriptor
|
||||||
auto i64Ty = mlir::IntegerType::get(xbox.getContext(), 64);
|
auto i64Ty = mlir::IntegerType::get(xbox.getContext(), 64);
|
||||||
mlir::Value base = operands[0];
|
mlir::Value base = operands[0];
|
||||||
assert(!xbox.shape().empty() && "must have a shape");
|
assert(!xbox.getShape().empty() && "must have a shape");
|
||||||
unsigned shapeOffset = xbox.shapeOffset();
|
unsigned shapeOffset = xbox.shapeOffset();
|
||||||
bool hasShift = !xbox.shift().empty();
|
bool hasShift = !xbox.getShift().empty();
|
||||||
unsigned shiftOffset = xbox.shiftOffset();
|
unsigned shiftOffset = xbox.shiftOffset();
|
||||||
bool hasSlice = !xbox.slice().empty();
|
bool hasSlice = !xbox.getSlice().empty();
|
||||||
unsigned sliceOffset = xbox.sliceOffset();
|
unsigned sliceOffset = xbox.sliceOffset();
|
||||||
mlir::Location loc = xbox.getLoc();
|
mlir::Location loc = xbox.getLoc();
|
||||||
mlir::Value zero = genConstantIndex(loc, i64Ty, rewriter, 0);
|
mlir::Value zero = genConstantIndex(loc, i64Ty, rewriter, 0);
|
||||||
|
@ -1549,7 +1549,7 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
|
||||||
llvm::SmallVector<mlir::Value> cstInteriorIndices;
|
llvm::SmallVector<mlir::Value> cstInteriorIndices;
|
||||||
unsigned constRows = 0;
|
unsigned constRows = 0;
|
||||||
mlir::Value ptrOffset = zero;
|
mlir::Value ptrOffset = zero;
|
||||||
mlir::Type memEleTy = fir::dyn_cast_ptrEleTy(xbox.memref().getType());
|
mlir::Type memEleTy = fir::dyn_cast_ptrEleTy(xbox.getMemref().getType());
|
||||||
assert(memEleTy.isa<fir::SequenceType>());
|
assert(memEleTy.isa<fir::SequenceType>());
|
||||||
auto seqTy = memEleTy.cast<fir::SequenceType>();
|
auto seqTy = memEleTy.cast<fir::SequenceType>();
|
||||||
mlir::Type seqEleTy = seqTy.getEleTy();
|
mlir::Type seqEleTy = seqTy.getEleTy();
|
||||||
|
@ -1567,8 +1567,8 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
|
||||||
constRows = seqTy.getConstantRows();
|
constRows = seqTy.getConstantRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hasSubcomp = !xbox.subcomponent().empty();
|
const auto hasSubcomp = !xbox.getSubcomponent().empty();
|
||||||
const bool hasSubstr = !xbox.substr().empty();
|
const bool hasSubstr = !xbox.getSubstr().empty();
|
||||||
// Initial element stride that will be use to compute the step in
|
// Initial element stride that will be use to compute the step in
|
||||||
// each dimension.
|
// each dimension.
|
||||||
mlir::Value prevDimByteStride = eleSize;
|
mlir::Value prevDimByteStride = eleSize;
|
||||||
|
@ -1612,7 +1612,7 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
|
||||||
rewriter.create<mlir::LLVM::AddOp>(loc, i64Ty, dimOff, ptrOffset);
|
rewriter.create<mlir::LLVM::AddOp>(loc, i64Ty, dimOff, ptrOffset);
|
||||||
}
|
}
|
||||||
if (mlir::isa_and_nonnull<fir::UndefOp>(
|
if (mlir::isa_and_nonnull<fir::UndefOp>(
|
||||||
xbox.slice()[3 * di + 1].getDefiningOp())) {
|
xbox.getSlice()[3 * di + 1].getDefiningOp())) {
|
||||||
// This dimension contains a scalar expression in the array slice op.
|
// This dimension contains a scalar expression in the array slice op.
|
||||||
// The dimension is loop invariant, will be dropped, and will not
|
// The dimension is loop invariant, will be dropped, and will not
|
||||||
// appear in the descriptor.
|
// appear in the descriptor.
|
||||||
|
@ -1678,7 +1678,7 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
|
||||||
llvm::SmallVector<mlir::Value> fieldIndices;
|
llvm::SmallVector<mlir::Value> fieldIndices;
|
||||||
llvm::Optional<mlir::Value> substringOffset;
|
llvm::Optional<mlir::Value> substringOffset;
|
||||||
if (hasSubcomp)
|
if (hasSubcomp)
|
||||||
getSubcomponentIndices(xbox, xbox.memref(), operands, fieldIndices);
|
getSubcomponentIndices(xbox, xbox.getMemref(), operands, fieldIndices);
|
||||||
if (hasSubstr)
|
if (hasSubstr)
|
||||||
substringOffset = operands[xbox.substrOffset()];
|
substringOffset = operands[xbox.substrOffset()];
|
||||||
base = genBoxOffsetGep(rewriter, loc, base, ptrOffset, cstInteriorIndices,
|
base = genBoxOffsetGep(rewriter, loc, base, ptrOffset, cstInteriorIndices,
|
||||||
|
@ -1748,7 +1748,7 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
|
||||||
mlir::Value baseAddr =
|
mlir::Value baseAddr =
|
||||||
loadBaseAddrFromBox(loc, baseTy, loweredBox, rewriter);
|
loadBaseAddrFromBox(loc, baseTy, loweredBox, rewriter);
|
||||||
|
|
||||||
if (!rebox.slice().empty() || !rebox.subcomponent().empty())
|
if (!rebox.getSlice().empty() || !rebox.getSubcomponent().empty())
|
||||||
return sliceBox(rebox, dest, baseAddr, inputExtents, inputStrides,
|
return sliceBox(rebox, dest, baseAddr, inputExtents, inputStrides,
|
||||||
operands, rewriter);
|
operands, rewriter);
|
||||||
return reshapeBox(rebox, dest, baseAddr, inputExtents, inputStrides,
|
return reshapeBox(rebox, dest, baseAddr, inputExtents, inputStrides,
|
||||||
|
@ -1799,7 +1799,7 @@ private:
|
||||||
mlir::Type idxTy = lowerTy().indexType();
|
mlir::Type idxTy = lowerTy().indexType();
|
||||||
mlir::Value zero = genConstantIndex(loc, idxTy, rewriter, 0);
|
mlir::Value zero = genConstantIndex(loc, idxTy, rewriter, 0);
|
||||||
// Apply subcomponent and substring shift on base address.
|
// Apply subcomponent and substring shift on base address.
|
||||||
if (!rebox.subcomponent().empty() || !rebox.substr().empty()) {
|
if (!rebox.getSubcomponent().empty() || !rebox.getSubstr().empty()) {
|
||||||
// Cast to inputEleTy* so that a GEP can be used.
|
// Cast to inputEleTy* so that a GEP can be used.
|
||||||
mlir::Type inputEleTy = getInputEleTy(rebox);
|
mlir::Type inputEleTy = getInputEleTy(rebox);
|
||||||
auto llvmElePtrTy =
|
auto llvmElePtrTy =
|
||||||
|
@ -1808,16 +1808,16 @@ private:
|
||||||
|
|
||||||
llvm::SmallVector<mlir::Value> fieldIndices;
|
llvm::SmallVector<mlir::Value> fieldIndices;
|
||||||
llvm::Optional<mlir::Value> substringOffset;
|
llvm::Optional<mlir::Value> substringOffset;
|
||||||
if (!rebox.subcomponent().empty())
|
if (!rebox.getSubcomponent().empty())
|
||||||
getSubcomponentIndices(rebox, rebox.box(), operands, fieldIndices);
|
getSubcomponentIndices(rebox, rebox.getBox(), operands, fieldIndices);
|
||||||
if (!rebox.substr().empty())
|
if (!rebox.getSubstr().empty())
|
||||||
substringOffset = operands[rebox.substrOffset()];
|
substringOffset = operands[rebox.substrOffset()];
|
||||||
base = genBoxOffsetGep(rewriter, loc, base, zero,
|
base = genBoxOffsetGep(rewriter, loc, base, zero,
|
||||||
/*cstInteriorIndices=*/llvm::None, fieldIndices,
|
/*cstInteriorIndices=*/llvm::None, fieldIndices,
|
||||||
substringOffset);
|
substringOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rebox.slice().empty())
|
if (rebox.getSlice().empty())
|
||||||
// The array section is of the form array[%component][substring], keep
|
// The array section is of the form array[%component][substring], keep
|
||||||
// the input array extents and strides.
|
// the input array extents and strides.
|
||||||
return finalizeRebox(rebox, dest, base, /*lbounds*/ llvm::None,
|
return finalizeRebox(rebox, dest, base, /*lbounds*/ llvm::None,
|
||||||
|
@ -1831,7 +1831,7 @@ private:
|
||||||
llvm::SmallVector<mlir::Value> slicedExtents;
|
llvm::SmallVector<mlir::Value> slicedExtents;
|
||||||
llvm::SmallVector<mlir::Value> slicedStrides;
|
llvm::SmallVector<mlir::Value> slicedStrides;
|
||||||
mlir::Value one = genConstantIndex(loc, idxTy, rewriter, 1);
|
mlir::Value one = genConstantIndex(loc, idxTy, rewriter, 1);
|
||||||
const bool sliceHasOrigins = !rebox.shift().empty();
|
const bool sliceHasOrigins = !rebox.getShift().empty();
|
||||||
unsigned sliceOps = rebox.sliceOffset();
|
unsigned sliceOps = rebox.sliceOffset();
|
||||||
unsigned shiftOps = rebox.shiftOffset();
|
unsigned shiftOps = rebox.shiftOffset();
|
||||||
auto strideOps = inputStrides.begin();
|
auto strideOps = inputStrides.begin();
|
||||||
|
@ -1883,8 +1883,8 @@ private:
|
||||||
mlir::ConversionPatternRewriter &rewriter) const {
|
mlir::ConversionPatternRewriter &rewriter) const {
|
||||||
mlir::ValueRange reboxShifts{operands.begin() + rebox.shiftOffset(),
|
mlir::ValueRange reboxShifts{operands.begin() + rebox.shiftOffset(),
|
||||||
operands.begin() + rebox.shiftOffset() +
|
operands.begin() + rebox.shiftOffset() +
|
||||||
rebox.shift().size()};
|
rebox.getShift().size()};
|
||||||
if (rebox.shape().empty()) {
|
if (rebox.getShape().empty()) {
|
||||||
// Only setting new lower bounds.
|
// Only setting new lower bounds.
|
||||||
return finalizeRebox(rebox, dest, base, reboxShifts, inputExtents,
|
return finalizeRebox(rebox, dest, base, reboxShifts, inputExtents,
|
||||||
inputStrides, rewriter);
|
inputStrides, rewriter);
|
||||||
|
@ -1905,7 +1905,7 @@ private:
|
||||||
mlir::Value stride = inputStrides.empty()
|
mlir::Value stride = inputStrides.empty()
|
||||||
? genConstantIndex(loc, idxTy, rewriter, 1)
|
? genConstantIndex(loc, idxTy, rewriter, 1)
|
||||||
: inputStrides[0];
|
: inputStrides[0];
|
||||||
for (unsigned i = 0; i < rebox.shape().size(); ++i) {
|
for (unsigned i = 0; i < rebox.getShape().size(); ++i) {
|
||||||
mlir::Value rawExtent = operands[rebox.shapeOffset() + i];
|
mlir::Value rawExtent = operands[rebox.shapeOffset() + i];
|
||||||
mlir::Value extent = integerCast(loc, rewriter, idxTy, rawExtent);
|
mlir::Value extent = integerCast(loc, rewriter, idxTy, rawExtent);
|
||||||
newExtents.emplace_back(extent);
|
newExtents.emplace_back(extent);
|
||||||
|
@ -1919,7 +1919,7 @@ private:
|
||||||
|
|
||||||
/// Return scalar element type of the input box.
|
/// Return scalar element type of the input box.
|
||||||
static mlir::Type getInputEleTy(fir::cg::XReboxOp rebox) {
|
static mlir::Type getInputEleTy(fir::cg::XReboxOp rebox) {
|
||||||
auto ty = fir::dyn_cast_ptrOrBoxEleTy(rebox.box().getType());
|
auto ty = fir::dyn_cast_ptrOrBoxEleTy(rebox.getBox().getType());
|
||||||
if (auto seqTy = ty.dyn_cast<fir::SequenceType>())
|
if (auto seqTy = ty.dyn_cast<fir::SequenceType>())
|
||||||
return seqTy.getEleTy();
|
return seqTy.getEleTy();
|
||||||
return ty;
|
return ty;
|
||||||
|
@ -2104,22 +2104,22 @@ struct XArrayCoorOpConversion
|
||||||
auto loc = coor.getLoc();
|
auto loc = coor.getLoc();
|
||||||
mlir::ValueRange operands = adaptor.getOperands();
|
mlir::ValueRange operands = adaptor.getOperands();
|
||||||
unsigned rank = coor.getRank();
|
unsigned rank = coor.getRank();
|
||||||
assert(coor.indices().size() == rank);
|
assert(coor.getIndices().size() == rank);
|
||||||
assert(coor.shape().empty() || coor.shape().size() == rank);
|
assert(coor.getShape().empty() || coor.getShape().size() == rank);
|
||||||
assert(coor.shift().empty() || coor.shift().size() == rank);
|
assert(coor.getShift().empty() || coor.getShift().size() == rank);
|
||||||
assert(coor.slice().empty() || coor.slice().size() == 3 * rank);
|
assert(coor.getSlice().empty() || coor.getSlice().size() == 3 * rank);
|
||||||
mlir::Type idxTy = lowerTy().indexType();
|
mlir::Type idxTy = lowerTy().indexType();
|
||||||
unsigned indexOffset = coor.indicesOffset();
|
unsigned indexOffset = coor.indicesOffset();
|
||||||
unsigned shapeOffset = coor.shapeOffset();
|
unsigned shapeOffset = coor.shapeOffset();
|
||||||
unsigned shiftOffset = coor.shiftOffset();
|
unsigned shiftOffset = coor.shiftOffset();
|
||||||
unsigned sliceOffset = coor.sliceOffset();
|
unsigned sliceOffset = coor.sliceOffset();
|
||||||
auto sliceOps = coor.slice().begin();
|
auto sliceOps = coor.getSlice().begin();
|
||||||
mlir::Value one = genConstantIndex(loc, idxTy, rewriter, 1);
|
mlir::Value one = genConstantIndex(loc, idxTy, rewriter, 1);
|
||||||
mlir::Value prevExt = one;
|
mlir::Value prevExt = one;
|
||||||
mlir::Value offset = genConstantIndex(loc, idxTy, rewriter, 0);
|
mlir::Value offset = genConstantIndex(loc, idxTy, rewriter, 0);
|
||||||
const bool isShifted = !coor.shift().empty();
|
const bool isShifted = !coor.getShift().empty();
|
||||||
const bool isSliced = !coor.slice().empty();
|
const bool isSliced = !coor.getSlice().empty();
|
||||||
const bool baseIsBoxed = coor.memref().getType().isa<fir::BoxType>();
|
const bool baseIsBoxed = coor.getMemref().getType().isa<fir::BoxType>();
|
||||||
|
|
||||||
// For each dimension of the array, generate the offset calculation.
|
// For each dimension of the array, generate the offset calculation.
|
||||||
for (unsigned i = 0; i < rank; ++i, ++indexOffset, ++shapeOffset,
|
for (unsigned i = 0; i < rank; ++i, ++indexOffset, ++shapeOffset,
|
||||||
|
@ -2180,14 +2180,14 @@ struct XArrayCoorOpConversion
|
||||||
llvm::SmallVector<mlir::LLVM::GEPArg> args{offset};
|
llvm::SmallVector<mlir::LLVM::GEPArg> args{offset};
|
||||||
auto addr =
|
auto addr =
|
||||||
rewriter.create<mlir::LLVM::GEPOp>(loc, voidPtrTy, base, args);
|
rewriter.create<mlir::LLVM::GEPOp>(loc, voidPtrTy, base, args);
|
||||||
if (coor.subcomponent().empty()) {
|
if (coor.getSubcomponent().empty()) {
|
||||||
rewriter.replaceOpWithNewOp<mlir::LLVM::BitcastOp>(coor, ty, addr);
|
rewriter.replaceOpWithNewOp<mlir::LLVM::BitcastOp>(coor, ty, addr);
|
||||||
return mlir::success();
|
return mlir::success();
|
||||||
}
|
}
|
||||||
auto casted = rewriter.create<mlir::LLVM::BitcastOp>(loc, baseTy, addr);
|
auto casted = rewriter.create<mlir::LLVM::BitcastOp>(loc, baseTy, addr);
|
||||||
args.clear();
|
args.clear();
|
||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
if (!coor.lenParams().empty()) {
|
if (!coor.getLenParams().empty()) {
|
||||||
// If type parameters are present, then we don't want to use a GEPOp
|
// If type parameters are present, then we don't want to use a GEPOp
|
||||||
// as below, as the LLVM struct type cannot be statically defined.
|
// as below, as the LLVM struct type cannot be statically defined.
|
||||||
TODO(loc, "derived type with type parameters");
|
TODO(loc, "derived type with type parameters");
|
||||||
|
@ -2204,14 +2204,14 @@ struct XArrayCoorOpConversion
|
||||||
// element offset and the base type is kept in the GEP unless the element
|
// element offset and the base type is kept in the GEP unless the element
|
||||||
// type size is itself dynamic.
|
// type size is itself dynamic.
|
||||||
mlir::Value base;
|
mlir::Value base;
|
||||||
if (coor.subcomponent().empty()) {
|
if (coor.getSubcomponent().empty()) {
|
||||||
// No subcomponent.
|
// No subcomponent.
|
||||||
if (!coor.lenParams().empty()) {
|
if (!coor.getLenParams().empty()) {
|
||||||
// Type parameters. Adjust element size explicitly.
|
// Type parameters. Adjust element size explicitly.
|
||||||
auto eleTy = fir::dyn_cast_ptrEleTy(coor.getType());
|
auto eleTy = fir::dyn_cast_ptrEleTy(coor.getType());
|
||||||
assert(eleTy && "result must be a reference-like type");
|
assert(eleTy && "result must be a reference-like type");
|
||||||
if (fir::characterWithDynamicLen(eleTy)) {
|
if (fir::characterWithDynamicLen(eleTy)) {
|
||||||
assert(coor.lenParams().size() == 1);
|
assert(coor.getLenParams().size() == 1);
|
||||||
auto length = integerCast(loc, rewriter, idxTy,
|
auto length = integerCast(loc, rewriter, idxTy,
|
||||||
operands[coor.lenParamsOffset()]);
|
operands[coor.lenParamsOffset()]);
|
||||||
offset =
|
offset =
|
||||||
|
|
Loading…
Reference in New Issue