-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[HLSL] Add support for the HLSL matrix type #159446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
26980a2
9e18ebb
158ea9b
d81fd36
0836981
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,9 +159,39 @@ void HLSLExternalSemaSource::defineHLSLMatrixAlias() { | |
SourceLocation(), ColsParam)); | ||
TemplateParams.emplace_back(ColsParam); | ||
|
||
auto *ParamList = | ||
TemplateParameterList::Create(AST, SourceLocation(), SourceLocation(), | ||
TemplateParams, SourceLocation(), nullptr); | ||
const unsigned MaxMatDim = SemaPtr->getLangOpts().MaxMatrixDimension; | ||
auto *MaxRow = IntegerLiteral::Create( | ||
AST, llvm::APInt(AST.getIntWidth(AST.IntTy), MaxMatDim), AST.IntTy, | ||
SourceLocation()); | ||
auto *MaxCol = IntegerLiteral::Create( | ||
AST, llvm::APInt(AST.getIntWidth(AST.IntTy), MaxMatDim), AST.IntTy, | ||
SourceLocation()); | ||
|
||
auto *RowsRef = DeclRefExpr::Create( | ||
AST, NestedNameSpecifierLoc(), SourceLocation(), RowsParam, | ||
/*RefersToEnclosingVariableOrCapture*/ false, | ||
DeclarationNameInfo(RowsParam->getDeclName(), SourceLocation()), | ||
AST.IntTy, VK_LValue); | ||
auto *ColsRef = DeclRefExpr::Create( | ||
AST, NestedNameSpecifierLoc(), SourceLocation(), ColsParam, | ||
/*RefersToEnclosingVariableOrCapture*/ false, | ||
DeclarationNameInfo(ColsParam->getDeclName(), SourceLocation()), | ||
AST.IntTy, VK_LValue); | ||
|
||
auto *RowsLE = BinaryOperator::Create(AST, RowsRef, MaxRow, BO_LE, AST.BoolTy, | ||
VK_PRValue, OK_Ordinary, | ||
SourceLocation(), FPOptionsOverride()); | ||
auto *ColsLE = BinaryOperator::Create(AST, ColsRef, MaxCol, BO_LE, AST.BoolTy, | ||
VK_PRValue, OK_Ordinary, | ||
SourceLocation(), FPOptionsOverride()); | ||
|
||
auto *RequiresExpr = BinaryOperator::Create( | ||
AST, RowsLE, ColsLE, BO_LAnd, AST.BoolTy, VK_PRValue, OK_Ordinary, | ||
SourceLocation(), FPOptionsOverride()); | ||
|
||
auto *ParamList = TemplateParameterList::Create( | ||
AST, SourceLocation(), SourceLocation(), TemplateParams, SourceLocation(), | ||
RequiresExpr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @llvm-beanz I had two questions on this commit for you.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this probably boils down to the quality of the error messages, and how we would handle larger matrices in the backend. Since we probably don't want to handle larger matrices we should probably restrict
Requirement expressions are part of C++ concepts, that was my intention for how this would be done. I don't think we need a separately defined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'n that case I'm going to take enforcement of size on |
||
|
||
IdentifierInfo &II = AST.Idents.get("matrix", tok::TokenKind::identifier); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal should likely be to replace the constexpr
MaxElementsPerDimension
with this language option.llvm-project/clang/include/clang/AST/TypeBase.h
Lines 4371 to 4379 in 129c683
But that would require updating all of these static constexpr functions with something that takes a SemaPtr
llvm-project/clang/include/clang/AST/TypeBase.h
Lines 4399 to 4407 in 129c683
For now we will make this an HLSL only language opt and create an issue to make it more generic:
issue #160190