Skip to content

Add support for Type arguments and fix static parameter codegen#181

Merged
maleadt merged 5 commits intoJuliaGPU:mainfrom
AntonOresten:constant-type-support
Apr 8, 2026
Merged

Add support for Type arguments and fix static parameter codegen#181
maleadt merged 5 commits intoJuliaGPU:mainfrom
AntonOresten:constant-type-support

Conversation

@AntonOresten
Copy link
Copy Markdown
Contributor

@AntonOresten AntonOresten commented Apr 7, 2026

  • Add Constant(val::Type{T}) constructor so Constant(Int) produces Constant{Type{Int}, Int} instead of Constant{DataType, Int}, correctly binding type parameters in method dispatch
  • Handle :static_parameter expressions in codegen (lookup from sptypes, unwrap VarState/Const)
  • Fix unqualified IRStructurizer.IndexedUseRef in walk_uses!
  • Guard scalar_elim_pass! against TokenType annotations
  • Add to_tile_arg(t::Type) = Constant(t) to allow type arguments without the need for Constant

Enable `Constant(T)` where `T` is a type (e.g., `Constant(Int)`) to
produce `Constant{Type{T}, T}` instead of `Constant{DataType, T}`,
so method dispatch correctly binds type parameters.

Handle `:static_parameter` expressions in codegen by looking up
concrete values from the method's sptypes, unwrapping VarState and
Const wrappers.

Also fix `IndexedUseRef` qualification in walk_uses! and guard
scalar_elim_pass! against TokenType annotations.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@AntonOresten AntonOresten force-pushed the constant-type-support branch from ea6792d to 309c0d6 Compare April 7, 2026 13:02
@AntonOresten AntonOresten changed the title Add Constant(Type) support and fix static_parameter codegen Add Constant(::Type) support and fix static parameter codegen Apr 7, 2026
@AntonOresten AntonOresten changed the title Add Constant(::Type) support and fix static parameter codegen Add support for Type arguments and fix static parameter codegen Apr 7, 2026
@AntonOresten
Copy link
Copy Markdown
Contributor Author

Changing the scope of the PR slightly to support Type arguments by wrapping them with Constant — my previous pattern for passing types, which I believe still worked in cuTile v0.1.2. Originally tried direct Type support in #93 but trying to make the DataType/Type distinction through the lower-level ghost/singleton helpers was too tricky, and I believe this is cleaner.

@maleadt maleadt merged commit 1ca30bb into JuliaGPU:main Apr 8, 2026
9 checks passed
@maleadt
Copy link
Copy Markdown
Member

maleadt commented Apr 8, 2026

Auto-wrapping as Const is pretty neat. I guess it gives us automatic specialization, i.e., without users having to write a kernel like typ::Type{T} where T because using typ could result in badly-specialized code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants