[llvm] [AMDGPU] MCExpr-ify MC layer kernel descriptor (PR #80855)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 06:58:48 PST 2024


arsenm wrote:

> > > > Can you add some examples where the expression has to refer to other functions' values?
> > > 
> > > 
> > > Currently there is no explicit tests I can add for this. I have one patch that converts AMDGPUResourceUsageAnalysis from a module level pass to a MachineFunction level pass and will include the infrastructure for resource usage information to be propagated through MCExprs and symbols. This propagation may mean that a symbol may be used before it is defined. However, I can't put a PR up for that unless I add support for the MC layer emit/parse for all (meta)data derived from resource usage.
> > 
> > 
> > I would expect the MC part to be decoupled from the codegen change to make use of it. I'm mostly wondering what the syntax ends up looking like
> 
> What I got so far for assembly format is emitting set directives for each resource usage info property gathered by AMDGPUResourceUsageAnalysis which are then combined with its callees' property (through a MAX/OR target specific MCExpr). For example:
> 
> ```
> with_call:
>     call uses_vcc
>     ...
> 
> .set with_call.num_vgpr, MAX(41, uses_vcc.num_vgpr)
> .set with_call.num_agpr, MAX(0, uses_vcc.num_agpr)
> .set with_call.num_sgpr, MAX(34, uses_vcc.num_sgpr)
> .set with_call.private_seg_size, 16+(MAX(uses_vcc.private_seg_size))
> .set with_call.uses_vcc, OR(1, uses_vcc.uses_vcc)
> .set with_call.uses_flat_scratch, OR(0, uses_vcc.uses_flat_scratch)
> .set with_call.has_dyn_sized_stack, OR(0, uses_vcc.has_dyn_sized_stack)
> .set with_call.has_recursion, OR(0, uses_vcc.has_recursion)
> .set with_call.has_indirect_call, OR(0, uses_vcc.has_indirect_call)
> 
> uses_vcc:
>     ...
> 
> .set uses_vcc.num_vgpr, 0
> .set uses_vcc.num_agpr, 0
> .set uses_vcc.num_sgpr, 32
> .set uses_vcc.private_seg_size, 0
> .set uses_vcc.uses_vcc, 1
> .set uses_vcc.uses_flat_scratch, 0
> .set uses_vcc.has_dyn_sized_stack, 0
> .set uses_vcc.has_recursion, 0
> .set uses_vcc.has_indirect_call, 0
> ```
> 
> These symbols could then be used to construct any derived fields (e.g., some of the kernel descriptor fields).

Can we define a single struct symbol per function, and emit that as a constant instead of individually setting each bit like this?

https://github.com/llvm/llvm-project/pull/80855


More information about the llvm-commits mailing list