[all-commits] [llvm/llvm-project] d46262: [HLSL] Parameter modifier parsing and AST (#72139)

Chris B via All-commits all-commits at lists.llvm.org
Tue Nov 28 13:03:24 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d4626216943f8c4712bd17a709e439a0ffd0006b
      https://github.com/llvm/llvm-project/commit/d4626216943f8c4712bd17a709e439a0ffd0006b
  Author: Chris B <chris.bieneman at me.com>
  Date:   2023-11-28 (Tue, 28 Nov 2023)

  Changed paths:
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Basic/TokenKinds.def
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseTentative.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/lib/Sema/SemaType.cpp
    A clang/test/ParserHLSL/hlsl_groupshared.cpp
    A clang/test/ParserHLSL/hlsl_parameter_modifiers.cpp
    A clang/test/SemaHLSL/parameter_modifiers.hlsl
    A clang/test/SemaHLSL/parameter_modifiers_ast.hlsl

  Log Message:
  -----------
  [HLSL] Parameter modifier parsing and AST (#72139)

This change implements parsing for HLSL's parameter modifier keywords
`in`, `out` and `inout`. Because HLSL doesn't support references or
pointers, these keywords are used to allow parameters to be passed in
and out of functions.

This change only implements the parsing and AST support. In the HLSL
ASTs we represent `out` and `inout` parameters as references, and we
implement the semantics of by-value passing during IR generation.

In HLSL parameters marked `out` and `inout` are ambiguous in function
declarations, and `in`, `out` and `inout` may be ambiguous at call
sites.

This means a function may be defined as `fn(in T)` and `fn(inout T)` or
`fn(out T)`, but not `fn(inout T)` and `fn(out T)`. If a funciton `fn`
is declared with `in` and `inout` or `out` arguments, the call will be
ambiguous the same as a C++ call would be ambiguous given declarations
`fn(T)` and `fn(T&)`.

Fixes #59849




More information about the All-commits mailing list