mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 15:56:06 +00:00

This is first part for support cbuffer/tbuffer. The format for cbuffer/tbuffer is BufferType [Name] [: register(b#)] { VariableDeclaration [: packoffset(c#.xyzw)]; ... }; More details at https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants New keyword 'cbuffer' and 'tbuffer' are added. New AST node HLSLBufferDecl is added. Build AST for simple cbuffer/tbuffer without attribute support. The special thing is variables declared inside cbuffer is exposed into global scope. So isTransparentContext should return true for HLSLBuffer. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D129883
35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
//===- SemaHLSL.cpp - Semantic Analysis for HLSL constructs ---------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// This implements Semantic Analysis for HLSL constructs.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Sema/Sema.h"
|
|
|
|
using namespace clang;
|
|
|
|
Decl *Sema::ActOnStartHLSLBuffer(Scope *BufferScope, bool CBuffer,
|
|
SourceLocation KwLoc, IdentifierInfo *Ident,
|
|
SourceLocation IdentLoc,
|
|
SourceLocation LBrace) {
|
|
// For anonymous namespace, take the location of the left brace.
|
|
DeclContext *LexicalParent = getCurLexicalContext();
|
|
HLSLBufferDecl *Result = HLSLBufferDecl::Create(
|
|
Context, LexicalParent, CBuffer, KwLoc, Ident, IdentLoc, LBrace);
|
|
|
|
PushOnScopeChains(Result, BufferScope);
|
|
PushDeclContext(BufferScope, Result);
|
|
|
|
return Result;
|
|
}
|
|
|
|
void Sema::ActOnFinishHLSLBuffer(Decl *Dcl, SourceLocation RBrace) {
|
|
auto *BufDecl = cast<HLSLBufferDecl>(Dcl);
|
|
BufDecl->setRBraceLoc(RBrace);
|
|
PopDeclContext();
|
|
}
|