<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 7, 2016 at 2:27 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"><span class="">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>
v4: Move generated _xml.h files to genxml/ (Sirisha)<br>
<br>
</span>v5: Remove newline from makefile (Jason)<br>
<span class=""><br>
Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
Cc: Sirisha Gandikota <<a href="mailto:Sirisha.Gandikota@intel.com">Sirisha.Gandikota@intel.com</a>><br>
---<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 1 +<br>
</span> src/intel/<a href="http://Makefile.genxml.am" rel="noreferrer" target="_blank">Makefile.genxml.am</a> | 9 ++++-<br>
src/intel/Makefile.sources | 7 +++-<br>
<span class=""> src/intel/genxml/.gitignore | 1 +<br>
src/intel/tools/aubinator.c | 37 +++++++++--------<br>
src/intel/tools/decoder.c | 94 +++++++++++++++++++++++++++++-<wbr>--------------<br>
src/intel/tools/decoder.h | 4 +-<br>
</span> 7 files changed, 100 insertions(+), 53 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 0c437a5..77eefd1 100644<br>
<span class="">--- 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/<a href="http://Makefile.genxml.am" rel="noreferrer" target="_blank">Makefile.genxml.am</a> b/src/intel/<a href="http://Makefile.genxml.am" rel="noreferrer" target="_blank">Makefile.genxml.am</a><br>
</span>index f80e2fd..e2a23c9 100644<br>
<span class="">--- a/src/intel/<a href="http://Makefile.genxml.am" rel="noreferrer" target="_blank">Makefile.genxml.am</a><br>
+++ b/src/intel/<a href="http://Makefile.genxml.am" rel="noreferrer" target="_blank">Makefile.genxml.am</a><br>
@@ -21,7 +21,7 @@<br>
<br>
BUILT_SOURCES += $(GENXML_GENERATED_FILES)<br>
<br>
-SUFFIXES = _pack.h .xml<br>
+SUFFIXES = _pack.h _xml.h .xml<br>
<br>
$(GENXML_GENERATED_FILES): genxml/gen_pack_header.py<br>
<br>
</span>@@ -29,6 +29,13 @@ $(GENXML_GENERATED_FILES): genxml/gen_pack_header.py<br>
<span class=""> $(MKDIR_GEN)<br>
$(PYTHON_GEN) $(srcdir)/genxml/gen_pack_<wbr>header.py $< > $@<br>
<br>
</span>+%_xml.h: %.xml Makefile<br>
<span class="">+ $(MKDIR_GEN)<br>
+ $(AM_V_GEN) echo -n "static const uint8_t " > $@; \<br>
</span>+ sed -e 's,_xml.h,,' <<< "`basename $@`_xml[] = {" >> $@; \<br>
<span class="">+ cat $< | $(XXD) -i >> $@; \<br>
+ echo "};" >> $@<br></span></blockquote><div><br></div><div>It'd still be nice to have a comment here about why all this is needed (out-of-tree builds). With that,<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><br></div><div>Sorry for all the review churn. :/<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
</span><span class="">+<br>
EXTRA_DIST += \<br>
genxml/gen4.xml \<br>
genxml/gen45.xml \<br>
diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources<br>
</span>index 22ca63b..5b759bf 100644<br>
--- a/src/intel/Makefile.sources<br>
+++ b/src/intel/Makefile.sources<br>
@@ -21,7 +21,12 @@ GENXML_GENERATED_FILES = \<br>
<span class=""> genxml/gen7_pack.h \<br>
genxml/gen75_pack.h \<br>
genxml/gen8_pack.h \<br>
- genxml/gen9_pack.h<br>
+ genxml/gen9_pack.h \<br>
</span>+ genxml/gen6_xml.h \<br>
<div class="HOEnZb"><div class="h5">+ genxml/gen7_xml.h \<br>
+ genxml/gen75_xml.h \<br>
+ genxml/gen8_xml.h \<br>
+ genxml/gen9_xml.h<br>
<br>
ISL_FILES = \<br>
isl/isl.c \<br>
diff --git a/src/intel/genxml/.gitignore b/src/intel/genxml/.gitignore<br>
index dd11495..c5672b5 100644<br>
--- a/src/intel/genxml/.gitignore<br>
+++ b/src/intel/genxml/.gitignore<br>
@@ -1 +1,2 @@<br>
gen*_pack.h<br>
+gen*_xml.h<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..778cd5b 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 "genxml/gen6_xml.h"<br>
+#include "genxml/gen7_xml.h"<br>
+#include "genxml/gen75_xml.h"<br>
+#include "genxml/gen8_xml.h"<br>
+#include "genxml/gen9_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>
+<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>
</div></div></blockquote></div><br></div></div>