Lines Matching refs:scope

55  * Decode scope.  When parsing a field that is itself a bitset, we push a
56 * new scope to the stack. A nested bitset is allowed to resolve fields
57 * from an enclosing scope (needed, for example, to decode src register
73 * Enclosing scope
101 * would require re-evaluation. But for a given scope, each evaluation
108 * in a given scope to have overlapping cache lookup idx's.
150 * Current topmost/innermost level of scope used for decoding fields,
154 struct decode_scope *scope;
195 static void display(struct decode_scope *scope);
253 struct decode_scope *scope = rzalloc_size(state, sizeof(*scope));
255 BITSET_COPY(scope->val.bitset, val.bitset);
256 scope->bitset = bitset;
257 scope->parent = state->scope;
258 scope->state = state;
260 state->scope = scope;
262 return scope;
266 pop_scope(struct decode_scope *scope)
268 assert(scope->state->scope == scope); /* must be top of stack */
270 scope->state->scope = scope->parent;
271 ralloc_free(scope);
278 evaluate_expr(struct decode_scope *scope, isa_expr_t expr)
280 if (scope->cache) {
281 struct hash_entry *entry = _mesa_hash_table_search(scope->cache, expr);
286 scope->cache = _mesa_pointer_hash_table_create(scope);
289 if (!push_expr(scope->state, expr))
292 uint64_t ret = expr(scope);
294 pop_expr(scope->state);
296 uint64_t *retp = ralloc_size(scope->cache, sizeof(*retp));
298 _mesa_hash_table_insert(scope->cache, expr, retp);
361 find_field(struct decode_scope *scope, const struct isa_bitset *bitset,
368 struct decode_state *state = scope->state;
378 if ((cur_expr != c->expr) && !evaluate_expr(scope, c->expr))
391 const struct isa_field *f = find_field(scope, bitset->parent, name, name_len);
401 extract_field(struct decode_scope *scope, const struct isa_field *field)
405 BITSET_COPY(val.bitset, scope->val.bitset);
420 find_display(struct decode_scope *scope, const struct isa_bitset *bitset)
424 if (c->expr && !evaluate_expr(scope, c->expr))
434 val = extract_field(scope, f);
436 decode_error(scope->state, "WARNING: unexpected "
452 return find_display(scope, bitset->parent);
462 display_bitset_field(struct decode_scope *scope, const struct isa_field *field, bitmask_t val)
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,
467 scope->bitset->name, field->name, BITSET_VALUE(val.bitset));
472 push_scope(scope->state, b, val);
479 display_enum_field(struct decode_scope *scope, const struct isa_field *field, bitmask_t val)
486 print(scope->state, "%s", e->values[i].display);
491 print(scope->state, "%u", (unsigned)ui);
495 resolve_field(struct decode_scope *scope, const char *field_name, size_t field_name_len, bitmask_t *valp)
497 if (!scope) {
503 find_field(scope, scope->bitset, field_name, field_name_len);
505 if (!field && scope->params) {
506 for (unsigned i = 0; i < scope->params->num_params; i++) {
507 if (!strncmp(field_name, scope->params->params[i].as, field_name_len) &&
508 (scope->params->params[i].as[field_name_len] == '\0')) {
509 const char *param_name = scope->params->params[i].name;
510 return resolve_field(scope->parent, param_name, strlen(param_name), valp);
521 uint64_t val = evaluate_expr(scope, field->expr);
525 *valp = extract_field(scope, field);
533 isa_decode_field(struct decode_scope *scope, const char *field_name)
536 const struct isa_field *field = resolve_field(scope, field_name, strlen(field_name), &val);
538 decode_error(scope->state, "no field '%s'", field_name);
546 display_field(struct decode_scope *scope, const char *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)
575 .str = scope->bitset->name,
579 while (scope->state->line_column < num_align)
582 print(scope->state, "%s", scope->bitset->name);
588 const struct isa_field *field = resolve_field(scope, field_name, field_name_len, &v);
590 decode_error(scope->state, "no field '%.*s'", (int)field_name_len, field_name);
604 while (scope->state->line_column < num_align)
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);
657 display_enum_field(scope, field, v);
667 display_bitset_field(scope, field, v);
670 decode_error(scope->state, "Bad field type: %d (%s)",
676 display(struct decode_scope *scope)
678 const struct isa_bitset *bitset = scope->bitset;
679 const char *display = find_display(scope, bitset);
682 decode_error(scope->state, "%s: no display template", bitset->name);
696 display_field(scope, field_name);
701 fputc(*p, scope->state->out);
702 scope->state->line_column++;
746 struct decode_scope *scope = push_scope(state, b, instr);
748 display(scope);
756 pop_scope(scope);