Deleted Added
sdiff udiff text old ( 9022:bb25e7646c41 ) new ( 9046:a1104cc13db2 )
full compact
1# Copyright (c) 2003-2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 712 unchanged lines hidden (view full) ---

721 next_pos = match.end()
722 self.sort()
723 # enumerate source & dest register operands... used in building
724 # constructor later
725 self.numSrcRegs = 0
726 self.numDestRegs = 0
727 self.numFPDestRegs = 0
728 self.numIntDestRegs = 0
729 self.memOperand = None
730 for op_desc in self.items:
731 if op_desc.isReg():
732 if op_desc.is_src:
733 op_desc.src_reg_idx = self.numSrcRegs
734 self.numSrcRegs += 1
735 if op_desc.is_dest:
736 op_desc.dest_reg_idx = self.numDestRegs
737 self.numDestRegs += 1
738 if op_desc.isFloatReg():
739 self.numFPDestRegs += 1
740 elif op_desc.isIntReg():
741 self.numIntDestRegs += 1
742 elif op_desc.isMem():
743 if self.memOperand:
744 error("Code block has more than one memory operand.")
745 self.memOperand = op_desc
746 if parser.maxInstSrcRegs < self.numSrcRegs:
747 parser.maxInstSrcRegs = self.numSrcRegs
748 if parser.maxInstDestRegs < self.numDestRegs:
749 parser.maxInstDestRegs = self.numDestRegs
750 # now make a final pass to finalize op_desc fields that may depend
751 # on the register enumeration
752 for op_desc in self.items:
753 op_desc.finalize()
754
755 def __len__(self):
756 return len(self.items)
757

--- 238 unchanged lines hidden (view full) ---

996 *
997 * It was automatically generated from the ISA description in %(filename)s
998 */
999
1000namespace %(namespace)s {
1001
1002 const int MaxInstSrcRegs = %(MaxInstSrcRegs)d;
1003 const int MaxInstDestRegs = %(MaxInstDestRegs)d;
1004
1005} // namespace %(namespace)s
1006
1007'''
1008
1009class ISAParser(Grammar):
1010 def __init__(self, output_dir, cpu_models):
1011 super(ISAParser, self).__init__()

--- 19 unchanged lines hidden (view full) ---

1031 # file where it was included.
1032 self.fileNameStack = Stack()
1033
1034 symbols = ('makeList', 're', 'string')
1035 self.exportContext = dict([(s, eval(s)) for s in symbols])
1036
1037 self.maxInstSrcRegs = 0
1038 self.maxInstDestRegs = 0
1039
1040 #####################################################################
1041 #
1042 # Lexer
1043 #
1044 # The PLY lexer module takes two things as input:
1045 # - A list of token names (the string list 'tokens')
1046 # - A regular expression describing a match for each token. The

--- 938 unchanged lines hidden (view full) ---

1985 decode_function = ''
1986 self.update_if_needed(cpu.filename, file_template % vars())
1987
1988 # The variable names here are hacky, but this will creat local
1989 # variables which will be referenced in vars() which have the
1990 # value of the globals.
1991 MaxInstSrcRegs = self.maxInstSrcRegs
1992 MaxInstDestRegs = self.maxInstDestRegs
1993 # max_inst_regs.hh
1994 self.update_if_needed('max_inst_regs.hh',
1995 max_inst_regs_template % vars())
1996
1997 def parse_isa_desc(self, *args, **kwargs):
1998 try:
1999 self._parse_isa_desc(*args, **kwargs)
2000 except ISAParserError, e:
2001 e.exit(self.fileNameStack)
2002
2003# Called as script: get args from command line.
2004# Args are: <path to cpu_models.py> <isa desc file> <output dir> <cpu models>
2005if __name__ == '__main__':
2006 execfile(sys.argv[1]) # read in CpuModel definitions
2007 cpu_models = [CpuModel.dict[cpu] for cpu in sys.argv[4:]]
2008 ISAParser(sys.argv[3], cpu_models).parse_isa_desc(sys.argv[2])