|
24 | 24 | #include "clang/Basic/LLVM.h" |
25 | 25 | #include "clang/Basic/SourceLocation.h" |
26 | 26 | #include "clang/Basic/TargetInfo.h" |
| 27 | +#include "clang/Parse/ParseHLSLRootSignature.h" |
27 | 28 | #include "clang/Sema/Initialization.h" |
28 | 29 | #include "clang/Sema/ParsedAttr.h" |
29 | 30 | #include "clang/Sema/Sema.h" |
@@ -647,6 +648,35 @@ void SemaHLSL::emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, |
647 | 648 | << NewFnName << FixItHint::CreateReplacement(FullRange, OS.str()); |
648 | 649 | } |
649 | 650 |
|
| 651 | +void SemaHLSL::handleRootSignatureAttr(Decl *D, const ParsedAttr &AL) { |
| 652 | + using namespace llvm::hlsl::root_signature; |
| 653 | + |
| 654 | + if (AL.getNumArgs() != 1) return; |
| 655 | + |
| 656 | + StringRef Signature; |
| 657 | + if (!SemaRef.checkStringLiteralArgumentAttr(AL, 0, Signature)) |
| 658 | + return; |
| 659 | + |
| 660 | + SourceLocation Loc = AL.getArgAsExpr(0)->getExprLoc(); |
| 661 | + // FIXME: pass down below to lexer when fp is supported |
| 662 | + // llvm::RoundingMode RM = SemaRef.CurFPFeatures.getRoundingMode(); |
| 663 | + SmallVector<RootSignatureToken> Tokens; |
| 664 | + RootSignatureLexer Lexer(Signature, Loc, SemaRef.getPreprocessor()); |
| 665 | + if (Lexer.Lex(Tokens)) return; |
| 666 | + |
| 667 | + SmallVector<RootElement> Elements; |
| 668 | + RootSignatureParser Parser(Elements, Tokens); |
| 669 | + if (Parser.Parse()) return; |
| 670 | + |
| 671 | + auto *RootElements = |
| 672 | + ::new (getASTContext()) ArrayRef<RootElement>(Elements); |
| 673 | + |
| 674 | + auto *Result = |
| 675 | + ::new (getASTContext()) HLSLRootSignatureAttr(getASTContext(), AL, Signature); |
| 676 | + Result->setElements(*RootElements); |
| 677 | + D->addAttr(Result); |
| 678 | +} |
| 679 | + |
650 | 680 | void SemaHLSL::handleNumThreadsAttr(Decl *D, const ParsedAttr &AL) { |
651 | 681 | llvm::VersionTuple SMVersion = |
652 | 682 | getASTContext().getTargetInfo().getTriple().getOSVersion(); |
|
0 commit comments