2 * Copyright © 2016 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #include "common/gen_device_info.h"
31 #include "util/hash_table.h"
40 union gen_field_value
;
42 static inline uint32_t gen_make_gen(uint32_t major
, uint32_t minor
)
44 return (major
<< 8) | minor
;
47 struct gen_group
*gen_spec_find_struct(struct gen_spec
*spec
, const char *name
);
48 struct gen_spec
*gen_spec_load(const struct gen_device_info
*devinfo
);
49 struct gen_spec
*gen_spec_load_from_path(const struct gen_device_info
*devinfo
,
51 void gen_spec_destroy(struct gen_spec
*spec
);
52 uint32_t gen_spec_get_gen(struct gen_spec
*spec
);
53 struct gen_group
*gen_spec_find_instruction(struct gen_spec
*spec
, const uint32_t *p
);
54 struct gen_group
*gen_spec_find_register(struct gen_spec
*spec
, uint32_t offset
);
55 struct gen_group
*gen_spec_find_register_by_name(struct gen_spec
*spec
, const char *name
);
56 struct gen_enum
*gen_spec_find_enum(struct gen_spec
*spec
, const char *name
);
58 int gen_group_get_length(struct gen_group
*group
, const uint32_t *p
);
59 const char *gen_group_get_name(struct gen_group
*group
);
60 uint32_t gen_group_get_opcode(struct gen_group
*group
);
61 struct gen_field
*gen_group_find_field(struct gen_group
*group
, const char *name
);
62 struct gen_enum
*gen_spec_find_enum(struct gen_spec
*spec
, const char *name
);
64 bool gen_field_is_header(struct gen_field
*field
);
66 struct gen_field_iterator
{
67 struct gen_group
*group
;
71 struct gen_group
*struct_desc
;
73 int p_bit
; /**< bit offset into p */
74 const uint32_t *p_end
;
75 int bit
; /**< current field starts at this bit offset into p */
79 struct gen_field
*field
;
86 struct hash_table
*commands
;
87 struct hash_table
*structs
;
88 struct hash_table
*registers_by_name
;
89 struct hash_table
*registers_by_offset
;
90 struct hash_table
*enums
;
92 struct hash_table
*access_cache
;
96 struct gen_spec
*spec
;
99 struct gen_field
*fields
; /* linked list of fields */
102 uint32_t group_offset
, group_count
;
106 struct gen_group
*parent
;
107 struct gen_group
*next
;
109 uint32_t opcode_mask
;
112 /* Register specific */
113 uint32_t register_offset
;
124 struct gen_value
**values
;
143 /* Struct definition for GEN_TYPE_STRUCT */
145 struct gen_group
*gen_struct
;
146 struct gen_enum
*gen_enum
;
148 /* Integer and fractional sizes for GEN_TYPE_UFIXED and GEN_TYPE_SFIXED */
154 union gen_field_value
{
162 struct gen_group
*parent
;
163 struct gen_field
*next
;
167 struct gen_type type
;
169 uint32_t default_value
;
171 struct gen_enum inline_enum
;
174 void gen_field_iterator_init(struct gen_field_iterator
*iter
,
175 struct gen_group
*group
,
176 const uint32_t *p
, int p_bit
,
179 bool gen_field_iterator_next(struct gen_field_iterator
*iter
);
181 void gen_print_group(FILE *out
,
182 struct gen_group
*group
,
183 uint64_t offset
, const uint32_t *p
, int p_bit
,
191 #endif /* GEN_DECODER_H */