================
@@ -341,19 +343,24 @@ class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public
BaseSPIRVTargetInfo {
: BaseSPIRVTargetInfo(Triple, Opts) {
assert(Triple.getArch() == llvm::Triple::spirv &&
"Invalid architecture for Logical SPIR-V.");
- assert(Triple.getOS() == llvm::Triple::Vulkan &&
- Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
- "Logical SPIR-V requires a valid Vulkan environment.");
- assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
- Triple.getEnvironment() <= llvm::Triple::Amplification &&
- "Logical SPIR-V environment must be a valid shader stage.");
PointerWidth = PointerAlign = 64;
// SPIR-V IDs are represented with a single 32-bit word.
SizeType = TargetInfo::UnsignedInt;
resetDataLayout();
}
+ // SPIR-V targeting requires a fully specified Vulkan environment.
+ // Validate here before CreateTargetInfo() to emit a proper diagnostic
+ bool validateTarget(DiagnosticsEngine &Diags) const override {
+ if (getTriple().getOS() != llvm::Triple::Vulkan ||
+ getTriple().getVulkanVersion() == llvm::VersionTuple(0)) {
+ Diags.Report(diag::err_fe_spirv_requires_vulkan) << getTriple().str();
+ return false;
+ }
+ return true;
----------------
to268 wrote:
```suggestion
assert(getTriple().getEnvironment() >= llvm::Triple::Pixel &&
getTriple().getEnvironment() <= llvm::Triple::Amplification &&
"Logical SPIR-V environment must be a valid shader stage.");
return true;
```
> If you need to remove this assert here, move it before the `return true;`
> statement of the `validateTarget()` method.
Something like that.
https://github.com/llvm/llvm-project/pull/190840
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits