isa_parser.py (2686:f0d591379ac3) isa_parser.py (3274:75d7e0bc4c1b)
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

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

1631# Assume all instruction flags are of the form 'IsFoo'
1632instFlagRE = re.compile(r'Is.*')
1633
1634# OpClass constants end in 'Op' except No_OpClass
1635opClassRE = re.compile(r'.*Op|No_OpClass')
1636
1637class InstObjParams:
1638 def __init__(self, mnem, class_name, base_class = '',
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

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

1631# Assume all instruction flags are of the form 'IsFoo'
1632instFlagRE = re.compile(r'Is.*')
1633
1634# OpClass constants end in 'Op' except No_OpClass
1635opClassRE = re.compile(r'.*Op|No_OpClass')
1636
1637class InstObjParams:
1638 def __init__(self, mnem, class_name, base_class = '',
1639 code = None, opt_args = [], *extras):
1639 code = None, opt_args = [], extras = {}):
1640 self.mnemonic = mnem
1641 self.class_name = class_name
1642 self.base_class = base_class
1643 if code:
1644 #If the user already made a CodeBlock, pick the parts from it
1645 if isinstance(code, CodeBlock):
1646 origCode = code.orig_code
1647 codeBlock = code
1648 else:
1649 origCode = code
1650 codeBlock = CodeBlock(code)
1640 self.mnemonic = mnem
1641 self.class_name = class_name
1642 self.base_class = base_class
1643 if code:
1644 #If the user already made a CodeBlock, pick the parts from it
1645 if isinstance(code, CodeBlock):
1646 origCode = code.orig_code
1647 codeBlock = code
1648 else:
1649 origCode = code
1650 codeBlock = CodeBlock(code)
1651 compositeCode = '\n'.join([origCode] +
1652 [pair[1] for pair in extras])
1651 stringExtras = {}
1652 otherExtras = {}
1653 for (k, v) in extras.items():
1654 if type(v) == str:
1655 stringExtras[k] = v
1656 else:
1657 otherExtras[k] = v
1658 compositeCode = "\n".join([origCode] + stringExtras.values())
1659 # compositeCode = '\n'.join([origCode] +
1660 # [pair[1] for pair in extras])
1653 compositeBlock = CodeBlock(compositeCode)
1654 for code_attr in compositeBlock.__dict__.keys():
1655 setattr(self, code_attr, getattr(compositeBlock, code_attr))
1661 compositeBlock = CodeBlock(compositeCode)
1662 for code_attr in compositeBlock.__dict__.keys():
1663 setattr(self, code_attr, getattr(compositeBlock, code_attr))
1656 for (key, snippet) in extras:
1664 for (key, snippet) in stringExtras.items():
1657 setattr(self, key, CodeBlock(snippet).code)
1665 setattr(self, key, CodeBlock(snippet).code)
1666 for (key, item) in otherExtras.items():
1667 setattr(self, key, item)
1658 self.code = codeBlock.code
1659 self.orig_code = origCode
1660 else:
1661 self.constructor = ''
1662 self.flags = []
1663 # Optional arguments are assumed to be either StaticInst flags
1664 # or an OpClass value. To avoid having to import a complete
1665 # list of these values to match against, we do it ad-hoc

--- 153 unchanged lines hidden ---
1668 self.code = codeBlock.code
1669 self.orig_code = origCode
1670 else:
1671 self.constructor = ''
1672 self.flags = []
1673 # Optional arguments are assumed to be either StaticInst flags
1674 # or an OpClass value. To avoid having to import a complete
1675 # list of these values to match against, we do it ad-hoc

--- 153 unchanged lines hidden ---