[clang] [CIR][AMDGPU][SPIR-V] Support metadata intrinsic args for feature predicates (PR #229330)

Arseniy Obolenskiy via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 11 00:46:08 PDT 2026


aobolensk wrote:

> > > I have previously attempted to represent LLVM metadata at CIR level : #204190
> > > Adding discussion thread here [#204190 (comment)](https://github.com/llvm/llvm-project/pull/204190#issuecomment-4781548798) for reference.
> > > CC: @andykaylor
> > 
> > 
> > Thanks for your reply!
> > Ok, I see your point. Probably then we don't really need to invent anything generic as it is done in LLVM IR. How do you think on introduction of CIR target specific operations that were mentioned in the discussion you have shared?
> > For that specific case, that could be something like:
> > ```mlir
> > %0 = cir.amdgcn.feature_predicate "is.gfx900"
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > I saw in the comment you shared, @andykaylor suggested something like that, but it didn't get any continuation, but in fact this idea could work out
> > The only thing that concerns me here is how do we introduce such operations, someone should decide on the convention or so. I haven't seen other CIR target specific ops that have already been defined (correct me if I'm wrong)
> 
> @steffenlarsen has implemented lowering of AMDGPU atomic buitlins in #225364 where a target attribute on the existing op is used and lowered to metadata during LLVM lowering. One difference I'm not sure how best to handle is, here the string is an operand of intrnsic call. So lowering would need to build a `MetadataAsValue` argument from the attribute.
> 
> CC: @andykaylor

Thanks! That's interesting that we don't have a "namespace" for amdgpu and use `_` after that. I'd expect that they could be separated with `.` for the convenience.

As for the implementation part, less obvious approach could be to reuse cir.call_llvm_intrinsic, so we get

```mlir
%0 = cir.call_llvm_intrinsic "spv.named.boolean.spec.constant"  ...
```
I'm really not sure how good is that, I don't really like it, because it seems too low level for CIR

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


More information about the cfe-commits mailing list