Skip to content

Commit e18672a

Browse files
committed
[flang][openacc] Add routine info attribute to the function
Attch the routine info attribute to the func operation. Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D157998
1 parent a1c447d commit e18672a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

flang/lib/Lower/OpenACC.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,19 @@ genACC(Fortran::lower::AbstractConverter &converter,
27482748
loc, routineOpName.str(), func.getName(), mlir::StringAttr{},
27492749
mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{},
27502750
mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::IntegerAttr{});
2751+
2752+
llvm::SmallVector<mlir::SymbolRefAttr> routines;
2753+
if (func.getOperation()->hasAttr(mlir::acc::getRoutineInfoAttrName())) {
2754+
auto routineInfo =
2755+
func.getOperation()->getAttrOfType<mlir::acc::RoutineInfoAttr>(
2756+
mlir::acc::getRoutineInfoAttrName());
2757+
routines.append(routineInfo.getAccRoutines().begin(),
2758+
routineInfo.getAccRoutines().end());
2759+
}
2760+
routines.push_back(builder.getSymbolRefAttr(routineOpName.str()));
2761+
func.getOperation()->setAttr(
2762+
mlir::acc::getRoutineInfoAttrName(),
2763+
mlir::acc::RoutineInfoAttr::get(builder.getContext(), routines));
27512764
}
27522765

27532766
void Fortran::lower::genOpenACCConstruct(

flang/test/Lower/OpenACC/acc-routine.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ subroutine acc_routine1()
77
end subroutine
88

99
! CHECK: acc.routine @acc_routine_0 func(@_QPacc_routine1)
10-
! CHECK-LABEL: func.func @_QPacc_routine1()
10+
! CHECK-LABEL: func.func @_QPacc_routine1() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}

mlir/include/mlir/Dialect/OpenACC/OpenACC.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ static constexpr StringLiteral getDeclareActionAttrName() {
8282
return StringLiteral("acc.declare_action");
8383
}
8484

85+
static constexpr StringLiteral getRoutineInfoAttrName() {
86+
return StringLiteral("acc.routine_info");
87+
}
88+
8589
} // namespace acc
8690
} // namespace mlir
8791

0 commit comments

Comments
 (0)