def needs_num_components(opcode):
return "replicated" in opcode.name
+
+def intrinsic_prefix(name):
+ if name in build_prefixed_intrinsics:
+ return 'nir_build'
+ else:
+ return 'nir'
%>
% for name, opcode in sorted(opcodes.items()):
% for name, opcode in sorted(INTR_OPCODES.items()):
% if opcode.indices:
#ifdef __cplusplus
-#define nir_build_${name}(build${intrinsic_macro_list(opcode)}, ...) ${'\\\\'}
+#define ${intrinsic_prefix(name)}_${name}(build${intrinsic_macro_list(opcode)}, ...) ${'\\\\'}
_nir_build_${name}(build${intrinsic_macro_list(opcode)}, _nir_${name}_indices{0, __VA_ARGS__})
#else
-#define nir_build_${name}(build${intrinsic_macro_list(opcode)}, ...) ${'\\\\'}
+#define ${intrinsic_prefix(name)}_${name}(build${intrinsic_macro_list(opcode)}, ...) ${'\\\\'}
_nir_build_${name}(build${intrinsic_macro_list(opcode)}, (struct _nir_${name}_indices){0, __VA_ARGS__})
#endif
% else:
-#define nir_build_${name} _nir_build_${name}
+#define nir_${name} _nir_build_${name}
% endif
+% if name in build_prefixed_intrinsics:
#define nir_${name} nir_build_${name}
+% endif
% endfor
% for name in ['flt', 'fge', 'feq', 'fneu']:
from nir_intrinsics import INTR_OPCODES, WRITE_MASK, ALIGN_MUL
from mako.template import Template
+# List of intrinsics that also need a nir_build_ prefixed factory macro.
+build_prefixed_intrinsics = [
+ "load_deref",
+ "store_deref",
+ "copy_deref",
+ "memcpy_deref",
+
+ "load_param",
+
+ "load_global",
+ "load_global_constant",
+ "store_global",
+
+ "deref_mode_is",
+]
+
print(Template(template).render(opcodes=opcodes,
type_size=type_size,
type_base_type=type_base_type,
INTR_OPCODES=INTR_OPCODES,
WRITE_MASK=WRITE_MASK,
- ALIGN_MUL=ALIGN_MUL))
+ ALIGN_MUL=ALIGN_MUL,
+ build_prefixed_intrinsics=build_prefixed_intrinsics))