@@ -143,6 +143,10 @@ BatchedBackendLLVM::BatchedBackendLLVM(ShadingSystemImpl& shadingsys,
143
143
case 8 : m_true_mask_value = Mask<8 >(true ).value (); break ;
144
144
default : OSL_ASSERT (0 && " unsupported vector width" );
145
145
}
146
+
147
+ // Select the appropriate ustring representation
148
+ ll.ustring_rep (LLVM_Util::UstringRep::hash);
149
+
146
150
ll.dumpasm (shadingsys.m_llvm_dumpasm );
147
151
ll.jit_fma (shadingsys.m_llvm_jit_fma );
148
152
ll.jit_aggressive (shadingsys.m_llvm_jit_aggressive );
@@ -191,7 +195,7 @@ BatchedBackendLLVM::llvm_pass_type(const TypeSpec& typespec)
191
195
else if (t == TypeDesc::INT)
192
196
lt = ll.type_int ();
193
197
else if (t == TypeDesc::STRING)
194
- lt = (llvm::Type*)ll.type_ustring ();
198
+ lt = (llvm::Type*)ll.type_real_ustring ();
195
199
else if (t.aggregate == TypeDesc::VEC3)
196
200
lt = (llvm::Type*)ll.type_void_ptr (); // llvm_type_triple_ptr();
197
201
else if (t.aggregate == TypeDesc::MATRIX44)
@@ -667,10 +671,11 @@ BatchedBackendLLVM::llvm_get_pointer(const Symbol& sym, int deriv,
667
671
#endif
668
672
669
673
int d = deriv * std::max (1 , t.arraylen );
670
- if (arrayindex)
674
+ if (arrayindex) {
671
675
arrayindex = ll.op_add (arrayindex, ll.constant (d));
672
- else
676
+ } else {
673
677
arrayindex = ll.constant (d);
678
+ }
674
679
675
680
llvm::Type* result_type = llvm_type (t.elementtype ());
676
681
if (!sym.is_uniform ()) {
@@ -715,7 +720,8 @@ llvm::Value*
715
720
BatchedBackendLLVM::llvm_load_value (const Symbol& sym, int deriv,
716
721
llvm::Value* arrayindex, int component,
717
722
TypeDesc cast, bool op_is_uniform,
718
- bool index_is_uniform)
723
+ bool index_is_uniform,
724
+ bool always_real_ustring)
719
725
{
720
726
// A uniform symbol can be broadcast into a varying value.
721
727
// 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,
780
786
if (sym.typespec ().is_string ()) {
781
787
ustring string_val = sym.get_string ();
782
788
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);
784
793
} 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);
786
798
}
787
799
}
788
800
OSL_ASSERT (0 && " unhandled constant type" );
@@ -796,7 +808,17 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
796
808
sym.forced_llvm_bool ());
797
809
}
798
810
811
+ llvm::Value*
812
+ BatchedBackendLLVM::llvm_const_hash (string_view str)
813
+ {
814
+ return llvm_const_hash (ustring (str));
815
+ }
799
816
817
+ llvm::Value*
818
+ BatchedBackendLLVM::llvm_const_hash (ustring str)
819
+ {
820
+ return ll.constant64 ((uint64_t )str.hash ());
821
+ }
800
822
801
823
llvm::Value*
802
824
BatchedBackendLLVM::llvm_load_mask (const Symbol& cond)
@@ -1717,6 +1739,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name,
1717
1739
= llvm_load_value (s, /* deriv=*/ d,
1718
1740
/* component*/ c, TypeUnknown,
1719
1741
function_is_uniform);
1742
+
1720
1743
// Store our wide pointer on the stack
1721
1744
llvm_store_value (wide_value, tmpptr, t, d, NULL , c,
1722
1745
/* dst_is_uniform*/ false );
0 commit comments