Skip to content

Commit

Permalink
[flang][openacc] Add routine info attribute to the function
Browse files Browse the repository at this point in the history
Attch the routine info attribute to the func operation.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157998
  • Loading branch information
clementval committed Aug 16, 2023
1 parent a1c447d commit e18672a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions flang/lib/Lower/OpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2748,6 +2748,19 @@ genACC(Fortran::lower::AbstractConverter &converter,
loc, routineOpName.str(), func.getName(), mlir::StringAttr{},
mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::UnitAttr{},
mlir::UnitAttr{}, mlir::UnitAttr{}, mlir::IntegerAttr{});

llvm::SmallVector<mlir::SymbolRefAttr> routines;
if (func.getOperation()->hasAttr(mlir::acc::getRoutineInfoAttrName())) {
auto routineInfo =
func.getOperation()->getAttrOfType<mlir::acc::RoutineInfoAttr>(
mlir::acc::getRoutineInfoAttrName());
routines.append(routineInfo.getAccRoutines().begin(),
routineInfo.getAccRoutines().end());
}
routines.push_back(builder.getSymbolRefAttr(routineOpName.str()));
func.getOperation()->setAttr(
mlir::acc::getRoutineInfoAttrName(),
mlir::acc::RoutineInfoAttr::get(builder.getContext(), routines));
}

void Fortran::lower::genOpenACCConstruct(
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenACC/acc-routine.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ subroutine acc_routine1()
end subroutine

! CHECK: acc.routine @acc_routine_0 func(@_QPacc_routine1)
! CHECK-LABEL: func.func @_QPacc_routine1()
! CHECK-LABEL: func.func @_QPacc_routine1() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}
4 changes: 4 additions & 0 deletions mlir/include/mlir/Dialect/OpenACC/OpenACC.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ static constexpr StringLiteral getDeclareActionAttrName() {
return StringLiteral("acc.declare_action");
}

static constexpr StringLiteral getRoutineInfoAttrName() {
return StringLiteral("acc.routine_info");
}

} // namespace acc
} // namespace mlir

Expand Down

0 comments on commit e18672a

Please sign in to comment.