@@ -143,6 +143,10 @@ BatchedBackendLLVM::BatchedBackendLLVM(ShadingSystemImpl& shadingsys,
143143 case 8 : m_true_mask_value = Mask<8 >(true ).value (); break ;
144144 default : OSL_ASSERT (0 && " unsupported vector width" );
145145 }
146+
147+ // Select the appropriate ustring representation
148+ ll.ustring_rep (LLVM_Util::UstringRep::hash);
149+
146150 ll.dumpasm (shadingsys.m_llvm_dumpasm );
147151 ll.jit_fma (shadingsys.m_llvm_jit_fma );
148152 ll.jit_aggressive (shadingsys.m_llvm_jit_aggressive );
@@ -191,7 +195,7 @@ BatchedBackendLLVM::llvm_pass_type(const TypeSpec& typespec)
191195 else if (t == TypeDesc::INT)
192196 lt = ll.type_int ();
193197 else if (t == TypeDesc::STRING)
194- lt = (llvm::Type*)ll.type_ustring ();
198+ lt = (llvm::Type*)ll.type_real_ustring ();
195199 else if (t.aggregate == TypeDesc::VEC3)
196200 lt = (llvm::Type*)ll.type_void_ptr (); // llvm_type_triple_ptr();
197201 else if (t.aggregate == TypeDesc::MATRIX44)
@@ -667,10 +671,11 @@ BatchedBackendLLVM::llvm_get_pointer(const Symbol& sym, int deriv,
667671#endif
668672
669673 int d = deriv * std::max (1 , t.arraylen );
670- if (arrayindex)
674+ if (arrayindex) {
671675 arrayindex = ll.op_add (arrayindex, ll.constant (d));
672- else
676+ } else {
673677 arrayindex = ll.constant (d);
678+ }
674679
675680 llvm::Type* result_type = llvm_type (t.elementtype ());
676681 if (!sym.is_uniform ()) {
@@ -715,7 +720,8 @@ llvm::Value*
715720BatchedBackendLLVM::llvm_load_value (const Symbol& sym, int deriv,
716721 llvm::Value* arrayindex, int component,
717722 TypeDesc cast, bool op_is_uniform,
718- bool index_is_uniform)
723+ bool index_is_uniform,
724+ bool always_real_ustring)
719725{
720726 // A uniform symbol can be broadcast into a varying value.
721727 // But a varying symbol can NOT be loaded into a uniform value.
@@ -780,9 +786,15 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
780786 if (sym.typespec ().is_string ()) {
781787 ustring string_val = sym.get_string ();
782788 if (op_is_uniform) {
783- return ll.constant (string_val);
789+ if (!always_real_ustring)
790+ return ll.constant (string_val);
791+ else
792+ return ll.constant_real_ustring (string_val);
784793 } else {
785- return ll.wide_constant (string_val);
794+ if (!always_real_ustring)
795+ return ll.wide_constant (string_val);
796+ else
797+ return ll.wide_constant_real_ustring (string_val);
786798 }
787799 }
788800 OSL_ASSERT (0 && " unhandled constant type" );
@@ -796,7 +808,17 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
796808 sym.forced_llvm_bool ());
797809}
798810
811+ llvm::Value*
812+ BatchedBackendLLVM::llvm_const_hash (string_view str)
813+ {
814+ return llvm_const_hash (ustring (str));
815+ }
799816
817+ llvm::Value*
818+ BatchedBackendLLVM::llvm_const_hash (ustring str)
819+ {
820+ return ll.constant64 ((uint64_t )str.hash ());
821+ }
800822
801823llvm::Value*
802824BatchedBackendLLVM::llvm_load_mask (const Symbol& cond)
@@ -1717,6 +1739,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name,
17171739 = llvm_load_value (s, /* deriv=*/ d,
17181740 /* component*/ c, TypeUnknown,
17191741 function_is_uniform);
1742+
17201743 // Store our wide pointer on the stack
17211744 llvm_store_value (wide_value, tmpptr, t, d, NULL , c,
17221745 /* dst_is_uniform*/ false );
0 commit comments