[all-commits] [llvm/llvm-project] 37b941: [flang] Plugin directives for the loop that follow...

Valentin Churavy via All-commits all-commits at lists.llvm.org
Sat Oct 3 12:43:20 PDT 2026


  Branch: refs/heads/users/vchuravy/flang-plugin-directives-loop
  Home:   https://github.com/llvm/llvm-project
  Commit: 37b941d4df485439bc07365d1f8874fc86d96500
      https://github.com/llvm/llvm-project/commit/37b941d4df485439bc07365d1f8874fc86d96500
  Author: Valentin Churavy <v.churavy at gmail.com>
  Date:   2026-10-03 (Sat, 03 Oct 2026)

  Changed paths:
    M flang/examples/DirectivesPlugin/DirectivesPlugin.cpp
    M flang/include/flang/Parser/parse-tree.h
    M flang/include/flang/Support/PluginDirectives.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Parser/Fortran-parsers.cpp
    M flang/lib/Parser/unparse.cpp
    M flang/lib/Semantics/canonicalize-directives.cpp
    M flang/lib/Semantics/mod-file.cpp
    M flang/lib/Semantics/resolve-names.cpp
    M flang/test/Examples/plugin-directives-errors.f90
    A flang/test/Examples/plugin-directives-loop-errors.f90
    A flang/test/Examples/plugin-directives-loop.f90
    M flang/test/Examples/plugin-directives-parse.f90

  Log Message:
  -----------
  [flang] Plugin directives for the loop that follows them

A plugin can register a directive whose subject is the DO or DO WHILE loop
that follows it (PluginDirectiveSubject::Loop), as !DIR$ UNROLL is for its
loop:

  !DIR$ prefix keyword(var, ...) [name(value)]...

- Syntax: a trailing name(value) is the same as a name=value argument, and
  an argument may be a (signed) real literal, for the new
  PluginDirectiveArgKind::Real (a real or integer literal).
- Semantics: the positional arguments of a loop directive are variables or
  COMMON blocks, at least PluginDirectiveSpec::minPositional of them. The
  directive must come directly before a DO or DO WHILE loop (other
  directives may be in between), or it is an error; a directive after the
  last declaration goes with the loop that starts the execution part.
- Lowering: the variables are evaluated in front of the loop (a variable as
  its address, or its descriptor if it has one, an allocatable or pointer
  as its target's at that point; a COMMON block as its storage), and the
  start of the loop body gets a marker
    fir.call @__flang_directive.<prefix>.<keyword>(%var...)
        {fir.directive = {prefix = ..., keyword = ..., args = {...}}}
  with the other arguments as for fir.directives. The plugin's passes
  replace it with what the directive stands for; nothing defines the
  callee. For every form of DO loop, structured or not.

The example plugin registers `example converge(var, ... [, tol=real])
[max_iters(n)]`; the tests check its marker calls for a structured DO and
an unstructured DO WHILE loop, with !DIR$ and the sentinel, and its errors.

Assisted-by: Claude Code (Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list