Skip to content

Commit 4859b92

Browse files
[flang][acc] Update FIR ref, heap, and pointer to be MappableType (#147834)
The MappableType OpenACC type interface is a richer interface that allows OpenACC dialect to be capable to better interact with a source dialect, FIR in this case. fir.box and fir.class types already implemented this interface. Now the same is being done with the other FIR types that represent variables. One additional notable change is that fir.array no longer implements this interface. This is because MappableType is primarily intended for variables - and FIR variables of this type have storage associated and thus there's a pointer-like type (fir.ref/heap/pointer) that holds the array type. The end goal of promoting these FIR types to MappableType is that we will soon implement ability to generate recipes outside of the frontend via this interface.
1 parent 78eb92b commit 4859b92

File tree

9 files changed

+277
-212
lines changed

9 files changed

+277
-212
lines changed

flang/lib/Lower/OpenACC.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,13 @@ createDataEntryOp(fir::FirOpBuilder &builder, mlir::Location loc,
164164
op.setStructured(structured);
165165
op.setImplicit(implicit);
166166
op.setDataClause(dataClause);
167-
if (auto mappableTy =
168-
mlir::dyn_cast<mlir::acc::MappableType>(baseAddr.getType())) {
169-
op.setVarType(baseAddr.getType());
167+
if (auto pointerLikeTy =
168+
mlir::dyn_cast<mlir::acc::PointerLikeType>(baseAddr.getType())) {
169+
op.setVarType(pointerLikeTy.getElementType());
170170
} else {
171-
assert(mlir::isa<mlir::acc::PointerLikeType>(baseAddr.getType()) &&
172-
"expected pointer-like");
173-
op.setVarType(mlir::cast<mlir::acc::PointerLikeType>(baseAddr.getType())
174-
.getElementType());
171+
assert(mlir::isa<mlir::acc::MappableType>(baseAddr.getType()) &&
172+
"expected mappable");
173+
op.setVarType(baseAddr.getType());
175174
}
176175

177176
op->setAttr(Op::getOperandSegmentSizeAttr(),

flang/lib/Optimizer/Dialect/FIRType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,9 @@ std::optional<std::pair<uint64_t, unsigned short>>
15331533
fir::getTypeSizeAndAlignment(mlir::Location loc, mlir::Type ty,
15341534
const mlir::DataLayout &dl,
15351535
const fir::KindMapping &kindMap) {
1536-
if (mlir::isa<mlir::IntegerType, mlir::FloatType, mlir::ComplexType>(ty)) {
1536+
if (ty.isIntOrIndexOrFloat() ||
1537+
mlir::isa<mlir::ComplexType, mlir::VectorType,
1538+
mlir::DataLayoutTypeInterface>(ty)) {
15371539
llvm::TypeSize size = dl.getTypeSize(ty);
15381540
unsigned short alignment = dl.getTypeABIAlignment(ty);
15391541
return std::pair{size, alignment};

0 commit comments

Comments
 (0)