[clang] [llvm] [HLSL][SPIR-V] Implements SV_Position for VS/PS I/O (PR #168735)

Steven Perron via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 21 06:56:31 PST 2025


================
@@ -759,11 +767,14 @@ void CGHLSLRuntime::emitSystemSemanticStore(IRBuilder<> &B, llvm::Value *Source,
                                             std::optional<unsigned> Index) {
 
   std::string SemanticName = Semantic->getAttrName()->getName().upper();
-  if (SemanticName == "SV_POSITION")
-    createSPIRVBuiltinStore(B, CGM.getModule(), Source,
-                            Semantic->getAttrName()->getName(),
-                            /* BuiltIn::Position */ 0);
-  else
+  if (SemanticName == "SV_POSITION") {
+    if (CGM.getTarget().getTriple().isDXIL())
+      emitDXILUserSemanticStore(B, Source, Semantic, Index);
+    else if (CGM.getTarget().getTriple().isSPIRV())
+      createSPIRVBuiltinStore(B, CGM.getModule(), Source,
+                              Semantic->getAttrName()->getName(),
+                              /* BuiltIn::Position */ 0);
+  } else
     llvm_unreachable("non-handled system semantic. FIXME.");
----------------
s-perron wrote:

This unreachable will not be hit if targeting a different target. Can we remove the `else` so that this is hit in all cases that the semantic is not handled? Also, are more meaningful message would be good.

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


More information about the cfe-commits mailing list