[all-commits] [llvm/llvm-project] b8dbc6: [HLSL] Add ExternalSemaSource & vector alias

Chris B via All-commits all-commits at lists.llvm.org
Tue Jul 5 09:30:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b8dbc6ffea93976dc0d8569c9d23e9c21e33e317
      https://github.com/llvm/llvm-project/commit/b8dbc6ffea93976dc0d8569c9d23e9c21e33e317
  Author: Chris Bieneman <chris.bieneman at me.com>
  Date:   2022-07-05 (Tue, 05 Jul 2022)

  Changed paths:
    A clang/include/clang/Sema/HLSLExternalSemaSource.h
    M clang/lib/Frontend/FrontendAction.cpp
    M clang/lib/Headers/hlsl/hlsl_basic_types.h
    M clang/lib/Sema/CMakeLists.txt
    A clang/lib/Sema/HLSLExternalSemaSource.cpp
    A clang/test/AST/HLSL/vector-alias.hlsl

  Log Message:
  -----------
  [HLSL] Add ExternalSemaSource & vector alias

HLSL vector types are ext_vector types, but they are also exposed via a
template syntax `vector<T, #>`. This is morally equavalent to the code:

```c++
template <typename T, int Size>
using vector = T __attribute__((ext_vector_type(Size)))
```

The problem is that templates aren't supported before HLSL 2021, and
type aliases still aren't supported in HLSL.

To resolve this (and other issues where HLSL can't represent its own
types), we rely on an external AST & Sema source being registered for
HLSL code.

This patch adds the HLSLExternalSemaSource and registers the vector
type alias.

Depends on D127802

Differential Revision: https://reviews.llvm.org/D128012




More information about the All-commits mailing list