[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

Chris Bieneman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 16 14:56:48 PDT 2022


beanz created this revision.
beanz added reviewers: aaron.ballman, kuhar, bogner, rnk, python3kgae.
Herald added subscribers: Anastasia, jeroen.dobbelaere, mgorny.
Herald added a project: All.
beanz requested review of this revision.
Herald added a project: clang.

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 <https://reviews.llvm.org/D127802>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128012

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128012.437721.patch
Type: text/x-patch
Size: 13521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220616/77165ba0/attachment.bin>


More information about the cfe-commits mailing list