LT_INIT([disable-static])
AC_CHECK_PROG(RM, rm, [rm -f])
+AC_CHECK_PROG(XXD, xxd, [xxd])
AX_PROG_BISON([],
AS_IF([test ! -f "$srcdir/src/compiler/glsl/glcpp/glcpp-parse.c"],
BUILT_SOURCES += $(GENXML_GENERATED_FILES)
-SUFFIXES = _pack.h .xml
+SUFFIXES = _pack.h _xml.h .xml
$(GENXML_GENERATED_FILES): genxml/gen_pack_header.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/genxml/gen_pack_header.py $< > $@
+# xxd generates variable names based on the path of the input file. We
+# prefer to generate our own name here, so it doesn't vary from
+# in/out-of-tree builds.
+%_xml.h: %.xml Makefile
+ $(MKDIR_GEN)
+ $(AM_V_GEN) echo -n "static const uint8_t " > $@; \
+ sed -e 's,_xml.h,,' <<< "`basename $@`_xml[] = {" >> $@; \
+ cat $< | $(XXD) -i >> $@; \
+ echo "};" >> $@
+
EXTRA_DIST += \
genxml/gen4.xml \
genxml/gen45.xml \
genxml/gen7_pack.h \
genxml/gen75_pack.h \
genxml/gen8_pack.h \
- genxml/gen9_pack.h
+ genxml/gen9_pack.h \
+ genxml/gen6_xml.h \
+ genxml/gen7_xml.h \
+ genxml/gen75_xml.h \
+ genxml/gen8_xml.h \
+ genxml/gen9_xml.h
ISL_FILES = \
isl/isl.c \
int c, i;
bool help = false, pager = true;
const char *input_file = NULL;
- char gen_file[256], gen_val[24];
+ char gen_val[24];
const struct {
const char *name;
int pci_id;
- int major;
- int minor;
} gens[] = {
- { "ivb", 0x0166, 7, 0 }, /* Intel(R) Ivybridge Mobile GT2 */
- { "hsw", 0x0416, 7, 5 }, /* Intel(R) Haswell Mobile GT2 */
- { "byt", 0x0155, 7, 5 }, /* Intel(R) Bay Trail */
- { "bdw", 0x1616, 8, 0 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
- { "chv", 0x22B3, 8, 0 }, /* Intel(R) HD Graphics (Cherryview) */
- { "skl", 0x1912, 9, 0 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
- { "kbl", 0x591D, 9, 0 }, /* Intel(R) Kabylake GT2 */
- { "bxt", 0x0A84, 9, 0 } /* Intel(R) HD Graphics (Broxton) */
+ { "ivb", 0x0166 }, /* Intel(R) Ivybridge Mobile GT2 */
+ { "hsw", 0x0416 }, /* Intel(R) Haswell Mobile GT2 */
+ { "byt", 0x0155 }, /* Intel(R) Bay Trail */
+ { "bdw", 0x1616 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
+ { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */
+ { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
+ { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */
+ { "bxt", 0x0A84 } /* Intel(R) HD Graphics (Broxton) */
}, *gen = NULL;
const struct option aubinator_opts[] = {
{ "help", no_argument, (int *) &help, true },
{ "color", required_argument, NULL, 'c' },
{ NULL, 0, NULL, 0 }
};
+ struct gen_device_info devinfo;
i = 0;
while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) {
exit(EXIT_FAILURE);
}
+ if (!gen_get_device_info(gen->pci_id, &devinfo)) {
+ fprintf(stderr, "can't find device information: pci_id=0x%x name=%s\n",
+ gen->pci_id, gen->name);
+ exit(EXIT_FAILURE);
+ }
+
+
/* Do this before we redirect stdout to pager. */
if (option_color == COLOR_AUTO)
option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER;
if (isatty(1) && pager)
setup_pager();
- if (gen->minor > 0) {
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",
- gen->major, gen->minor);
- } else {
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen->major);
- }
-
- spec = gen_spec_load(gen_file);
+ spec = gen_spec_load(&devinfo);
disasm = gen_disasm_create(gen->pci_id);
if (input_file == NULL) {
#include "decoder.h"
+#include "genxml/gen6_xml.h"
+#include "genxml/gen7_xml.h"
+#include "genxml/gen75_xml.h"
+#include "genxml/gen8_xml.h"
+#include "genxml/gen9_xml.h"
+
#define XML_BUFFER_SIZE 4096
#define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )
{
}
+static int
+devinfo_to_gen(const struct gen_device_info *devinfo)
+{
+ int value = 10 * devinfo->gen;
+
+ if (devinfo->is_baytrail || devinfo->is_haswell)
+ value += 5;
+
+ return value;
+}
+
+static const struct {
+ int gen;
+ const uint8_t *data;
+ size_t data_length;
+} gen_data[] = {
+ { .gen = 60, .data = gen6_xml, .data_length = sizeof(gen6_xml) },
+ { .gen = 70, .data = gen7_xml, .data_length = sizeof(gen7_xml) },
+ { .gen = 75, .data = gen75_xml, .data_length = sizeof(gen75_xml) },
+ { .gen = 80, .data = gen8_xml, .data_length = sizeof(gen8_xml) },
+ { .gen = 90, .data = gen9_xml, .data_length = sizeof(gen9_xml) }
+};
+
+static const uint8_t *
+devinfo_to_xml_data(const struct gen_device_info *devinfo,
+ uint32_t *data_length)
+{
+ int i, gen = devinfo_to_gen(devinfo);
+
+ for (i = 0; i < ARRAY_SIZE(gen_data); i++) {
+ if (gen_data[i].gen == gen) {
+ *data_length = gen_data[i].data_length;
+ return gen_data[i].data;
+ }
+ }
+
+ unreachable("Unknown generation");
+ return NULL;
+}
+
struct gen_spec *
-gen_spec_load(const char *filename)
+gen_spec_load(const struct gen_device_info *devinfo)
{
struct parser_context ctx;
void *buf;
- int len;
- FILE *input;
-
- input = fopen(filename, "r");
- printf("xml filename = %s\n", filename);
- if (input == NULL) {
- fprintf(stderr, "failed to open xml description\n");
- exit(EXIT_FAILURE);
- }
+ const void *data;
+ uint32_t data_length = 0;
memset(&ctx, 0, sizeof ctx);
ctx.parser = XML_ParserCreate(NULL);
XML_SetUserData(ctx.parser, &ctx);
if (ctx.parser == NULL) {
fprintf(stderr, "failed to create parser\n");
- fclose(input);
return NULL;
}
XML_SetElementHandler(ctx.parser, start_element, end_element);
XML_SetCharacterDataHandler(ctx.parser, character_data);
- ctx.loc.filename = filename;
ctx.spec = xzalloc(sizeof(*ctx.spec));
- do {
- buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);
- len = fread(buf, 1, XML_BUFFER_SIZE, input);
- if (len < 0) {
- fprintf(stderr, "fread: %m\n");
- fclose(input);
- return NULL;
- }
- if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {
- fprintf(stderr,
- "Error parsing XML at line %ld col %ld: %s\n",
- XML_GetCurrentLineNumber(ctx.parser),
- XML_GetCurrentColumnNumber(ctx.parser),
- XML_ErrorString(XML_GetErrorCode(ctx.parser)));
- fclose(input);
- return NULL;
- }
- } while (len > 0);
+ data = devinfo_to_xml_data(devinfo, &data_length);
+ buf = XML_GetBuffer(ctx.parser, data_length);
+
+ memcpy(buf, data, data_length);
+
+ if (XML_ParseBuffer(ctx.parser, data_length, true) == 0) {
+ fprintf(stderr,
+ "Error parsing XML at line %ld col %ld: %s\n",
+ XML_GetCurrentLineNumber(ctx.parser),
+ XML_GetCurrentColumnNumber(ctx.parser),
+ XML_ErrorString(XML_GetErrorCode(ctx.parser)));
+ XML_ParserFree(ctx.parser);
+ return NULL;
+ }
XML_ParserFree(ctx.parser);
- fclose(input);
return ctx.spec;
}
#include <stdint.h>
#include <stdbool.h>
+#include "common/gen_device_info.h"
+
struct gen_spec;
struct gen_group;
struct gen_field;
}
struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name);
-struct gen_spec *gen_spec_load(const char *filename);
+struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);
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);