I have been experimenting with translating OpenCL kernels to SPIR-V.
My question is, how clang can still produce LLVM-IR destined to be SPIRV, even though it does support SPIR-V?
The following compiles fine:
First with clang to LLVM IR
clang -c -target spir64 kernel.cl -O0 -o IR.bc -emit-llvm
Then with llvm-spirv translator from LLVM IR to SPIRV
llvm-spirv -o SPIR.spv IR.bc
If I leave the target out from the clang part, llvm-spirv complains that it is for x86. So clearly the target information is built-in in the IR somehow.