@@ -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)
@@ -271,9 +275,9 @@ BatchedBackendLLVM::llvm_assign_zero(const Symbol& sym)
271
275
zero = ll.wide_constant (0 );
272
276
} else if (elemtype.is_string_based ()) {
273
277
if (sym.is_uniform ())
274
- zero = ll.constant (ustring ( ));
278
+ zero = ll.constant (uint64_t ( 0 ));
275
279
else
276
- zero = ll.wide_constant (ustring ( ));
280
+ zero = ll.wide_constant (uint64_t ( 0 ));
277
281
} else if (elemtype.is_closure_based ()) {
278
282
if (sym.is_uniform ())
279
283
zero = ll.void_ptr_null ();
@@ -715,7 +719,8 @@ llvm::Value*
715
719
BatchedBackendLLVM::llvm_load_value (const Symbol& sym, int deriv,
716
720
llvm::Value* arrayindex, int component,
717
721
TypeDesc cast, bool op_is_uniform,
718
- bool index_is_uniform)
722
+ bool index_is_uniform,
723
+ bool always_real_ustring)
719
724
{
720
725
// A uniform symbol can be broadcast into a varying value.
721
726
// But a varying symbol can NOT be loaded into a uniform value.
@@ -780,9 +785,15 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
780
785
if (sym.typespec ().is_string ()) {
781
786
ustring string_val = sym.get_string ();
782
787
if (op_is_uniform) {
783
- return ll.constant (string_val);
788
+ if (!always_real_ustring)
789
+ return ll.constant (string_val);
790
+ else
791
+ return ll.constant_real_ustring (string_val);
784
792
} else {
785
- return ll.wide_constant (string_val);
793
+ if (!always_real_ustring)
794
+ return ll.wide_constant (string_val);
795
+ else
796
+ return ll.wide_constant_real_ustring (string_val);
786
797
}
787
798
}
788
799
OSL_ASSERT (0 && " unhandled constant type" );
@@ -796,7 +807,17 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
796
807
sym.forced_llvm_bool ());
797
808
}
798
809
810
+ llvm::Value*
811
+ BatchedBackendLLVM::llvm_const_hash (string_view str)
812
+ {
813
+ return llvm_const_hash (ustring (str));
814
+ }
799
815
816
+ llvm::Value*
817
+ BatchedBackendLLVM::llvm_const_hash (ustring str)
818
+ {
819
+ return ll.constant64 ((uint64_t )str.hash ());
820
+ }
800
821
801
822
llvm::Value*
802
823
BatchedBackendLLVM::llvm_load_mask (const Symbol& cond)
@@ -1717,6 +1738,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name,
1717
1738
= llvm_load_value (s, /* deriv=*/ d,
1718
1739
/* component*/ c, TypeUnknown,
1719
1740
function_is_uniform);
1741
+
1720
1742
// Store our wide pointer on the stack
1721
1743
llvm_store_value (wide_value, tmpptr, t, d, NULL , c,
1722
1744
/* dst_is_uniform*/ false );
0 commit comments