<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 5, 2016 at 8:55 AM, Lionel Landwerlin <span dir="ltr"><<a href="mailto:llandwerlin@gmail.com" target="_blank">llandwerlin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Embed the xml files into the binary, so aubinator can be used from any<br>
location.<br>
<br>
v2: Split generation packing into another patch (Jason)<br>
Check for xxd (Jason)<br>
<br>
v3: Fix out of tree builds (Jason)<br>
Generate custom variable name rather than names generated by xxd<br>
(Lionel)<br>
<br>
Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
---<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 1 +<br>
src/intel/tools/.gitignore | 5 +++<br>
src/intel/tools/Makefile.am | 19 +++++++++<br>
src/intel/tools/aubinator.c | 37 +++++++++---------<br>
src/intel/tools/decoder.c | 94 ++++++++++++++++++++++++++++++<wbr>---------------<br>
src/intel/tools/decoder.h | 4 +-<br>
6 files changed, 109 insertions(+), 51 deletions(-)<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 421f4f3..6b600f5 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -110,6 +110,7 @@ LT_PREREQ([2.2])<br>
LT_INIT([disable-static])<br>
<br>
AC_CHECK_PROG(RM, rm, [rm -f])<br>
+AC_CHECK_PROG(XXD, xxd, [xxd])<br>
<br>
AX_PROG_BISON([],<br>
AS_IF([test ! -f "$srcdir/src/compiler/glsl/<wbr>glcpp/glcpp-parse.c"],<br>
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore<br>
index 0c80a6f..c4eebde 100644<br>
--- a/src/intel/tools/.gitignore<br>
+++ b/src/intel/tools/.gitignore<br>
@@ -1 +1,6 @@<br>
/aubinator<br>
+gen6_aubinator_xml.h<br>
+gen75_aubinator_xml.h<br>
+gen7_aubinator_xml.h<br>
+gen8_aubinator_xml.h<br>
+gen9_aubinator_xml.h<br>
diff --git a/src/intel/tools/Makefile.am b/src/intel/tools/Makefile.am<br>
index 5f4d78d..5c2242d 100644<br>
--- a/src/intel/tools/Makefile.am<br>
+++ b/src/intel/tools/Makefile.am<br>
@@ -45,6 +45,25 @@ aubinator_DEPS = \<br>
$(DLOPEN_LIBS) \<br>
-lm<br>
<br>
+GENERATED_FILES = \<br>
+ gen6_aubinator_xml.h \<br>
+ gen7_aubinator_xml.h \<br>
+ gen75_aubinator_xml.h \<br>
+ gen8_aubinator_xml.h \<br>
+ gen9_aubinator_xml.h<br>
+<br>
+BUILT_SOURCES = $(GENERATED_FILES)<br>
+<br>
+SUFFIXES = _aubinator_xml.h .xml<br>
+<br>
+$(builddir)/%_aubinator_xml.<wbr>h: $(srcdir)/../genxml/%.xml Makefile<br>
+ $(MKDIR_GEN)<br>
+ $(AM_V_GEN) echo -n "static const uint8_t " > $@; \<br>
+ echo -n `basename $@` | sed -e 's,_aubinator_xml.h,,' >> $@; \<br>
+ echo "_xml[] = {" >> $@; \<br>
+ cat $< | $(XXD) -i >> $@; \<br>
+ echo "};" >> $@<br></blockquote><div><br></div><div>I talked to Sirisha a bit yesterday and she wasn't terribly happy with the way this "dirtied" things. I *think* what she didn't like was the piles of autogenerated files it dumps in the tools directory. Sirisha, please correct me if I'm misunderstanding you.<br><br></div><div>One option would be to generate them in the genxml directory as genN_xml.h. We already have genN_pack.h, so it's no big deal to dump more there. Another option would be to add a genxml_include directory to tools/ and dump them there to get them out of the way.<br><br></div><div>Personally, I don't think it's a big deal, but I'm also ok with trying to keep things clean.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
noinst_PROGRAMS = aubinator<br>
<br>
aubinator_SOURCES = \<br>
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c<br>
index 44a6bb2..8be7580 100644<br>
--- a/src/intel/tools/aubinator.c<br>
+++ b/src/intel/tools/aubinator.c<br>
@@ -1048,21 +1048,19 @@ int main(int argc, char *argv[])<br>
int c, i;<br>
bool help = false, pager = true;<br>
const char *input_file = NULL;<br>
- char gen_file[256], gen_val[24];<br>
+ char gen_val[24];<br>
const struct {<br>
const char *name;<br>
int pci_id;<br>
- int major;<br>
- int minor;<br>
} gens[] = {<br>
- { "ivb", 0x0166, 7, 0 }, /* Intel(R) Ivybridge Mobile GT2 */<br>
- { "hsw", 0x0416, 7, 5 }, /* Intel(R) Haswell Mobile GT2 */<br>
- { "byt", 0x0155, 7, 5 }, /* Intel(R) Bay Trail */<br>
- { "bdw", 0x1616, 8, 0 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br>
- { "chv", 0x22B3, 8, 0 }, /* Intel(R) HD Graphics (Cherryview) */<br>
- { "skl", 0x1912, 9, 0 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */<br>
- { "kbl", 0x591D, 9, 0 }, /* Intel(R) Kabylake GT2 */<br>
- { "bxt", 0x0A84, 9, 0 } /* Intel(R) HD Graphics (Broxton) */<br>
+ { "ivb", 0x0166 }, /* Intel(R) Ivybridge Mobile GT2 */<br>
+ { "hsw", 0x0416 }, /* Intel(R) Haswell Mobile GT2 */<br>
+ { "byt", 0x0155 }, /* Intel(R) Bay Trail */<br>
+ { "bdw", 0x1616 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br>
+ { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */<br>
+ { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */<br>
+ { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */<br>
+ { "bxt", 0x0A84 } /* Intel(R) HD Graphics (Broxton) */<br>
}, *gen = NULL;<br>
const struct option aubinator_opts[] = {<br>
{ "help", no_argument, (int *) &help, true },<br>
@@ -1073,6 +1071,7 @@ int main(int argc, char *argv[])<br>
{ "color", required_argument, NULL, 'c' },<br>
{ NULL, 0, NULL, 0 }<br>
};<br>
+ struct gen_device_info devinfo;<br>
<br>
i = 0;<br>
while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) {<br>
@@ -1118,6 +1117,13 @@ int main(int argc, char *argv[])<br>
exit(EXIT_FAILURE);<br>
}<br>
<br>
+ if (!gen_get_device_info(gen-><wbr>pci_id, &devinfo)) {<br>
+ fprintf(stderr, "can't find device information: pci_id=0x%x name=%s\n",<br>
+ gen->pci_id, gen->name);<br>
+ exit(EXIT_FAILURE);<br>
+ }<br>
+<br>
+<br>
/* Do this before we redirect stdout to pager. */<br>
if (option_color == COLOR_AUTO)<br>
option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER;<br>
@@ -1125,14 +1131,7 @@ int main(int argc, char *argv[])<br>
if (isatty(1) && pager)<br>
setup_pager();<br>
<br>
- if (gen->minor > 0) {<br>
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",<br>
- gen->major, gen->minor);<br>
- } else {<br>
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen->major);<br>
- }<br>
-<br>
- spec = gen_spec_load(gen_file);<br>
+ spec = gen_spec_load(&devinfo);<br>
disasm = gen_disasm_create(gen->pci_id)<wbr>;<br>
<br>
if (input_file == NULL) {<br>
diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c<br>
index 4cbaab2..76c237c 100644<br>
--- a/src/intel/tools/decoder.c<br>
+++ b/src/intel/tools/decoder.c<br>
@@ -33,6 +33,12 @@<br>
<br>
#include "decoder.h"<br>
<br>
+#include "gen6_aubinator_xml.h"<br>
+#include "gen7_aubinator_xml.h"<br>
+#include "gen75_aubinator_xml.h"<br>
+#include "gen8_aubinator_xml.h"<br>
+#include "gen9_aubinator_xml.h"<br>
+<br>
#define XML_BUFFER_SIZE 4096<br>
<br>
#define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )<br>
@@ -395,57 +401,83 @@ character_data(void *data, const XML_Char *s, int len)<br>
{<br>
}<br>
<br>
+static int<br>
+devinfo_to_gen(const struct gen_device_info *devinfo)<br>
+{<br>
+ int value = 10 * devinfo->gen;<br>
+<br>
+ if (devinfo->is_baytrail || devinfo->is_haswell)<br>
+ value += 5;<br></blockquote><div><br></div><div>I'm not sure if we really want baytrail to be counted as haswell. It's more like Ivy Bridge in a lot of ways. :/ That said, that's something to sort out in a different patch.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ return value;<br>
+}<br>
+<br>
+static const struct {<br>
+ int gen;<br>
+ const uint8_t *data;<br>
+ size_t data_length;<br>
+} gen_data[] = {<br>
+ { .gen = 60, .data = gen6_xml, .data_length = sizeof(gen6_xml) },<br>
+ { .gen = 70, .data = gen7_xml, .data_length = sizeof(gen7_xml) },<br>
+ { .gen = 75, .data = gen75_xml, .data_length = sizeof(gen75_xml) },<br>
+ { .gen = 80, .data = gen8_xml, .data_length = sizeof(gen8_xml) },<br>
+ { .gen = 90, .data = gen9_xml, .data_length = sizeof(gen9_xml) }<br>
+};<br>
+<br>
+static const uint8_t *<br>
+devinfo_to_xml_data(const struct gen_device_info *devinfo,<br>
+ uint32_t *data_length)<br>
+{<br>
+ int i, gen = devinfo_to_gen(devinfo);<br>
+<br>
+ for (i = 0; i < ARRAY_SIZE(gen_data); i++) {<br>
+ if (gen_data[i].gen == gen) {<br>
+ *data_length = gen_data[i].data_length;<br>
+ return gen_data[i].data;<br>
+ }<br>
+ }<br>
+<br>
+ unreachable("Unknown generation");<br>
+ return NULL;<br>
+}<br>
+<br>
struct gen_spec *<br>
-gen_spec_load(const char *filename)<br>
+gen_spec_load(const struct gen_device_info *devinfo)<br>
{<br>
struct parser_context ctx;<br>
void *buf;<br>
- int len;<br>
- FILE *input;<br>
-<br>
- input = fopen(filename, "r");<br>
- printf("xml filename = %s\n", filename);<br>
- if (input == NULL) {<br>
- fprintf(stderr, "failed to open xml description\n");<br>
- exit(EXIT_FAILURE);<br>
- }<br>
+ const void *data;<br>
+ uint32_t data_length = 0;<br>
<br>
memset(&ctx, 0, sizeof ctx);<br>
ctx.parser = XML_ParserCreate(NULL);<br>
XML_SetUserData(ctx.parser, &ctx);<br>
if (ctx.parser == NULL) {<br>
fprintf(stderr, "failed to create parser\n");<br>
- fclose(input);<br>
return NULL;<br>
}<br>
<br>
XML_SetElementHandler(ctx.<wbr>parser, start_element, end_element);<br>
XML_SetCharacterDataHandler(<wbr>ctx.parser, character_data);<br>
- ctx.loc.filename = filename;<br>
<br>
ctx.spec = xzalloc(sizeof(*ctx.spec));<br>
<br>
- do {<br>
- buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);<br>
- len = fread(buf, 1, XML_BUFFER_SIZE, input);<br>
- if (len < 0) {<br>
- fprintf(stderr, "fread: %m\n");<br>
- fclose(input);<br>
- return NULL;<br>
- }<br>
- if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {<br>
- fprintf(stderr,<br>
- "Error parsing XML at line %ld col %ld: %s\n",<br>
- XML_GetCurrentLineNumber(ctx.<wbr>parser),<br>
- XML_GetCurrentColumnNumber(<wbr>ctx.parser),<br>
- XML_ErrorString(XML_<wbr>GetErrorCode(ctx.parser)));<br>
- fclose(input);<br>
- return NULL;<br>
- }<br>
- } while (len > 0);<br>
+ data = devinfo_to_xml_data(devinfo, &data_length);<br>
+ buf = XML_GetBuffer(ctx.parser, data_length);<br>
+<br>
+ memcpy(buf, data, data_length);<br>
+<br>
+ if (XML_ParseBuffer(ctx.parser, data_length, true) == 0) {<br>
+ fprintf(stderr,<br>
+ "Error parsing XML at line %ld col %ld: %s\n",<br>
+ XML_GetCurrentLineNumber(ctx.<wbr>parser),<br>
+ XML_GetCurrentColumnNumber(<wbr>ctx.parser),<br>
+ XML_ErrorString(XML_<wbr>GetErrorCode(ctx.parser)));<br>
+ XML_ParserFree(ctx.parser);<br>
+ return NULL;<br>
+ }<br>
<br>
XML_ParserFree(ctx.parser);<br>
- fclose(input);<br>
<br>
return ctx.spec;<br>
}<br>
diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h<br>
index f688ba5..5bea9b9 100644<br>
--- a/src/intel/tools/decoder.h<br>
+++ b/src/intel/tools/decoder.h<br>
@@ -26,6 +26,8 @@<br>
#include <stdint.h><br>
#include <stdbool.h><br>
<br>
+#include "common/gen_device_info.h"<br>
+<br>
struct gen_spec;<br>
struct gen_group;<br>
struct gen_field;<br>
@@ -36,7 +38,7 @@ static inline uint32_t gen_make_gen(uint32_t major, uint32_t minor)<br>
}<br>
<br>
struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name);<br>
-struct gen_spec *gen_spec_load(const char *filename);<br>
+struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);<br>
uint32_t gen_spec_get_gen(struct gen_spec *spec);<br>
struct gen_group *gen_spec_find_instruction(<wbr>struct gen_spec *spec, const uint32_t *p);<br>
struct gen_group *gen_spec_find_register(struct gen_spec *spec, uint32_t offset);<br>
--<br>
2.9.3<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>