[llvm] [SPIRV] Change how to detect OpenCL/Vulkan Env and update tests accordingly. (PR #129689)
Marcos Maronas via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 12:05:37 PDT 2025
================
@@ -78,14 +83,22 @@ class SPIRVSubtarget : public SPIRVGenSubtargetInfo {
unsigned getPointerSize() const { return PointerSize; }
unsigned getBound() const { return GR->getBound(); }
bool canDirectlyComparePointers() const;
- // TODO: this environment is not implemented in Triple, we need to decide
- // how to standardize its support. For now, let's assume SPIR-V with physical
- // addressing is OpenCL, and Logical addressing is Vulkan.
- bool isOpenCLEnv() const {
+ void setEnv(SPIRVEnvType E) {
+ assert(E != Unknown && "Unknown environment is not allowed");
----------------
maarquitos14 wrote:
My thinking here is that we should only use `setEnv` to go from `Unknown` to `Shader` or `Kernel`. I don't see a scenario where it makes sense to pass `Unknown` to `setEnv`, but at the same time, I don't think it's really critical, and `llc` can continue. Therefore, I made it an assert instead of a critical error. I'm ambivalent here, if you think an error is better in this situation, I can change it.
The second assert checks that we only set the environment if it's still `Unknown`. When the triple is explicit, the environment will be set directly in the `SPIRVSubtarget` constructor. I think the triple should have priority over the rest of heuristics, so if the environment was already set according to the triple, it shouldn't be changed again. However, like I said for the previous assertion, I don't think it's really critical, and `llc` can continue. I don't have a strong opinion on this one either, both assertion and error work for me.
https://github.com/llvm/llvm-project/pull/129689
More information about the llvm-commits
mailing list