isa_parser.py (8448:86ed97566b23) isa_parser.py (8449:4be49ad47c74)
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

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

1316 exec_output=self.exportContext["exec_output"],
1317 decode_block=self.exportContext["decode_block"])
1318
1319 # Define the mapping from operand type extensions to C++ types and
1320 # bit widths (stored in operandTypeMap).
1321 def p_def_operand_types(self, t):
1322 'def_operand_types : DEF OPERAND_TYPES CODELIT SEMI'
1323 try:
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

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

1316 exec_output=self.exportContext["exec_output"],
1317 decode_block=self.exportContext["decode_block"])
1318
1319 # Define the mapping from operand type extensions to C++ types and
1320 # bit widths (stored in operandTypeMap).
1321 def p_def_operand_types(self, t):
1322 'def_operand_types : DEF OPERAND_TYPES CODELIT SEMI'
1323 try:
1324 user_dict = eval('{' + t[3] + '}')
1324 self.operandTypeMap = eval('{' + t[3] + '}')
1325 except Exception, exc:
1326 if debug:
1327 raise
1328 error(t,
1329 'error: %s in def operand_types block "%s".' % (exc, t[3]))
1325 except Exception, exc:
1326 if debug:
1327 raise
1328 error(t,
1329 'error: %s in def operand_types block "%s".' % (exc, t[3]))
1330 self.buildOperandTypeMap(user_dict, t.lexer.lineno)
1331 t[0] = GenCode(self) # contributes nothing to the output C++ file
1332
1333 # Define the mapping from operand names to operand classes and
1334 # other traits. Stored in operandNameMap.
1335 def p_def_operands(self, t):
1336 'def_operands : DEF OPERANDS CODELIT SEMI'
1337 if not hasattr(self, 'operandTypeMap'):
1338 error(t, 'error: operand types must be defined before operands')

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

1783 return re.sub(r'%(?=\(CPU_)', '%%', template)
1784
1785 def protectNonSubstPercents(self, s):
1786 '''Protect any non-dict-substitution '%'s in a format string
1787 (i.e. those not followed by '(')'''
1788
1789 return re.sub(r'%(?!\()', '%%', s)
1790
1330 t[0] = GenCode(self) # contributes nothing to the output C++ file
1331
1332 # Define the mapping from operand names to operand classes and
1333 # other traits. Stored in operandNameMap.
1334 def p_def_operands(self, t):
1335 'def_operands : DEF OPERANDS CODELIT SEMI'
1336 if not hasattr(self, 'operandTypeMap'):
1337 error(t, 'error: operand types must be defined before operands')

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

1782 return re.sub(r'%(?=\(CPU_)', '%%', template)
1783
1784 def protectNonSubstPercents(self, s):
1785 '''Protect any non-dict-substitution '%'s in a format string
1786 (i.e. those not followed by '(')'''
1787
1788 return re.sub(r'%(?!\()', '%%', s)
1789
1791 def buildOperandTypeMap(self, user_dict, lineno):
1792 """Generate operandTypeMap from the user's 'def operand_types'
1793 statement."""
1794 operand_type = {}
1795 for (ext, (desc, size)) in user_dict.iteritems():
1796 if desc == 'signed int':
1797 ctype = 'int%d_t' % size
1798 elif desc == 'unsigned int':
1799 ctype = 'uint%d_t' % size
1800 elif desc == 'float':
1801 if size == 32:
1802 ctype = 'float'
1803 elif size == 64:
1804 ctype = 'double'
1805 elif desc == 'twin64 int':
1806 ctype = 'Twin64_t'
1807 elif desc == 'twin32 int':
1808 ctype = 'Twin32_t'
1809 if ctype == '':
1810 error(parser, lineno,
1811 'Unrecognized type description "%s" in user_dict')
1812 operand_type[ext] = ctype
1813
1814 self.operandTypeMap = operand_type
1815
1816 def buildOperandNameMap(self, user_dict, lineno):
1817 operand_name = {}
1818 for op_name, val in user_dict.iteritems():
1819 base_cls_name, dflt_ext, reg_spec, flags, sort_pri = val[:5]
1820 if len(val) > 5:
1821 read_code = val[5]
1822 else:
1823 read_code = None

--- 213 unchanged lines hidden ---
1790 def buildOperandNameMap(self, user_dict, lineno):
1791 operand_name = {}
1792 for op_name, val in user_dict.iteritems():
1793 base_cls_name, dflt_ext, reg_spec, flags, sort_pri = val[:5]
1794 if len(val) > 5:
1795 read_code = val[5]
1796 else:
1797 read_code = None

--- 213 unchanged lines hidden ---