-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[IR] Add storage scope to PointerType #8017
Conversation
This looks to be in competition with the |
Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Good question, the Type subclasses can be used as a type_annotation to tir variables. Code generation specifically relies on this type annotation to correctly write an op's function signature and the accesses of that Var. Taking #7686 as an example, when generating a function signature for
we expect PrintType(var) to return That's not to say we couldn't use the AST annotation to annotate Vars, but this would require all lowering to respect the fact that Vars may have annotations and thus to carry them forward if any Var binding occurs. OTOH if the storage_scope is part of the type system it is guaranteed to be preserved. |
@mbaret The are related. The scope information is only availiable in the alloca stmt, while the scope in pointer type can propagate as we pass the values, which can help our analysis by a lot. In the alloca stmt itself this might results in a duplicated information, as a next step we can update, and ensure that the pointer type's scope is consistent with the scope in alloca so there won't be inconsistency issue. We have done the similar thing for dtype field of alloca and pointers, and I believe we should do this as well as our next steps. |
Thanks @csullivan @Hzfengsy @mbaret |
* Add storage scope to PointerType. * Apply suggestions from code review Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
* Add storage scope to PointerType. * Apply suggestions from code review Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Add storage scope into which a PointerType may address. Scope is global by default. The storage scope field can allow for specialization during lowering and codegen (e.g. when the kernel function signature is storage scope dependent during codegen). This satisfies the need in #7686 for a pointer to texture memory.