isa_parser.py (10196:be0e1724eb39) | isa_parser.py (10319:4207f9bfcceb) |
---|---|
1# Copyright (c) 2003-2005 The Regents of The University of Michigan 2# Copyright (c) 2013 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 1164 unchanged lines hidden (view full) --- 1173 1174####################### 1175# 1176# ISA Parser 1177# parses ISA DSL and emits C++ headers and source 1178# 1179 1180class ISAParser(Grammar): | 1# Copyright (c) 2003-2005 The Regents of The University of Michigan 2# Copyright (c) 2013 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 1164 unchanged lines hidden (view full) --- 1173 1174####################### 1175# 1176# ISA Parser 1177# parses ISA DSL and emits C++ headers and source 1178# 1179 1180class ISAParser(Grammar): |
1181 def __init__(self, output_dir, cpu_models): | 1181 class CpuModel(object): 1182 def __init__(self, name, filename, includes, strings): 1183 self.name = name 1184 self.filename = filename 1185 self.includes = includes 1186 self.strings = strings 1187 1188 def __init__(self, output_dir): |
1182 super(ISAParser, self).__init__() 1183 self.output_dir = output_dir 1184 1185 self.filename = None # for output file watermarking/scaremongering 1186 | 1189 super(ISAParser, self).__init__() 1190 self.output_dir = output_dir 1191 1192 self.filename = None # for output file watermarking/scaremongering 1193 |
1187 self.cpuModels = cpu_models | 1194 self.cpuModels = [ 1195 ISAParser.CpuModel('ExecContext', 1196 'generic_cpu_exec.cc', 1197 '#include "cpu/exec_context.hh"', 1198 { "CPU_exec_context" : "ExecContext" }), 1199 ] |
1188 1189 # variable to hold templates 1190 self.templateMap = {} 1191 1192 # This dictionary maps format name strings to Format objects. 1193 self.formatMap = {} 1194 1195 # Track open files and, if applicable, how many chunks it has been --- 1175 unchanged lines hidden (view full) --- 2371 2372 def parse_isa_desc(self, *args, **kwargs): 2373 try: 2374 self._parse_isa_desc(*args, **kwargs) 2375 except ISAParserError, e: 2376 e.exit(self.fileNameStack) 2377 2378# Called as script: get args from command line. | 1200 1201 # variable to hold templates 1202 self.templateMap = {} 1203 1204 # This dictionary maps format name strings to Format objects. 1205 self.formatMap = {} 1206 1207 # Track open files and, if applicable, how many chunks it has been --- 1175 unchanged lines hidden (view full) --- 2383 2384 def parse_isa_desc(self, *args, **kwargs): 2385 try: 2386 self._parse_isa_desc(*args, **kwargs) 2387 except ISAParserError, e: 2388 e.exit(self.fileNameStack) 2389 2390# Called as script: get args from command line. |
2379# Args are: <path to cpu_models.py> <isa desc file> <output dir> <cpu models> | 2391# Args are: <isa desc file> <output dir> |
2380if __name__ == '__main__': | 2392if __name__ == '__main__': |
2381 execfile(sys.argv[1]) # read in CpuModel definitions 2382 cpu_models = [CpuModel.dict[cpu] for cpu in sys.argv[4:]] 2383 ISAParser(sys.argv[3], cpu_models).parse_isa_desc(sys.argv[2]) | 2393 ISAParser(sys.argv[2]).parse_isa_desc(sys.argv[1]) |