• Home
  • Raw
  • Download

Lines Matching refs:iter

883 iter_more_fields(const struct gen_field_iterator *iter)  in iter_more_fields()  argument
885 return iter->field != NULL && iter->field->next != NULL; in iter_more_fields()
889 iter_array_offset_bits(const struct gen_field_iterator *iter) in iter_array_offset_bits() argument
891 if (iter->level == 0) in iter_array_offset_bits()
895 const struct gen_group *group = iter->groups[1]; in iter_array_offset_bits()
896 for (int level = 1; level <= iter->level; level++, group = iter->groups[level]) { in iter_array_offset_bits()
897 uint32_t array_idx = iter->array_iter[level]; in iter_array_offset_bits()
909 iter_push_array(struct gen_field_iterator *iter) in iter_push_array() argument
911 assert(iter->level >= 0); in iter_push_array()
913 iter->group = iter->field->array; in iter_push_array()
914 iter->level++; in iter_push_array()
915 assert(iter->level < DECODE_MAX_ARRAY_DEPTH); in iter_push_array()
916 iter->groups[iter->level] = iter->group; in iter_push_array()
917 iter->array_iter[iter->level] = 0; in iter_push_array()
919 assert(iter->group->fields != NULL); /* an empty <group> makes no sense */ in iter_push_array()
920 iter->field = iter->group->fields; in iter_push_array()
921 iter->fields[iter->level] = iter->field; in iter_push_array()
925 iter_pop_array(struct gen_field_iterator *iter) in iter_pop_array() argument
927 assert(iter->level > 0); in iter_pop_array()
929 iter->level--; in iter_pop_array()
930 iter->field = iter->fields[iter->level]; in iter_pop_array()
931 iter->group = iter->groups[iter->level]; in iter_pop_array()
935 iter_start_field(struct gen_field_iterator *iter, struct gen_field *field) in iter_start_field() argument
937 iter->field = field; in iter_start_field()
938 iter->fields[iter->level] = field; in iter_start_field()
940 while (iter->field->array) in iter_start_field()
941 iter_push_array(iter); in iter_start_field()
943 int array_member_offset = iter_array_offset_bits(iter); in iter_start_field()
945 iter->start_bit = array_member_offset + iter->field->start; in iter_start_field()
946 iter->end_bit = array_member_offset + iter->field->end; in iter_start_field()
947 iter->struct_desc = NULL; in iter_start_field()
951 iter_advance_array(struct gen_field_iterator *iter) in iter_advance_array() argument
953 assert(iter->level > 0); in iter_advance_array()
954 int lvl = iter->level; in iter_advance_array()
956 if (iter->group->variable) in iter_advance_array()
957 iter->array_iter[lvl]++; in iter_advance_array()
959 if ((iter->array_iter[lvl] + 1) < iter->group->array_count) { in iter_advance_array()
960 iter->array_iter[lvl]++; in iter_advance_array()
964 iter_start_field(iter, iter->group->fields); in iter_advance_array()
968 iter_more_array_elems(const struct gen_field_iterator *iter) in iter_more_array_elems() argument
970 int lvl = iter->level; in iter_more_array_elems()
973 if (iter->group->variable) { in iter_more_array_elems()
974 int length = gen_group_get_length(iter->group, iter->p); in iter_more_array_elems()
976 return iter_array_offset_bits(iter) + iter->group->array_item_size < in iter_more_array_elems()
979 return (iter->array_iter[lvl] + 1) < iter->group->array_count; in iter_more_array_elems()
984 iter_advance_field(struct gen_field_iterator *iter) in iter_advance_field() argument
989 while (iter_more_fields(iter) || iter->level > 0) { in iter_advance_field()
990 if (iter_more_fields(iter)) { in iter_advance_field()
991 iter_start_field(iter, iter->field->next); in iter_advance_field()
995 assert(iter->level >= 0); in iter_advance_field()
997 if (iter_more_array_elems(iter)) { in iter_advance_field()
998 iter_advance_array(iter); in iter_advance_field()
1006 iter_pop_array(iter); in iter_advance_field()
1013 iter_decode_field_raw(struct gen_field_iterator *iter, uint64_t *qw) in iter_decode_field_raw() argument
1017 int field_start = iter->p_bit + iter->start_bit; in iter_decode_field_raw()
1018 int field_end = iter->p_bit + iter->end_bit; in iter_decode_field_raw()
1020 const uint32_t *p = iter->p + (iter->start_bit / 32); in iter_decode_field_raw()
1021 if (iter->p_end && p >= iter->p_end) in iter_decode_field_raw()
1025 if (!iter->p_end || (p + 1) < iter->p_end) in iter_decode_field_raw()
1036 if (iter->field->type.kind == GEN_TYPE_ADDRESS || in iter_decode_field_raw()
1037 iter->field->type.kind == GEN_TYPE_OFFSET) in iter_decode_field_raw()
1044 iter_decode_field(struct gen_field_iterator *iter) in iter_decode_field() argument
1051 if (iter->field->name) in iter_decode_field()
1052 snprintf(iter->name, sizeof(iter->name), "%s", iter->field->name); in iter_decode_field()
1054 memset(iter->name, 0, sizeof(iter->name)); in iter_decode_field()
1058 if (!iter_decode_field_raw(iter, &iter->raw_value)) in iter_decode_field()
1063 v.qw = iter->raw_value; in iter_decode_field()
1064 switch (iter->field->type.kind) { in iter_decode_field()
1067 snprintf(iter->value, sizeof(iter->value), "%"PRId64, v.qw); in iter_decode_field()
1068 enum_name = gen_get_enum_name(&iter->field->inline_enum, v.qw); in iter_decode_field()
1072 snprintf(iter->value, sizeof(iter->value), "%"PRIu64, v.qw); in iter_decode_field()
1073 enum_name = gen_get_enum_name(&iter->field->inline_enum, v.qw); in iter_decode_field()
1078 iter->print_colors ? "\e[0;35mtrue\e[0m" : "true"; in iter_decode_field()
1079 snprintf(iter->value, sizeof(iter->value), "%s", in iter_decode_field()
1084 snprintf(iter->value, sizeof(iter->value), "%f", v.f); in iter_decode_field()
1088 snprintf(iter->value, sizeof(iter->value), "0x%08"PRIx64, v.qw); in iter_decode_field()
1091 snprintf(iter->value, sizeof(iter->value), "<struct %s>", in iter_decode_field()
1092 iter->field->type.gen_struct->name); in iter_decode_field()
1093 iter->struct_desc = in iter_decode_field()
1094 gen_spec_find_struct(iter->group->spec, in iter_decode_field()
1095 iter->field->type.gen_struct->name); in iter_decode_field()
1098 snprintf(iter->value, sizeof(iter->value), "%f", in iter_decode_field()
1099 (float) v.qw / (1 << iter->field->type.f)); in iter_decode_field()
1103 int bits = iter->field->type.i + iter->field->type.f + 1; in iter_decode_field()
1105 snprintf(iter->value, sizeof(iter->value), "%f", in iter_decode_field()
1106 (float) v_sign_extend / (1 << iter->field->type.f)); in iter_decode_field()
1112 snprintf(iter->value, sizeof(iter->value), "%"PRId64, v.qw); in iter_decode_field()
1113 enum_name = gen_get_enum_name(iter->field->type.gen_enum, v.qw); in iter_decode_field()
1118 if (strlen(iter->group->name) == 0) { in iter_decode_field()
1119 int length = strlen(iter->name); in iter_decode_field()
1120 assert(iter->level >= 0); in iter_decode_field()
1123 char *buf = iter->name + length; in iter_decode_field()
1124 while (level <= iter->level) { in iter_decode_field()
1125 int printed = snprintf(buf, sizeof(iter->name) - length, in iter_decode_field()
1126 "[%i]", iter->array_iter[level]); in iter_decode_field()
1134 int length = strlen(iter->value); in iter_decode_field()
1135 snprintf(iter->value + length, sizeof(iter->value) - length, in iter_decode_field()
1137 } else if (strcmp(iter->name, "Surface Format") == 0 || in iter_decode_field()
1138 strcmp(iter->name, "Source Element Format") == 0) { in iter_decode_field()
1141 int length = strlen(iter->value); in iter_decode_field()
1142 snprintf(iter->value + length, sizeof(iter->value) - length, in iter_decode_field()
1151 gen_field_iterator_init(struct gen_field_iterator *iter, in gen_field_iterator_init() argument
1156 memset(iter, 0, sizeof(*iter)); in gen_field_iterator_init()
1158 iter->groups[iter->level] = group; in gen_field_iterator_init()
1159 iter->group = group; in gen_field_iterator_init()
1160 iter->p = p; in gen_field_iterator_init()
1161 iter->p_bit = p_bit; in gen_field_iterator_init()
1163 int length = gen_group_get_length(iter->group, iter->p); in gen_field_iterator_init()
1165 iter->p_end = length >= 0 ? &p[length] : NULL; in gen_field_iterator_init()
1166 iter->print_colors = print_colors; in gen_field_iterator_init()
1170 gen_field_iterator_next(struct gen_field_iterator *iter) in gen_field_iterator_next() argument
1173 if (!iter->field) { in gen_field_iterator_next()
1174 if (iter->group->fields) in gen_field_iterator_next()
1175 iter_start_field(iter, iter->group->fields); in gen_field_iterator_next()
1177 bool result = iter_decode_field(iter); in gen_field_iterator_next()
1178 if (!result && iter->p_end) { in gen_field_iterator_next()
1182 assert(iter->group->dw_length == 0); in gen_field_iterator_next()
1188 if (!iter_advance_field(iter)) in gen_field_iterator_next()
1191 if (!iter_decode_field(iter)) in gen_field_iterator_next()
1199 struct gen_field_iterator *iter, in print_dword_header() argument
1203 offset + 4 * dword, iter->p[dword], dword); in print_dword_header()
1226 struct gen_field_iterator iter; in gen_print_group() local
1229 gen_field_iterator_init(&iter, group, p, p_bit, color); in gen_print_group()
1230 while (gen_field_iterator_next(&iter)) { in gen_print_group()
1231 int iter_dword = iter.end_bit / 32; in gen_print_group()
1234 print_dword_header(outfile, &iter, offset, i); in gen_print_group()
1237 if (!gen_field_is_header(iter.field)) { in gen_print_group()
1238 fprintf(outfile, " %s: %s\n", iter.name, iter.value); in gen_print_group()
1239 if (iter.struct_desc) { in gen_print_group()
1240 int struct_dword = iter.start_bit / 32; in gen_print_group()
1242 gen_print_group(outfile, iter.struct_desc, struct_offset, in gen_print_group()
1243 &p[struct_dword], iter.start_bit % 32, color); in gen_print_group()