From a29b1d5716ed8dbcf9f6cc23744adbdfe09b2571 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 6 May 2021 22:22:44 +0300 Subject: [PATCH] intel/clc: allow producing SPIRV files Useful to debug the parser. Signed-off-by: Lionel Landwerlin Reviewed-by: Jason Ekstrand Part-of: --- src/intel/compiler/intel_clc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/intel_clc.c b/src/intel/compiler/intel_clc.c index e2fb221..23a97de 100644 --- a/src/intel/compiler/intel_clc.c +++ b/src/intel/compiler/intel_clc.c @@ -261,6 +261,7 @@ print_usage(char *exec_name, FILE *f) " -p, --platform Specify the target platform name.\n" " --prefix Prefix for variable names in generated C code.\n" " -g, --out Specify the output filename.\n" +" -s, --spv Specify the output filename for spirv.\n" , exec_name); } @@ -277,10 +278,11 @@ int main(int argc, char **argv) {"prefix", required_argument, 0, OPT_PREFIX}, {"in", required_argument, 0, 'i'}, {"out", required_argument, 0, 'o'}, + {"spv", required_argument, 0, 's'}, {0, 0, 0, 0} }; - char *entry_point = NULL, *platform = NULL, *outfile = NULL, *prefix = NULL; + char *entry_point = NULL, *platform = NULL, *outfile = NULL, *spv_outfile = NULL, *prefix = NULL; struct util_dynarray clang_args; struct util_dynarray input_files; struct util_dynarray spirv_objs; @@ -294,7 +296,7 @@ int main(int argc, char **argv) util_dynarray_init(&spirv_ptr_objs, mem_ctx); int ch; - while ((ch = getopt_long(argc, argv, "he:p:o:", long_options, NULL)) != -1) + while ((ch = getopt_long(argc, argv, "he:p:s:o:", long_options, NULL)) != -1) { switch (ch) { @@ -310,6 +312,9 @@ int main(int argc, char **argv) case 'o': outfile = optarg; break; + case 's': + spv_outfile = optarg; + break; case OPT_PREFIX: prefix = optarg; break; @@ -412,6 +417,12 @@ int main(int argc, char **argv) return 1; } + if (spv_outfile) { + FILE *fp = fopen(spv_outfile, "w"); + fwrite(final_spirv.data, final_spirv.size, 1, fp); + fclose(fp); + } + struct clc_parsed_spirv parsed_spirv_data; if (!clc_parse_spirv(&final_spirv, &logger, &parsed_spirv_data)) { ralloc_free(mem_ctx); -- 2.7.4