Skip to content

Commit 58ceae9

Browse files
committed
[mlir:NFC] Remove the forward declaration of FuncOp in the mlir namespace
FuncOp has been moved to the `func` namespace for a little over a month, the using directive can be dropped now.
1 parent f8e1337 commit 58ceae9

File tree

154 files changed

+767
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+767
-714
lines changed

flang/include/flang/Optimizer/Builder/FIRBuilder.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class FirOpBuilder : public mlir::OpBuilder {
5252
}
5353

5454
/// Get the current Function
55-
mlir::FuncOp getFunction() {
56-
return getRegion().getParentOfType<mlir::FuncOp>();
55+
mlir::func::FuncOp getFunction() {
56+
return getRegion().getParentOfType<mlir::func::FuncOp>();
5757
}
5858

5959
/// Get a reference to the kind map.
@@ -222,19 +222,19 @@ class FirOpBuilder : public mlir::OpBuilder {
222222

223223
/// Get a function by name. If the function exists in the current module, it
224224
/// is returned. Otherwise, a null FuncOp is returned.
225-
mlir::FuncOp getNamedFunction(llvm::StringRef name) {
225+
mlir::func::FuncOp getNamedFunction(llvm::StringRef name) {
226226
return getNamedFunction(getModule(), name);
227227
}
228-
static mlir::FuncOp getNamedFunction(mlir::ModuleOp module,
229-
llvm::StringRef name);
228+
static mlir::func::FuncOp getNamedFunction(mlir::ModuleOp module,
229+
llvm::StringRef name);
230230

231231
/// Get a function by symbol name. The result will be null if there is no
232232
/// function with the given symbol in the module.
233-
mlir::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
233+
mlir::func::FuncOp getNamedFunction(mlir::SymbolRefAttr symbol) {
234234
return getNamedFunction(getModule(), symbol);
235235
}
236-
static mlir::FuncOp getNamedFunction(mlir::ModuleOp module,
237-
mlir::SymbolRefAttr symbol);
236+
static mlir::func::FuncOp getNamedFunction(mlir::ModuleOp module,
237+
mlir::SymbolRefAttr symbol);
238238

239239
fir::GlobalOp getNamedGlobal(llvm::StringRef name) {
240240
return getNamedGlobal(getModule(), name);
@@ -254,28 +254,29 @@ class FirOpBuilder : public mlir::OpBuilder {
254254

255255
/// Create a new FuncOp. If the function may have already been created, use
256256
/// `addNamedFunction` instead.
257-
mlir::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
258-
mlir::FunctionType ty) {
257+
mlir::func::FuncOp createFunction(mlir::Location loc, llvm::StringRef name,
258+
mlir::FunctionType ty) {
259259
return createFunction(loc, getModule(), name, ty);
260260
}
261261

262-
static mlir::FuncOp createFunction(mlir::Location loc, mlir::ModuleOp module,
263-
llvm::StringRef name,
264-
mlir::FunctionType ty);
262+
static mlir::func::FuncOp createFunction(mlir::Location loc,
263+
mlir::ModuleOp module,
264+
llvm::StringRef name,
265+
mlir::FunctionType ty);
265266

266267
/// Determine if the named function is already in the module. Return the
267268
/// instance if found, otherwise add a new named function to the module.
268-
mlir::FuncOp addNamedFunction(mlir::Location loc, llvm::StringRef name,
269-
mlir::FunctionType ty) {
269+
mlir::func::FuncOp addNamedFunction(mlir::Location loc, llvm::StringRef name,
270+
mlir::FunctionType ty) {
270271
if (auto func = getNamedFunction(name))
271272
return func;
272273
return createFunction(loc, name, ty);
273274
}
274275

275-
static mlir::FuncOp addNamedFunction(mlir::Location loc,
276-
mlir::ModuleOp module,
277-
llvm::StringRef name,
278-
mlir::FunctionType ty) {
276+
static mlir::func::FuncOp addNamedFunction(mlir::Location loc,
277+
mlir::ModuleOp module,
278+
llvm::StringRef name,
279+
mlir::FunctionType ty) {
279280
if (auto func = getNamedFunction(module, name))
280281
return func;
281282
return createFunction(loc, module, name, ty);

flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ struct RuntimeTableEntry<RuntimeTableKey<KT>, RuntimeIdentifier<Cs...>> {
391391
/// Get (or generate) the MLIR FuncOp for a given runtime function. Its template
392392
/// argument is intended to be of the form: <mkRTKey(runtime function name)>.
393393
template <typename RuntimeEntry>
394-
static mlir::FuncOp getRuntimeFunc(mlir::Location loc,
395-
fir::FirOpBuilder &builder) {
394+
static mlir::func::FuncOp getRuntimeFunc(mlir::Location loc,
395+
fir::FirOpBuilder &builder) {
396396
using namespace Fortran::runtime;
397397
auto name = RuntimeEntry::name;
398398
auto func = builder.getNamedFunction(name);

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ def fir_CallOp : fir_Op<"call", [CallOpInterface]> {
22822282
let hasCustomAssemblyFormat = 1;
22832283

22842284
let builders = [
2285-
OpBuilder<(ins "mlir::FuncOp":$callee,
2285+
OpBuilder<(ins "mlir::func::FuncOp":$callee,
22862286
CArg<"mlir::ValueRange", "{}">:$operands)>,
22872287
OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
22882288
"llvm::ArrayRef<mlir::Type>":$results,

flang/include/flang/Optimizer/Dialect/FIROpsSupport.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ inline bool pureCall(mlir::Operation *op) {
5353
///
5454
/// If `module` already contains FuncOp `name`, it is returned. Otherwise, a new
5555
/// FuncOp is created, and that new FuncOp is returned.
56-
mlir::FuncOp createFuncOp(mlir::Location loc, mlir::ModuleOp module,
57-
llvm::StringRef name, mlir::FunctionType type,
58-
llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
56+
mlir::func::FuncOp
57+
createFuncOp(mlir::Location loc, mlir::ModuleOp module, llvm::StringRef name,
58+
mlir::FunctionType type,
59+
llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
5960

6061
/// Get or create a GlobalOp in a module.
6162
fir::GlobalOp createGlobalOp(mlir::Location loc, mlir::ModuleOp module,
@@ -87,7 +88,7 @@ static constexpr llvm::StringRef getHostAssocAttrName() {
8788

8889
/// Does the function, \p func, have a host-associations tuple argument?
8990
/// Some internal procedures may have access to host procedure variables.
90-
bool hasHostAssociationArgument(mlir::FuncOp func);
91+
bool hasHostAssociationArgument(mlir::func::FuncOp func);
9192

9293
/// Tell if \p value is:
9394
/// - a function argument that has attribute \p attributeName
@@ -102,7 +103,7 @@ bool valueHasFirAttribute(mlir::Value value, llvm::StringRef attributeName);
102103
/// Scan the arguments of a FuncOp to determine if any arguments have the
103104
/// attribute `attr` placed on them. This can be used to determine if the
104105
/// function has any host associations, for example.
105-
bool anyFuncArgsHaveAttr(mlir::FuncOp func, llvm::StringRef attr);
106+
bool anyFuncArgsHaveAttr(mlir::func::FuncOp func, llvm::StringRef attr);
106107

107108
} // namespace fir
108109

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
include "mlir/Pass/PassBase.td"
1818

19-
def AbstractResultOpt : Pass<"abstract-result-opt", "mlir::FuncOp"> {
19+
def AbstractResultOpt : Pass<"abstract-result-opt", "mlir::func::FuncOp"> {
2020
let summary = "Convert fir.array, fir.box and fir.rec function result to "
2121
"function argument";
2222
let description = [{
@@ -35,7 +35,7 @@ def AbstractResultOpt : Pass<"abstract-result-opt", "mlir::FuncOp"> {
3535
];
3636
}
3737

38-
def AffineDialectPromotion : Pass<"promote-to-affine", "::mlir::FuncOp"> {
38+
def AffineDialectPromotion : Pass<"promote-to-affine", "::mlir::func::FuncOp"> {
3939
let summary = "Promotes `fir.{do_loop,if}` to `affine.{for,if}`.";
4040
let description = [{
4141
Convert fir operations which satisfy affine constraints to the affine
@@ -60,7 +60,7 @@ def AffineDialectPromotion : Pass<"promote-to-affine", "::mlir::FuncOp"> {
6060
];
6161
}
6262

63-
def AffineDialectDemotion : Pass<"demote-affine", "::mlir::FuncOp"> {
63+
def AffineDialectDemotion : Pass<"demote-affine", "::mlir::func::FuncOp"> {
6464
let summary = "Converts `affine.{load,store}` back to fir operations";
6565
let description = [{
6666
Affine dialect's default lowering for loads and stores is different from
@@ -91,7 +91,7 @@ def AnnotateConstantOperands : Pass<"annotate-constant"> {
9191
let dependentDialects = [ "fir::FIROpsDialect" ];
9292
}
9393

94-
def ArrayValueCopy : Pass<"array-value-copy", "::mlir::FuncOp"> {
94+
def ArrayValueCopy : Pass<"array-value-copy", "::mlir::func::FuncOp"> {
9595
let summary = "Convert array value operations to memory operations.";
9696
let description = [{
9797
Transform the set of array value primitives to a memory-based array
@@ -129,7 +129,7 @@ def CharacterConversion : Pass<"character-conversion"> {
129129
];
130130
}
131131

132-
def CFGConversion : Pass<"cfg-conversion", "::mlir::FuncOp"> {
132+
def CFGConversion : Pass<"cfg-conversion", "::mlir::func::FuncOp"> {
133133
let summary = "Convert FIR structured control flow ops to CFG ops.";
134134
let description = [{
135135
Transform the `fir.do_loop`, `fir.if`, and `fir.iterate_while` ops into
@@ -157,7 +157,7 @@ def ExternalNameConversion : Pass<"external-name-interop", "mlir::ModuleOp"> {
157157
let constructor = "::fir::createExternalNameConversionPass()";
158158
}
159159

160-
def MemRefDataFlowOpt : Pass<"fir-memref-dataflow-opt", "::mlir::FuncOp"> {
160+
def MemRefDataFlowOpt : Pass<"fir-memref-dataflow-opt", "::mlir::func::FuncOp"> {
161161
let summary =
162162
"Perform store/load forwarding and potentially removing dead stores.";
163163
let description = [{
@@ -170,7 +170,7 @@ def MemRefDataFlowOpt : Pass<"fir-memref-dataflow-opt", "::mlir::FuncOp"> {
170170
];
171171
}
172172

173-
def MemoryAllocationOpt : Pass<"memory-allocation-opt", "mlir::FuncOp"> {
173+
def MemoryAllocationOpt : Pass<"memory-allocation-opt", "mlir::func::FuncOp"> {
174174
let summary = "Convert stack to heap allocations and vice versa.";
175175
let description = [{
176176
Convert stack allocations to heap allocations and vice versa based on

flang/include/flang/Tools/CLOptions.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ static void defaultFlangInlinerOptPipeline(mlir::OpPassManager &pm) {
9292
}
9393

9494
inline void addCfgConversionPass(mlir::PassManager &pm) {
95-
addNestedPassConditionally<mlir::FuncOp>(
95+
addNestedPassConditionally<mlir::func::FuncOp>(
9696
pm, disableCfgConversion, fir::createFirToCfgPass);
9797
}
9898

9999
inline void addAVC(mlir::PassManager &pm) {
100-
addNestedPassConditionally<mlir::FuncOp>(
100+
addNestedPassConditionally<mlir::func::FuncOp>(
101101
pm, disableFirAvc, fir::createArrayValueCopyPass);
102102
}
103103

104104
inline void addMemoryAllocationOpt(mlir::PassManager &pm) {
105-
addNestedPassConditionally<mlir::FuncOp>(pm, disableFirMao, [&]() {
105+
addNestedPassConditionally<mlir::func::FuncOp>(pm, disableFirMao, [&]() {
106106
return fir::createMemoryAllocationPass(
107107
dynamicArrayStackToHeapAllocation, arrayStackAllocationThreshold);
108108
});
@@ -148,7 +148,7 @@ inline void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm) {
148148
mlir::GreedyRewriteConfig config;
149149
config.enableRegionSimplification = false;
150150
fir::addAVC(pm);
151-
pm.addNestedPass<mlir::FuncOp>(fir::createCharacterConversionPass());
151+
pm.addNestedPass<mlir::func::FuncOp>(fir::createCharacterConversionPass());
152152
pm.addPass(mlir::createCanonicalizerPass(config));
153153
pm.addPass(fir::createSimplifyRegionLitePass());
154154
fir::addMemoryAllocationOpt(pm);
@@ -171,7 +171,7 @@ inline void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm) {
171171
#if !defined(FLANG_EXCLUDE_CODEGEN)
172172
inline void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm) {
173173
fir::addBoxedProcedurePass(pm);
174-
pm.addNestedPass<mlir::FuncOp>(fir::createAbstractResultOptPass());
174+
pm.addNestedPass<mlir::func::FuncOp>(fir::createAbstractResultOptPass());
175175
fir::addCodeGenRewritePass(pm);
176176
fir::addTargetRewritePass(pm);
177177
fir::addFIRToLLVMPass(pm);

flang/lib/Lower/Allocatable.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void genRuntimeSetBounds(fir::FirOpBuilder &builder, mlir::Location loc,
118118
const fir::MutableBoxValue &box,
119119
mlir::Value dimIndex, mlir::Value lowerBound,
120120
mlir::Value upperBound) {
121-
mlir::FuncOp callee =
121+
mlir::func::FuncOp callee =
122122
box.isPointer()
123123
? fir::runtime::getRuntimeFunc<mkRTKey(PointerSetBounds)>(loc,
124124
builder)
@@ -138,7 +138,7 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
138138
mlir::Location loc,
139139
const fir::MutableBoxValue &box,
140140
mlir::Value len) {
141-
mlir::FuncOp callee =
141+
mlir::func::FuncOp callee =
142142
box.isPointer()
143143
? fir::runtime::getRuntimeFunc<mkRTKey(PointerNullifyCharacter)>(
144144
loc, builder)
@@ -166,7 +166,7 @@ static mlir::Value genRuntimeAllocate(fir::FirOpBuilder &builder,
166166
mlir::Location loc,
167167
const fir::MutableBoxValue &box,
168168
ErrorManager &errorManager) {
169-
mlir::FuncOp callee =
169+
mlir::func::FuncOp callee =
170170
box.isPointer()
171171
? fir::runtime::getRuntimeFunc<mkRTKey(PointerAllocate)>(loc, builder)
172172
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableAllocate)>(loc,
@@ -187,7 +187,7 @@ static mlir::Value genRuntimeDeallocate(fir::FirOpBuilder &builder,
187187
ErrorManager &errorManager) {
188188
// Ensure fir.box is up-to-date before passing it to deallocate runtime.
189189
mlir::Value boxAddress = fir::factory::getMutableIRBox(builder, loc, box);
190-
mlir::FuncOp callee =
190+
mlir::func::FuncOp callee =
191191
box.isPointer()
192192
? fir::runtime::getRuntimeFunc<mkRTKey(PointerDeallocate)>(loc,
193193
builder)

flang/lib/Lower/Bridge.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
195195
for (int entryIndex = 0, last = funit.entryPointList.size();
196196
entryIndex < last; ++entryIndex) {
197197
funit.setActiveEntry(entryIndex);
198-
// Calling CalleeInterface ctor will build a declaration mlir::FuncOp with
199-
// no other side effects.
198+
// Calling CalleeInterface ctor will build a declaration
199+
// mlir::func::FuncOp with no other side effects.
200200
// TODO: when doing some compiler profiling on real apps, it may be worth
201201
// to check it's better to save the CalleeInterface instead of recomputing
202202
// it later when lowering the body. CalleeInterface ctor should be linear
@@ -742,8 +742,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
742742
return cond;
743743
}
744744

745-
mlir::FuncOp getFunc(llvm::StringRef name, mlir::FunctionType ty) {
746-
if (mlir::FuncOp func = builder->getNamedFunction(name)) {
745+
mlir::func::FuncOp getFunc(llvm::StringRef name, mlir::FunctionType ty) {
746+
if (mlir::func::FuncOp func = builder->getNamedFunction(name)) {
747747
assert(func.getFunctionType() == ty);
748748
return func;
749749
}
@@ -2191,7 +2191,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21912191
void startNewFunction(Fortran::lower::pft::FunctionLikeUnit &funit) {
21922192
assert(!builder && "expected nullptr");
21932193
Fortran::lower::CalleeInterface callee(funit, *this);
2194-
mlir::FuncOp func = callee.addEntryBlockAndMapArguments();
2194+
mlir::func::FuncOp func = callee.addEntryBlockAndMapArguments();
21952195
builder = new fir::FirOpBuilder(func, bridge.getKindMap());
21962196
assert(builder && "FirOpBuilder did not instantiate");
21972197
builder->setInsertionPointToStart(&func.front());
@@ -2387,7 +2387,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
23872387
// FIXME: get rid of the bogus function context and instantiate the
23882388
// globals directly into the module.
23892389
mlir::MLIRContext *context = &getMLIRContext();
2390-
mlir::FuncOp func = fir::FirOpBuilder::createFunction(
2390+
mlir::func::FuncOp func = fir::FirOpBuilder::createFunction(
23912391
mlir::UnknownLoc::get(context), getModuleOp(),
23922392
fir::NameUniquer::doGenerated("Sham"),
23932393
mlir::FunctionType::get(context, llvm::None, llvm::None));

flang/lib/Lower/CallInterface.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ bool Fortran::lower::CalleeInterface::isMainProgram() const {
360360
return funit.isMainProgram();
361361
}
362362

363-
mlir::FuncOp Fortran::lower::CalleeInterface::addEntryBlockAndMapArguments() {
363+
mlir::func::FuncOp
364+
Fortran::lower::CalleeInterface::addEntryBlockAndMapArguments() {
364365
// On the callee side, directly map the mlir::value argument of
365366
// the function block to the Fortran symbols.
366367
func.addEntryBlock();
@@ -387,7 +388,7 @@ mlir::Value Fortran::lower::CalleeInterface::getHostAssociatedTuple() const {
387388
// sides.
388389
//===----------------------------------------------------------------------===//
389390

390-
static void addSymbolAttribute(mlir::FuncOp func,
391+
static void addSymbolAttribute(mlir::func::FuncOp func,
391392
const Fortran::semantics::Symbol &sym,
392393
mlir::MLIRContext &mlirContext) {
393394
// Only add this on bind(C) functions for which the symbol is not reflected in
@@ -401,7 +402,7 @@ static void addSymbolAttribute(mlir::FuncOp func,
401402
}
402403

403404
/// Declare drives the different actions to be performed while analyzing the
404-
/// signature and building/finding the mlir::FuncOp.
405+
/// signature and building/finding the mlir::func::FuncOp.
405406
template <typename T>
406407
void Fortran::lower::CallInterface<T>::declare() {
407408
if (!side().isMainProgram()) {
@@ -431,8 +432,9 @@ void Fortran::lower::CallInterface<T>::declare() {
431432
}
432433
}
433434

434-
/// Once the signature has been analyzed and the mlir::FuncOp was built/found,
435-
/// map the fir inputs to Fortran entities (the symbols or expressions).
435+
/// Once the signature has been analyzed and the mlir::func::FuncOp was
436+
/// built/found, map the fir inputs to Fortran entities (the symbols or
437+
/// expressions).
436438
template <typename T>
437439
void Fortran::lower::CallInterface<T>::mapPassedEntities() {
438440
// map back fir inputs to passed entities
@@ -1165,11 +1167,11 @@ mlir::FunctionType Fortran::lower::translateSignature(
11651167
.getFunctionType();
11661168
}
11671169

1168-
mlir::FuncOp Fortran::lower::getOrDeclareFunction(
1170+
mlir::func::FuncOp Fortran::lower::getOrDeclareFunction(
11691171
llvm::StringRef name, const Fortran::evaluate::ProcedureDesignator &proc,
11701172
Fortran::lower::AbstractConverter &converter) {
11711173
mlir::ModuleOp module = converter.getModuleOp();
1172-
mlir::FuncOp func = fir::FirOpBuilder::getNamedFunction(module, name);
1174+
mlir::func::FuncOp func = fir::FirOpBuilder::getNamedFunction(module, name);
11731175
if (func)
11741176
return func;
11751177

@@ -1185,7 +1187,7 @@ mlir::FuncOp Fortran::lower::getOrDeclareFunction(
11851187
mlir::FunctionType ty = SignatureBuilder{characteristics.value(), converter,
11861188
/*forceImplicit=*/false}
11871189
.getFunctionType();
1188-
mlir::FuncOp newFunc =
1190+
mlir::func::FuncOp newFunc =
11891191
fir::FirOpBuilder::createFunction(loc, module, name, ty);
11901192
addSymbolAttribute(newFunc, *symbol, converter.getMLIRContext());
11911193
return newFunc;

0 commit comments

Comments
 (0)