diff options
author | Tim Rowley <[email protected]> | 2017-03-16 13:44:52 -0500 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-03-20 18:05:54 -0500 |
commit | fe325e64230e01fa7f3044afb99f927bc594bef7 (patch) | |
tree | 2f8333755e3a71a57d18259b9aaa9a1a84a823bc /src/gallium/drivers/swr/rasterizer | |
parent | cf8fa673647b05f9e42b7ab1f283eef781da50b1 (diff) |
swr: [rasterizer] Cleanup naming of codegen files
All template files and generated files are prefixed with gen_.
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/rasterizer')
20 files changed, 93 insertions, 86 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp index 20b14a3a28c..a7d41e27c0d 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp +++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp @@ -30,7 +30,7 @@ #include "common/os.h" #include "archrast/archrast.h" #include "archrast/eventmanager.h" -#include "gen_ar_eventhandlerfile.h" +#include "gen_ar_eventhandlerfile.hpp" namespace ArchRast { diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.h b/src/gallium/drivers/swr/rasterizer/archrast/archrast.h index c0f9d6a8194..1b81e6e952b 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.h +++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.h @@ -28,7 +28,7 @@ #pragma once #include "common/os.h" -#include "gen_ar_event.h" +#include "gen_ar_event.hpp" namespace ArchRast { diff --git a/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h b/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h index b361188c3dd..44f75e44410 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h +++ b/src/gallium/drivers/swr/rasterizer/archrast/eventmanager.h @@ -29,8 +29,8 @@ #include "common/os.h" -#include "gen_ar_event.h" -#include "gen_ar_eventhandler.h" +#include "gen_ar_event.hpp" +#include "gen_ar_eventhandler.hpp" #include <vector> diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py index 901d6d8d05b..cbaa1beddec 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py @@ -36,12 +36,12 @@ def write_template_to_string(template_filename, **kwargs): except: traceback = RichTraceback() for (filename, lineno, function, line) in traceback.traceback: - print("File %s, line %s, in %s" % (filename, lineno, function)) - print(line, "\n") - print("%s: %s" % (str(traceback.error.__class__.__name__), traceback.error)) + print('File %s, line %s, in %s' % (filename, lineno, function)) + print(line, '\n') + print('%s: %s' % (str(traceback.error.__class__.__name__), traceback.error)) def write_template_to_file(template_filename, output_filename, **kwargs): - with open(output_filename, "w") as outfile: + with open(output_filename, 'w') as outfile: print(write_template_to_string(template_filename, **kwargs), file=outfile) def parse_event_fields(lines, idx, event_dict): @@ -57,14 +57,14 @@ def parse_event_fields(lines, idx, event_dict): line = lines[idx].rstrip() idx += 1 - field = re.match(r"(\s*)(\w+)(\s*)(\w+)", line) + field = re.match(r'(\s*)(\w+)(\s*)(\w+)', line) if field: field_types.append(field.group(2)) field_names.append(field.group(4)) num_fields += 1 - end_of_event = re.match(r"(\s*)};", line) + end_of_event = re.match(r'(\s*)};', line) event_dict['field_types'] = field_types event_dict['field_names'] = field_names @@ -82,15 +82,15 @@ def parse_enums(lines, idx, event_dict): line = lines[idx].rstrip() idx += 1 - preprocessor = re.search(r"#if|#endif", line) + preprocessor = re.search(r'#if|#endif', line) if not preprocessor: - enum = re.match(r"(\s*)(\w+)(\s*)", line) + enum = re.match(r'(\s*)(\w+)(\s*)', line) if enum: enum_names.append(line) - end_of_enum = re.match(r"(\s*)};", line) + end_of_enum = re.match(r'(\s*)};', line) event_dict['names'] = enum_names return idx @@ -115,7 +115,7 @@ def parse_protos(filename): idx += 1 # search for event definitions. - match = re.match(r"(\s*)event(\s*)(\w+)", line) + match = re.match(r'(\s*)event(\s*)(\w+)', line) if match: eventId += 1 @@ -127,7 +127,7 @@ def parse_protos(filename): idx = parse_event_fields(lines, idx, protos['events'][event_name]) # search for enums. - match = re.match(r"(\s*)enum(\s*)(\w+)", line) + match = re.match(r'(\s*)enum(\s*)(\w+)', line) if match: enum_name = match.group(3) @@ -142,12 +142,12 @@ def main(): # Parse args... parser = argparse.ArgumentParser() - parser.add_argument("--proto", "-p", help="Path to proto file", required=True) - parser.add_argument("--output", "-o", help="Output filename (i.e. event.h)", required=True) - parser.add_argument("--gen_event_h", "-geh", help="Generate event header", action="store_true", default=False) - parser.add_argument("--gen_event_cpp", "-gec", help="Generate event cpp", action="store_true", default=False) - parser.add_argument("--gen_eventhandler_h", "-gehh", help="Generate eventhandler header", action="store_true", default=False) - parser.add_argument("--gen_eventhandlerfile_h", "-gehf", help="Generate eventhandler header for writing to files", action="store_true", default=False) + parser.add_argument('--proto', '-p', help='Path to proto file', required=True) + parser.add_argument('--output', '-o', help='Output filename (i.e. event.hpp)', required=True) + parser.add_argument('--gen_event_hpp', help='Generate event header', action='store_true', default=False) + parser.add_argument('--gen_event_cpp', help='Generate event cpp', action='store_true', default=False) + parser.add_argument('--gen_eventhandler_hpp', help='Generate eventhandler header', action='store_true', default=False) + parser.add_argument('--gen_eventhandlerfile_hpp', help='Generate eventhandler header for writing to files', action='store_true', default=False) args = parser.parse_args() proto_filename = args.proto @@ -155,21 +155,21 @@ def main(): (output_dir, output_filename) = os.path.split(args.output) if not output_dir: - output_dir = "." + output_dir = '.' - #print("output_dir = %s" % output_dir, file=sys.stderr) - #print("output_filename = %s" % output_filename, file=sys.stderr) + #print('output_dir = %s' % output_dir, file=sys.stderr) + #print('output_filename = %s' % output_filename, file=sys.stderr) if not os.path.exists(proto_filename): - print("Error: Could not find proto file %s" % proto_filename, file=sys.stderr) + print('Error: Could not find proto file %s' % proto_filename, file=sys.stderr) return 1 protos = parse_protos(proto_filename) # Generate event header - if args.gen_event_h: + if args.gen_event_hpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_event_h.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_event.hpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, @@ -179,7 +179,7 @@ def main(): # Generate event implementation if args.gen_event_cpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_event_cpp.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_event.cpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, @@ -187,25 +187,25 @@ def main(): protos=protos) # Generate event handler header - if args.gen_eventhandler_h: + if args.gen_eventhandler_hpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_eventhandler_h.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_eventhandler.hpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, filename=output_filename, - event_header="gen_ar_event.h", # todo: fix this! + event_header='gen_ar_event.hpp', protos=protos) # Generate event handler header - if args.gen_eventhandlerfile_h: + if args.gen_eventhandlerfile_hpp: curdir = os.path.dirname(os.path.abspath(__file__)) - template_file = os.sep.join([curdir, 'templates', 'ar_eventhandlerfile_h.template']) + template_file = os.sep.join([curdir, 'templates', 'gen_ar_eventhandlerfile.hpp']) output_fullpath = os.sep.join([output_dir, output_filename]) write_template_to_file(template_file, output_fullpath, filename=output_filename, - event_header="gen_ar_eventhandler.h", # todo: fix this! + event_header='gen_ar_eventhandler.hpp', protos=protos) return 0 diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py index c889ea5816e..f2a22729dc2 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py @@ -94,8 +94,8 @@ def main(args=sys.argv[1:]): # generate .cpp files if args.cpp: - baseCppName = os.path.join(args.outdir, 'BackendPixelRate%s.cpp') - templateCpp = os.path.join(thisDir, 'templates', 'backend_template.cpp') + baseCppName = os.path.join(args.outdir, 'gen_BackendPixelRate%s.cpp') + templateCpp = os.path.join(thisDir, 'templates', 'gen_backend.cpp') for fileNum in range(numFiles): filename = baseCppName % str(fileNum) @@ -109,7 +109,7 @@ def main(args=sys.argv[1:]): # generate gen_backend.cmake file if args.cmake: - templateCmake = os.path.join(thisDir, 'templates', 'backend_template.cmake') + templateCmake = os.path.join(thisDir, 'templates', 'gen_backend.cmake') cmakeFile = os.path.join(args.outdir, 'gen_backends.cmake') #print('Generating', cmakeFile) write_template_to_file( @@ -117,7 +117,7 @@ def main(args=sys.argv[1:]): cmakeFile, cmdline=sys.argv, numFiles=numFiles, - baseCppName=baseCppName.replace('\\','/')) + baseCppName='${RASTY_GEN_SRC_DIR}/backends/' + os.path.basename(baseCppName)) #print("Generated %d template instantiations in %d files" % (len(output_list), numFiles)) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py index 50afdcdd10c..e722b84a9f1 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py @@ -51,7 +51,7 @@ def main(args=sys.argv[1:]): # parse args parser = argparse.ArgumentParser() - parser.add_argument("--input", "-i", help="Path to knobs.template", required=True) + parser.add_argument("--input", "-i", help="Path to gen_knobs.cpp template", required=True) parser.add_argument("--output", "-o", help="Path to output file", required=True) parser.add_argument("--gen_h", "-gen_h", help="Generate gen_knobs.h", action="store_true", default=False) parser.add_argument("--gen_cpp", "-gen_cpp", help="Generate gen_knobs.cpp", action="store_true", required=False) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py index cfd63942dc1..bd8e48e4218 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py @@ -95,7 +95,7 @@ intrinsics = [ ] this_dir = os.path.dirname(os.path.abspath(__file__)) -template = os.path.join(this_dir, 'templates', 'gen_builder_template.hpp') +template = os.path.join(this_dir, 'templates', 'gen_builder.hpp') def convert_uppercamel(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_cpp.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp index 4b3dcd57dbc..b743b2f3d2d 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_cpp.template +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.cpp @@ -28,8 +28,8 @@ * ******************************************************************************/ #include "common/os.h" -#include "gen_ar_event.h" -#include "gen_ar_eventhandler.h" +#include "gen_ar_event.hpp" +#include "gen_ar_eventhandler.hpp" using namespace ArchRast; % for name in protos['event_names']: diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp index 68926ea8053..68926ea8053 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_event_h.template +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_event.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp index cfed2aded0c..cfed2aded0c 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandler_h.template +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandler.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp index 48ff0b0a958..48ff0b0a958 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/ar_eventhandlerfile_h.template +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp index 4eb4ad4f2b3..4eb4ad4f2b3 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/backend_template.cpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_backend.cpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp index 2e957581ac4..2e957581ac4 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder_template.hpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp index 99294d2290e..81e49da659c 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/knobs_template.cpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp @@ -1,28 +1,4 @@ -<% - max_len = 0 - for knob in knobs: - if len(knob[0]) > max_len: max_len = len(knob[0]) - max_len += len('KNOB_ ') - if max_len % 4: max_len += 4 - (max_len % 4) - - def space_knob(knob): - knob_len = len('KNOB_' + knob) - return ' '*(max_len - knob_len) - - def calc_max_name_len(choices_array): - _max_len = 0 - for choice in choices_array: - if len(choice['name']) > _max_len: _max_len = len(choice['name']) - - if _max_len % 4: _max_len += 4 - (_max_len % 4) - return _max_len - - def space_name(name, max_len): - name_len = len(name) - return ' '*(max_len - name_len) - - -%>/****************************************************************************** +/****************************************************************************** * * Copyright 2015-2017 * Intel Corporation @@ -53,6 +29,7 @@ * ${'\n* '.join(cmdline)} * ******************************************************************************/ +<% calc_max_knob_len(knobs) %> %if gen_header: #pragma once #include <string> @@ -168,3 +145,33 @@ std::string GlobalKnobs::ToString(const char* optPerLinePrefix) } % endif + +<%! + # Globally available python + max_len = 0 + def calc_max_knob_len(knobs): + global max_len + max_len = 0 + for knob in knobs: + if len(knob[0]) > max_len: max_len = len(knob[0]) + max_len += len('KNOB_ ') + if max_len % 4: max_len += 4 - (max_len % 4) + + def space_knob(knob): + knob_len = len('KNOB_' + knob) + return ' '*(max_len - knob_len) + + def calc_max_name_len(choices_array): + _max_len = 0 + for choice in choices_array: + if len(choice['name']) > _max_len: _max_len = len(choice['name']) + + if _max_len % 4: _max_len += 4 - (_max_len % 4) + return _max_len + + def space_name(name, max_len): + name_len = len(name) + return ' '*(max_len - name_len) + + +%>
\ No newline at end of file diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp index 40bc8a42cdc..18ea7817137 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp @@ -30,19 +30,6 @@ * ${'\n* '.join(cmdline)} * ******************************************************************************/ -<%! - def calc_max_len(fields): - max_type_len = 0 - max_name_len = 0 - for f in fields: - if len(f['type']) > max_type_len: max_type_len = len(f['type']) - if len(f['name']) > max_name_len: max_name_len = len(f['name']) - return (max_type_len, max_name_len) - - def pad(cur_len, max_len): - pad_amt = max_len - cur_len - return ' '*pad_amt -%> #pragma once namespace SwrJit @@ -58,7 +45,7 @@ namespace SwrJit (max_type_len, max_name_len) = calc_max_len(type['members']) %> %for member in type['members']: - /* ${member['name']} ${pad(len(member['name']), max_name_len)} */ members.push_back( ${member['type']} ); + /* ${member['name']} ${pad(len(member['name']), max_name_len)}*/ members.push_back( ${member['type']} ); %endfor return StructType::get(ctx, members, false); @@ -70,3 +57,17 @@ namespace SwrJit %endfor } // ns SwrJit + +<%! # Global function definitions + def calc_max_len(fields): + max_type_len = 0 + max_name_len = 0 + for f in fields: + if len(f['type']) > max_type_len: max_type_len = len(f['type']) + if len(f['name']) > max_name_len: max_name_len = len(f['name']) + return (max_type_len, max_name_len) + + def pad(cur_len, max_len): + pad_amt = max_len - cur_len + return ' '*pad_amt +%> diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index ca5a6dd1a23..bd63796d138 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -43,7 +43,6 @@ #include "core/clip.h" #include "core/utils.h" -#include "common/simdintrin.h" #include "common/os.h" static const SWR_RECT g_MaxScissorRect = { 0, 0, KNOB_MAX_SCISSOR_X, KNOB_MAX_SCISSOR_Y }; diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp index ead52fe55f3..79118f5f65c 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp @@ -59,7 +59,7 @@ #include "core/state.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include <sstream> #if defined(_WIN32) diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp index 55961d19957..1c2c8df1977 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp @@ -30,7 +30,7 @@ #include "builder.h" #include "jit_api.h" #include "blend_jit.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include <sstream> diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp index 9bc63f31c6a..d8eb5309d7c 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp @@ -30,7 +30,7 @@ #include "builder.h" #include "jit_api.h" #include "fetch_jit.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include <sstream> #include <tuple> diff --git a/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp index 3d393387bb0..494d8cfc89d 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/streamout_jit.cpp @@ -30,7 +30,7 @@ #include "builder.h" #include "jit_api.h" #include "streamout_jit.h" -#include "state_llvm.h" +#include "gen_state_llvm.h" #include "llvm/IR/DataLayout.h" #include <sstream> |