* DEALINGS IN THE SOFTWARE.
*/
+#include <inttypes.h> /* for PRIx64 macro */
#include "ir_print_visitor.h"
#include "compiler/glsl_types.h"
#include "glsl_parser_extras.h"
#include "main/macros.h"
#include "util/hash_table.h"
+#include "util/u_string.h"
static void print_type(FILE *f, const glsl_type *t);
: f(f)
{
indentation = 0;
- printable_names =
- _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+ printable_names = _mesa_pointer_hash_table_create(NULL);
symbols = _mesa_symbol_table_ctor();
mem_ctx = ralloc_context(NULL);
}
/* If there's no conflict, just use the original name */
const char* name = NULL;
- if (_mesa_symbol_table_find_symbol(this->symbols, -1, var->name) == NULL) {
+ if (_mesa_symbol_table_find_symbol(this->symbols, var->name) == NULL) {
name = var->name;
} else {
static unsigned i = 1;
name = ralloc_asprintf(this->mem_ctx, "%s@%u", var->name, ++i);
}
_mesa_hash_table_insert(this->printable_names, var, (void *) name);
- _mesa_symbol_table_add_symbol(this->symbols, -1, name, var);
+ _mesa_symbol_table_add_symbol(this->symbols, name, var);
return name;
}
static void
print_type(FILE *f, const glsl_type *t)
{
- if (t->base_type == GLSL_TYPE_ARRAY) {
+ if (t->is_array()) {
fprintf(f, "(array ");
print_type(f, t->fields.array);
fprintf(f, " %u)", t->length);
- } else if ((t->base_type == GLSL_TYPE_STRUCT)
- && !is_gl_identifier(t->name)) {
+ } else if (t->is_struct() && !is_gl_identifier(t->name)) {
fprintf(f, "%s@%p", t->name, (void *) t);
} else {
fprintf(f, "%s", t->name);
snprintf(loc, sizeof(loc), "location=%i ", ir->data.location);
char component[32] = {0};
- if (ir->data.explicit_component)
- snprintf(component, sizeof(component), "component=%i ", ir->data.location_frac);
+ if (ir->data.explicit_component || ir->data.location_frac != 0)
+ snprintf(component, sizeof(component), "component=%i ",
+ ir->data.location_frac);
+
+ char stream[32] = {0};
+ if (ir->data.stream & (1u << 31)) {
+ if (ir->data.stream & ~(1u << 31)) {
+ snprintf(stream, sizeof(stream), "stream(%u,%u,%u,%u) ",
+ ir->data.stream & 3, (ir->data.stream >> 2) & 3,
+ (ir->data.stream >> 4) & 3, (ir->data.stream >> 6) & 3);
+ }
+ } else if (ir->data.stream) {
+ snprintf(stream, sizeof(stream), "stream%u ", ir->data.stream);
+ }
+
+ char image_format[32] = {0};
+ if (ir->data.image_format) {
+ snprintf(image_format, sizeof(image_format), "format=%x ",
+ ir->data.image_format);
+ }
const char *const cent = (ir->data.centroid) ? "centroid " : "";
const char *const samp = (ir->data.sample) ? "sample " : "";
const char *const patc = (ir->data.patch) ? "patch " : "";
const char *const inv = (ir->data.invariant) ? "invariant " : "";
+ const char *const explicit_inv = (ir->data.explicit_invariant) ? "explicit_invariant " : "";
const char *const prec = (ir->data.precise) ? "precise " : "";
+ const char *const bindless = (ir->data.bindless) ? "bindless " : "";
+ const char *const bound = (ir->data.bound) ? "bound " : "";
+ const char *const memory_read_only = (ir->data.memory_read_only) ? "readonly " : "";
+ const char *const memory_write_only = (ir->data.memory_write_only) ? "writeonly " : "";
+ const char *const memory_coherent = (ir->data.memory_coherent) ? "coherent " : "";
+ const char *const memory_volatile = (ir->data.memory_volatile) ? "volatile " : "";
+ const char *const memory_restrict = (ir->data.memory_restrict) ? "restrict " : "";
const char *const mode[] = { "", "uniform ", "shader_storage ",
"shader_shared ", "shader_in ", "shader_out ",
"in ", "out ", "inout ",
"const_in ", "sys ", "temporary " };
STATIC_ASSERT(ARRAY_SIZE(mode) == ir_var_mode_count);
- const char *const stream [] = {"", "stream1 ", "stream2 ", "stream3 "};
const char *const interp[] = { "", "smooth", "flat", "noperspective" };
STATIC_ASSERT(ARRAY_SIZE(interp) == INTERP_MODE_COUNT);
- fprintf(f, "(%s%s%s%s%s%s%s%s%s%s%s) ",
- binding, loc, component, cent, samp, patc, inv, prec, mode[ir->data.mode],
- stream[ir->data.stream],
+ fprintf(f, "(%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s) ",
+ binding, loc, component, cent, bindless, bound,
+ image_format, memory_read_only, memory_write_only,
+ memory_coherent, memory_volatile, memory_restrict,
+ samp, patc, inv, explicit_inv, prec, mode[ir->data.mode],
+ stream,
interp[ir->data.interpolation]);
print_type(f, ir->type);
fprintf(f, " %s ", ir_expression_operation_strings[ir->operation]);
- for (unsigned i = 0; i < ir->get_num_operands(); i++) {
+ for (unsigned i = 0; i < ir->num_operands; i++) {
ir->operands[i]->accept(this);
}
else
fprintf(f, "1");
- if (ir->shadow_comparitor) {
+ if (ir->shadow_comparator) {
fprintf(f, " ");
- ir->shadow_comparitor->accept(this);
+ ir->shadow_comparator->accept(this);
} else {
fprintf(f, " ()");
}
{
fprintf(f, "(record_ref ");
ir->record->accept(this);
- fprintf(f, " %s) ", ir->field);
+
+ const char *field_name =
+ ir->record->type->fields.structure[ir->field_idx].name;
+ fprintf(f, " %s) ", field_name);
}
if (ir->type->is_array()) {
for (unsigned i = 0; i < ir->type->length; i++)
ir->get_array_element(i)->accept(this);
- } else if (ir->type->is_record()) {
- ir_constant *value = (ir_constant *) ir->components.get_head();
+ } else if (ir->type->is_struct()) {
for (unsigned i = 0; i < ir->type->length; i++) {
fprintf(f, "(%s ", ir->type->fields.structure[i].name);
- value->accept(this);
+ ir->get_record_field(i)->accept(this);
fprintf(f, ")");
-
- value = (ir_constant *) value->next;
}
} else {
for (unsigned i = 0; i < ir->type->components(); i++) {
else
fprintf(f, "%f", ir->value.f[i]);
break;
+ case GLSL_TYPE_SAMPLER:
+ case GLSL_TYPE_IMAGE:
+ case GLSL_TYPE_UINT64:
+ fprintf(f, "%" PRIu64, ir->value.u64[i]);
+ break;
+ case GLSL_TYPE_INT64: fprintf(f, "%" PRIi64, ir->value.i64[i]); break;
case GLSL_TYPE_BOOL: fprintf(f, "%d", ir->value.b[i]); break;
case GLSL_TYPE_DOUBLE:
if (ir->value.d[i] == 0.0)
else
fprintf(f, "%f", ir->value.d[i]);
break;
- default: assert(0);
+ default:
+ unreachable("Invalid constant type");
}
}
}
}
+void
+ir_print_visitor::visit(ir_demote *ir)
+{
+ fprintf(f, "(demote)");
+}
+
+
void
ir_print_visitor::visit(ir_if *ir)
{