#include <stdbool.h>
#include "common/gen_device_info.h"
+#include "util/hash_table.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
struct gen_spec;
struct gen_group;
struct gen_field;
+union gen_field_value;
static inline uint32_t gen_make_gen(uint32_t major, uint32_t minor)
{
struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);
struct gen_spec *gen_spec_load_from_path(const struct gen_device_info *devinfo,
const char *path);
+void gen_spec_destroy(struct gen_spec *spec);
uint32_t gen_spec_get_gen(struct gen_spec *spec);
struct gen_group *gen_spec_find_instruction(struct gen_spec *spec, const uint32_t *p);
struct gen_group *gen_spec_find_register(struct gen_spec *spec, uint32_t offset);
struct gen_group *gen_spec_find_register_by_name(struct gen_spec *spec, const char *name);
+struct gen_enum *gen_spec_find_enum(struct gen_spec *spec, const char *name);
+
int gen_group_get_length(struct gen_group *group, const uint32_t *p);
const char *gen_group_get_name(struct gen_group *group);
uint32_t gen_group_get_opcode(struct gen_group *group);
+struct gen_field *gen_group_find_field(struct gen_group *group, const char *name);
struct gen_enum *gen_spec_find_enum(struct gen_spec *spec, const char *name);
+bool gen_field_is_header(struct gen_field *field);
+void gen_field_decode(struct gen_field *field,
+ const uint32_t *p, const uint32_t *end,
+ union gen_field_value *value);
+
struct gen_field_iterator {
struct gen_group *group;
char name[128];
char value[128];
struct gen_group *struct_desc;
const uint32_t *p;
+ const uint32_t *p_end;
int dword; /**< current field starts at &p[dword] */
int start; /**< current field starts at this bit number */
int end; /**< current field ends at this bit number */
struct gen_spec {
uint32_t gen;
- uint32_t ncommands;
- struct gen_group *commands[256];
- uint32_t nstructs;
- struct gen_group *structs[256];
- uint32_t nregisters;
- struct gen_group *registers[256];
- uint32_t nenums;
- struct gen_enum *enums[256];
+ struct hash_table *commands;
+ struct hash_table *structs;
+ struct hash_table *registers_by_name;
+ struct hash_table *registers_by_offset;
+ struct hash_table *enums;
+
+ struct hash_table *access_cache;
};
struct gen_group {
struct gen_field *fields; /* linked list of fields */
+ uint32_t dw_length;
uint32_t group_offset, group_count;
uint32_t group_size;
bool variable;
};
};
+union gen_field_value {
+ bool b32;
+ float f32;
+ uint64_t u64;
+ int64_t i64;
+};
+
struct gen_field {
+ struct gen_group *parent;
struct gen_field *next;
char *name;
uint64_t offset, const uint32_t *p,
bool color);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif /* GEN_DECODER_H */