-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[HLSL] Rewrite semantics parsing #152537
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
base: main
Are you sure you want to change the base?
[HLSL] Rewrite semantics parsing #152537
Changes from all commits
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 |
---|---|---|
|
@@ -232,6 +232,41 @@ class HLSLAnnotationAttr : public InheritableAttr { | |
} | ||
}; | ||
|
||
class HLSLSemanticAttr : public HLSLAnnotationAttr { | ||
unsigned SemanticIndex : 30; | ||
LLVM_PREFERRED_TYPE(bool) | ||
unsigned SemanticIndexable : 1; | ||
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. Do we need to store this at all? Isn't this a static property we can define from the semantic type itself? User defined semantics are always indexable and system values may or may not be based on which system value they refer to. At the moment that's a unique attribute type, but even if we instead make it an enum on the |
||
LLVM_PREFERRED_TYPE(bool) | ||
unsigned SemanticExplicitIndex : 1; | ||
|
||
protected: | ||
HLSLSemanticAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, | ||
attr::Kind AK, bool IsLateParsed, | ||
bool InheritEvenIfAlreadyPresent, bool SemanticIndexable) | ||
: HLSLAnnotationAttr(Context, CommonInfo, AK, IsLateParsed, | ||
InheritEvenIfAlreadyPresent) { | ||
this->SemanticIndexable = SemanticIndexable; | ||
this->SemanticIndex = 0; | ||
this->SemanticExplicitIndex = 0; | ||
} | ||
|
||
public: | ||
bool isSemanticIndexable() const { return SemanticIndexable; } | ||
|
||
void setSemanticIndex(unsigned SemanticIndex) { | ||
this->SemanticIndex = SemanticIndex; | ||
this->SemanticExplicitIndex = true; | ||
} | ||
|
||
unsigned getSemanticIndex() const { return SemanticIndex; } | ||
|
||
// Implement isa/cast/dyncast/etc. | ||
static bool classof(const Attr *A) { | ||
return A->getKind() >= attr::FirstHLSLSemanticAttr && | ||
A->getKind() <= attr::LastHLSLSemanticAttr; | ||
} | ||
}; | ||
|
||
/// A parameter attribute which changes the argument-passing ABI rule | ||
/// for the parameter. | ||
class ParameterABIAttr : public InheritableParamAttr { | ||
|
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.
I was trying to figure out if we had any documentation on the valid ranges for this. It looks like DXC does allow a 32-bit integer, and while I hope to god that nobody is actually doing this it seems to work up to UINT32_MAX:
https://godbolt.org/z/eEazEbfrM
It probably won't hurt us to give a full 32-bit integer for the semantic index and have the bools be an extra bitfield.