[clang] Add SPIRV support to HIPAMD toolchain (PR #75357)

Henry Linjamäki via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 3 03:11:58 PST 2024


linehill wrote:

> > Perhaps we should consider prefixing it in some way (e.g. `hip-spirv` or `amd-spirv`) that leaves the door open for some special handling (enable a particular set of extensions only for amdgpu targeting SPIRV, try to deal with missing builtins etc.) / flexibility?
> 
> I think amd-spirv may be a good choice since spirv itself is ambiguous about which HIP toolchain to choose since there are two HIP toolchains that support SPIRV: HIPAMD and HIPSPV.

> > I wonder if `-mcpu` is the correct way to encode this. Targeting SPIR-V is more like the triple than the architecture as far as I'm aware.
> 
> I will see whether I can use triple instead.

How about using `--offload=<target>` which can take a target triple? E.g.

* `--offload=spirv64-amd` or something like that: pick HIPAMD tool chain.
* `--offload=spirv64`: pick HIPSPV tool chain.

And also remove this [limitation](https://github.com/llvm/llvm-project/blob/5fc712c4bbe84e6cbaa1f7d2a0300f613f11b0c3/clang/lib/Driver/Driver.cpp#L3130-L3136) if you want `--offload` to work along with `--offload-arch`. 

Or alternatively allow multiple `--offload` options, deprecate `--offload-arch` and use `--offload` instead. For convenience and easy transition, options like `--offload=<processor>` could be allowed where the `<processor>` is treated as an alias for an offload target (E.g. `--offload=gfx900` could imply `--offload=amdgcn-amd-amdhsa:gfx900` or something like that).


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


More information about the cfe-commits mailing list