llvm-project/flang/lib/Semantics/rewrite-directives.h
Sergio Afonso b49f846fe5
[Flang][OpenMP][Sema] Add directive rewrite pass to support atomic_default_mem_order REQUIRES clause
This patch creates the `OmpRewriteMutator` pass that runs at the end of
`RewriteParseTree()`. This pass is intended to make OpenMP-specific mutations
to the PFT after name resolution.

In the case of the `atomic_default_mem_order` clause of the REQUIRES directive,
name resolution results in populating global symbols with information about the
REQUIRES clauses that apply to that scope. The new rewrite pass is then able to
use this information in order to explicitly set the memory order of ATOMIC
constructs for which that is not already specified.

Given that this rewrite happens before semantics checks, the check of the order
in which ATOMIC constructs without explicit memory order and REQUIRES
directives with `atomic_default_mem_order` appear is moved earlier into the
rewrite pass. Otherwise, these problems would not be caught by semantics
checks, since the PFT would be modified by that stage.

This is patch 4/5 of a series splitting D149337 to simplify review.

Depends on D157983.

Differential Revision: https://reviews.llvm.org/D158096
2023-10-19 10:43:37 +01:00

25 lines
810 B
C++

//===-- lib/Semantics/rewrite-directives.h ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef FORTRAN_SEMANTICS_REWRITE_DIRECTIVES_H_
#define FORTRAN_SEMANTICS_REWRITE_DIRECTIVES_H_
namespace Fortran::parser {
struct Program;
} // namespace Fortran::parser
namespace Fortran::semantics {
class SemanticsContext;
} // namespace Fortran::semantics
namespace Fortran::semantics {
bool RewriteOmpParts(SemanticsContext &, parser::Program &);
} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_REWRITE_DIRECTIVES_H_