Lines Matching refs:state

93 	 * Pointer back to decode state, for convenience.
95 struct decode_state *state;
114 * Current decode state
165 print(struct decode_state *state, const char *fmt, ...)
181 fputc(c, state->out);
182 state->line_column++;
185 state->line_column = 0;
196 static void decode_error(struct decode_state *state, const char *fmt, ...) _util_printf_format(2,3);
199 decode_error(struct decode_state *state, const char *fmt, ...)
201 if (!state->options->show_errors) {
205 if (state->num_errors == ARRAY_SIZE(state->errors)) {
212 vasprintf(&state->errors[state->num_errors++], fmt, ap);
217 flush_errors(struct decode_state *state)
219 unsigned num_errors = state->num_errors;
221 print(state, "\t; ");
223 print(state, "%s%s", (i > 0) ? ", " : "", state->errors[i]);
224 free(state->errors[i]);
226 state->num_errors = 0;
232 push_expr(struct decode_state *state, isa_expr_t expr)
234 for (int i = state->expr_sp - 1; i > 0; i--) {
235 if (state->expr_stack[i] == expr) {
239 state->expr_stack[state->expr_sp++] = expr;
244 pop_expr(struct decode_state *state)
246 assert(state->expr_sp > 0);
247 state->expr_sp--;
251 push_scope(struct decode_state *state, const struct isa_bitset *bitset, bitmask_t val)
253 struct decode_scope *scope = rzalloc_size(state, sizeof(*scope));
257 scope->parent = state->scope;
258 scope->state = state;
260 state->scope = scope;
268 assert(scope->state->scope == scope); /* must be top of stack */
270 scope->state->scope = scope->parent;
289 if (!push_expr(scope->state, expr))
294 pop_expr(scope->state);
308 find_bitset(struct decode_state *state, const struct isa_bitset **bitsets,
313 if (state->options->gpu_id > bitsets[n]->gen.max)
315 if (state->options->gpu_id < bitsets[n]->gen.min)
339 decode_error(state, "bitset conflict: %s vs %s", match->name,
352 decode_error(state, "dontcare bits in %s: %"BITSET_FORMAT,
368 struct decode_state *state = scope->state;
376 if (state->expr_sp > 0)
377 cur_expr = state->expr_stack[state->expr_sp - 1];
436 decode_error(scope->state, "WARNING: unexpected "
464 const struct isa_bitset *b = find_bitset(scope->state, field->bitsets, val);
466 decode_error(scope->state, "no match: FIELD: '%s.%s': %"BITSET_FORMAT,
472 push_scope(scope->state, b, val);
486 print(scope->state, "%s", e->values[i].display);
491 print(scope->state, "%u", (unsigned)ui);
538 decode_error(scope->state, "no field '%s'", field_name);
548 const struct isa_decode_options *options = scope->state->options;
549 struct decode_state *state = scope->state;
565 while (scope->state->line_column < num_align)
566 print(state, " ");
579 while (scope->state->line_column < num_align)
580 print(state, " ");
582 print(scope->state, "%s", scope->bitset->name);
590 decode_error(scope->state, "no field '%.*s'", (int)field_name_len, field_name);
604 while (scope->state->line_column < num_align)
605 print(state, " ");
610 if (scope->state->options->branch_labels) {
611 int offset = util_sign_extend(val, width) + scope->state->n;
612 if (offset < scope->state->num_instr) {
613 print(scope->state, "l%d", offset);
614 BITSET_SET(scope->state->branch_targets, offset);
620 print(scope->state, "%"PRId64, util_sign_extend(val, width));
623 print(scope->state, "%"PRIu64, val);
627 print(scope->state, "%"PRIx64, val);
631 print(scope->state, "%+"PRId64, util_sign_extend(val, width));
636 print(scope->state, "+%"PRIu64, val);
641 print(scope->state, "%f", _mesa_half_to_float(val));
644 print(scope->state, "%f", uif(val));
650 print(scope->state, "%s", field->display);
653 print(scope->state, "%u", (unsigned)val);
670 decode_error(scope->state, "Bad field type: %d (%s)",
682 decode_error(scope->state, "%s: no display template", bitset->name);
701 fputc(*p, scope->state->out);
702 scope->state->line_column++;
709 decode(struct decode_state *state, void *bin, int sz)
716 for (state->n = 0; state->n < state->num_instr; state->n++) {
719 next_instruction(&instr, &instrs[state->n * BITMASK_WORDS]);
720 state->line_column = 0;
722 if (state->options->max_errors && (errors > state->options->max_errors)) {
726 if (state->options->branch_labels &&
727 BITSET_TEST(state->branch_targets, state->n)) {
728 if (state->options->instr_cb) {
729 state->options->instr_cb(state->options->cbdata,
730 state->n, instr.bitset);
732 print(state, "l%d:\n", state->n);
735 if (state->options->instr_cb) {
736 state->options->instr_cb(state->options->cbdata, state->n, instr.bitset);
739 const struct isa_bitset *b = find_bitset(state, __instruction, instr);
741 print(state, "no match: %"BITSET_FORMAT"\n", BITSET_VALUE(instr.bitset));
746 struct decode_scope *scope = push_scope(state, b, instr);
749 if (flush_errors(state)) {
754 print(state, "\n");
758 if (state->options->stop) {
771 struct decode_state *state;
776 state = rzalloc_size(NULL, sizeof(*state));
777 state->options = options;
778 state->num_instr = sz / (BITMASK_WORDS * sizeof(BITSET_WORD));
780 if (state->options->branch_labels) {
781 state->branch_targets = rzalloc_size(state,
782 sizeof(BITSET_WORD) * BITSET_WORDS(state->num_instr));
785 state->out = fopen("/dev/null", "w");
786 state->options = &default_options; /* skip hooks for prepass */
787 decode(state, bin, sz);
788 fclose(state->out);
790 state->options = options;
794 state->out = out;
796 decode(state, bin, sz);
798 ralloc_free(state);