Skip to content

Commit e802e5e

Browse files
committed
Remove convertObjectType from Utils. Add new ops to isTargetDeviceOp.
1 parent 2aba8c9 commit e802e5e

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

flang/include/flang/Optimizer/Support/Utils.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@ std::optional<llvm::ArrayRef<int64_t>> getComponentLowerBoundsIfNonDefault(
200200
fir::RecordType recordType, llvm::StringRef component,
201201
mlir::ModuleOp module, const mlir::SymbolTable *symbolTable = nullptr);
202202

203-
// Convert FIR type to LLVM without turning fir.box<T> into memory
204-
// reference.
205-
mlir::Type convertObjectType(const fir::LLVMTypeConverter &converter,
206-
mlir::Type firType);
207-
208203
/// Generate a LLVM constant value of type `ity`, using the provided offset.
209204
mlir::LLVM::ConstantOp
210205
genConstantIndex(mlir::Location loc, mlir::Type ity,

flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ struct PrivateClauseOpConversion
127127
}
128128
};
129129

130+
// Convert FIR type to LLVM without turning fir.box<T> into memory
131+
// reference.
132+
static mlir::Type convertObjectType(const fir::LLVMTypeConverter &converter,
133+
mlir::Type firType) {
134+
if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(firType))
135+
return converter.convertBoxTypeAsStruct(boxTy);
136+
return converter.convertType(firType);
137+
}
138+
130139
// FIR Op specific conversion for TargetAllocMemOp
131140
struct TargetAllocMemOpConversion
132141
: public OpenMPFIROpConversion<mlir::omp::TargetAllocMemOp> {
@@ -139,7 +148,7 @@ struct TargetAllocMemOpConversion
139148
mlir::Location loc = allocmemOp.getLoc();
140149
auto ity = lowerTy().indexType();
141150
mlir::Type dataTy = fir::unwrapRefType(heapTy);
142-
mlir::Type llvmObjectTy = fir::convertObjectType(lowerTy(), dataTy);
151+
mlir::Type llvmObjectTy = convertObjectType(lowerTy(), dataTy);
143152
if (fir::isRecordWithTypeParameters(fir::unwrapSequenceType(dataTy)))
144153
TODO(loc, "omp.target_allocmem codegen of derived type with length "
145154
"parameters");

flang/lib/Optimizer/Support/Utils.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@ std::optional<llvm::ArrayRef<int64_t>> fir::getComponentLowerBoundsIfNonDefault(
5151
return std::nullopt;
5252
}
5353

54-
mlir::Type fir::convertObjectType(const fir::LLVMTypeConverter &converter,
55-
mlir::Type firType) {
56-
if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(firType))
57-
return converter.convertBoxTypeAsStruct(boxTy);
58-
return converter.convertType(firType);
59-
}
60-
6154
mlir::LLVM::ConstantOp
6255
fir::genConstantIndex(mlir::Location loc, mlir::Type ity,
6356
mlir::ConversionPatternRewriter &rewriter,

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5835,6 +5835,10 @@ static bool isTargetDeviceOp(Operation *op) {
58355835
if (mlir::isa<omp::ThreadprivateOp>(op))
58365836
return true;
58375837

5838+
if (mlir::isa<omp::TargetAllocMemOp>(op) ||
5839+
mlir::isa<mp::TargetFreeMemOp>(op))
5840+
return true;
5841+
58385842
if (auto parentFn = op->getParentOfType<LLVM::LLVMFuncOp>())
58395843
if (auto declareTargetIface =
58405844
llvm::dyn_cast<mlir::omp::DeclareTargetInterface>(

0 commit comments

Comments
 (0)