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

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


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

  Changed paths:
    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

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

A plugin can now 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, as one
  before the declarations already did.
- 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.

Assisted-by: Claude Code (Opus 5.5)

# Conflicts:
#	flang/lib/Lower/Bridge.cpp
#	flang/lib/Parser/Fortran-parsers.cpp
#	flang/lib/Semantics/mod-file.cpp
#	flang/lib/Semantics/resolve-names.cpp


  Commit: f37f665898619d6cfbe630fe64720c38f6e61e97
      https://github.com/llvm/llvm-project/commit/f37f665898619d6cfbe630fe64720c38f6e61e97
  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/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] Example plugin: a directive for the loop that follows it

flangDirectivesPlugin registers `example converge(var, ... [, tol=real])
[max_iters(n)]` for the DO or DO WHILE loop that follows it. The tests check
the marker call it becomes at the start of the loop body, for a structured DO
and an unstructured DO WHILE loop, written with !DIR$ and with the sentinel,
and its errors. A real literal is now a valid argument value, so the parse
error test uses other malformed arguments.

Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>


Compare: https://github.com/llvm/llvm-project/compare/80535238ec08%5E...f37f66589861

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