diff --git a/src/compiler/isaspec/decode.c b/src/compiler/isaspec/decode.c index 127773d6641..1938e309870 100644 --- a/src/compiler/isaspec/decode.c +++ b/src/compiler/isaspec/decode.c @@ -21,6 +21,10 @@ * SOFTWARE. */ +/* This file should not be built directly. Instead, it is included in the C + * file generated by isaspec/decode.py and built along with it. + */ + #include #include #include @@ -37,7 +41,6 @@ #include "util/u_debug.h" #include "util/u_math.h" -#include "decode.h" #include "isa.h" /** diff --git a/src/compiler/isaspec/decode.h b/src/compiler/isaspec/decode.h index ce8d1bfd8fd..e44517ced46 100644 --- a/src/compiler/isaspec/decode.h +++ b/src/compiler/isaspec/decode.h @@ -21,10 +21,10 @@ * SOFTWARE. */ -#ifndef _DECODE_H_ -#define _DECODE_H_ +/* This file should not be included directly. Instead, it is included as part + * of the header file generated by isaspec/decode.py + */ -#include #include #include @@ -145,5 +145,3 @@ struct isa_bitset { unsigned num_cases; const struct isa_case *cases[]; }; - -#endif /* _DECODE_H_ */ diff --git a/src/compiler/isaspec/decode.py b/src/compiler/isaspec/decode.py index afa56edf508..d7ba16d48e6 100755 --- a/src/compiler/isaspec/decode.py +++ b/src/compiler/isaspec/decode.py @@ -50,7 +50,7 @@ template = """\ * IN THE SOFTWARE. */ -#include "decode.h" +#include "${header}" /* * enum tables, these don't have any link back to other tables so just @@ -192,6 +192,8 @@ const struct isa_bitset *${root.get_c_name()}[] = { }; %endfor +#include "decode.c" + """ header = """\ @@ -258,37 +260,7 @@ uint64_t_to_bitmask(uint64_t val) return mask; } -#endif /* _${guard}_ */ - -""" - -glue = """\ -/* Copyright (C) 2020 Google, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef _${guard}_ -#define _${guard}_ - -#include "${isa}" +#include "decode.h" #endif /* _${guard}_ */ @@ -302,20 +274,14 @@ def main(): parser.add_argument('--xml', required=True, help='isaspec XML file.') parser.add_argument('--out-c', required=True, help='Output C file.') parser.add_argument('--out-h', required=True, help='Output H file.') - parser.add_argument('--out-glue-h', - required=True, - help='Output glue H file.') args = parser.parse_args() isa = ISA(args.xml) try: - with open(args.out_glue_h, 'w') as f: - f.write(Template(glue).render(guard=guard(args.out_glue_h), - isa=os.path.basename(args.out_h))) - with open(args.out_c, 'w') as f: - f.write(Template(template).render(isa=isa)) + out_h_basename = os.path.basename(args.out_h) + f.write(Template(template).render(isa=isa, header=out_h_basename)) with open(args.out_h, 'w') as f: f.write(Template(header).render(isa=isa, guard=guard(args.out_h))) diff --git a/src/compiler/isaspec/meson.build b/src/compiler/isaspec/meson.build index cf08a1f315f..37b6721a097 100644 --- a/src/compiler/isaspec/meson.build +++ b/src/compiler/isaspec/meson.build @@ -19,7 +19,7 @@ # SOFTWARE. prog_isaspec_decode = find_program('decode.py') -idep_isaspec_decode = declare_dependency(sources : files('decode.c'), include_directories : include_directories('.')) +idep_isaspec_decode = declare_dependency(include_directories : include_directories('.')) prog_isaspec_encode = find_program('encode.py') diff --git a/src/freedreno/isa/meson.build b/src/freedreno/isa/meson.build index 63b4c43b042..0fba8b040a5 100644 --- a/src/freedreno/isa/meson.build +++ b/src/freedreno/isa/meson.build @@ -34,10 +34,10 @@ isa_depend_files = [ ir3_isa = custom_target( 'ir3-isa', input: ['ir3.xml'], - output: ['isaspec-isa.h', 'ir3-isa.c', 'ir3-isa.h'], + output: ['ir3-isa.c', 'ir3-isa.h'], command: [ - prog_isaspec_decode, '--xml', '@INPUT@', '--out-glue-h', '@OUTPUT0@', - '--out-c', '@OUTPUT1@', '--out-h', '@OUTPUT2@', + prog_isaspec_decode, '--xml', '@INPUT@', + '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@', ], depend_files: isa_depend_files, )