isa_parser.py (12204:2ba80db6075c) | isa_parser.py (12222:6db0fc7407a5) |
---|---|
1# Copyright (c) 2014, 2016 ARM Limited 2# All rights reserved 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 1559 unchanged lines hidden (view full) --- 1568 1569 return f 1570 1571 # Weave together the parts of the different output sections by 1572 # #include'ing them into some very short top-level .cc/.hh files. 1573 # These small files make it much clearer how this tool works, since 1574 # you directly see the chunks emitted as files that are #include'd. 1575 def write_top_level_files(self): | 1# Copyright (c) 2014, 2016 ARM Limited 2# All rights reserved 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 1559 unchanged lines hidden (view full) --- 1568 1569 return f 1570 1571 # Weave together the parts of the different output sections by 1572 # #include'ing them into some very short top-level .cc/.hh files. 1573 # These small files make it much clearer how this tool works, since 1574 # you directly see the chunks emitted as files that are #include'd. 1575 def write_top_level_files(self): |
1576 dep = self.open('inc.d', bare=True) 1577 | |
1578 # decoder header - everything depends on this 1579 file = 'decoder.hh' 1580 with self.open(file) as f: | 1576 # decoder header - everything depends on this 1577 file = 'decoder.hh' 1578 with self.open(file) as f: |
1581 inc = [] 1582 | |
1583 fn = 'decoder-g.hh.inc' 1584 assert(fn in self.files) 1585 f.write('#include "%s"\n' % fn) | 1579 fn = 'decoder-g.hh.inc' 1580 assert(fn in self.files) 1581 f.write('#include "%s"\n' % fn) |
1586 inc.append(fn) | |
1587 1588 fn = 'decoder-ns.hh.inc' 1589 assert(fn in self.files) 1590 f.write('namespace %s {\n#include "%s"\n}\n' 1591 % (self.namespace, fn)) | 1582 1583 fn = 'decoder-ns.hh.inc' 1584 assert(fn in self.files) 1585 f.write('namespace %s {\n#include "%s"\n}\n' 1586 % (self.namespace, fn)) |
1592 inc.append(fn) | |
1593 | 1587 |
1594 print >>dep, file+':', ' '.join(inc) 1595 | |
1596 # decoder method - cannot be split 1597 file = 'decoder.cc' 1598 with self.open(file) as f: | 1588 # decoder method - cannot be split 1589 file = 'decoder.cc' 1590 with self.open(file) as f: |
1599 inc = [] 1600 | |
1601 fn = 'decoder-g.cc.inc' 1602 assert(fn in self.files) 1603 f.write('#include "%s"\n' % fn) | 1591 fn = 'decoder-g.cc.inc' 1592 assert(fn in self.files) 1593 f.write('#include "%s"\n' % fn) |
1604 inc.append(fn) | |
1605 1606 fn = 'decoder.hh' 1607 f.write('#include "%s"\n' % fn) | 1594 1595 fn = 'decoder.hh' 1596 f.write('#include "%s"\n' % fn) |
1608 inc.append(fn) | |
1609 1610 fn = 'decode-method.cc.inc' 1611 # is guaranteed to have been written for parse to complete 1612 f.write('#include "%s"\n' % fn) | 1597 1598 fn = 'decode-method.cc.inc' 1599 # is guaranteed to have been written for parse to complete 1600 f.write('#include "%s"\n' % fn) |
1613 inc.append(fn) | |
1614 | 1601 |
1615 print >>dep, file+':', ' '.join(inc) 1616 | |
1617 extn = re.compile('(\.[^\.]+)$') 1618 1619 # instruction constructors 1620 splits = self.splits[self.get_file('decoder')] 1621 file_ = 'inst-constrs.cc' 1622 for i in range(1, splits+1): 1623 if splits > 1: 1624 file = extn.sub(r'-%d\1' % i, file_) 1625 else: 1626 file = file_ 1627 with self.open(file) as f: | 1602 extn = re.compile('(\.[^\.]+)$') 1603 1604 # instruction constructors 1605 splits = self.splits[self.get_file('decoder')] 1606 file_ = 'inst-constrs.cc' 1607 for i in range(1, splits+1): 1608 if splits > 1: 1609 file = extn.sub(r'-%d\1' % i, file_) 1610 else: 1611 file = file_ 1612 with self.open(file) as f: |
1628 inc = [] 1629 | |
1630 fn = 'decoder-g.cc.inc' 1631 assert(fn in self.files) 1632 f.write('#include "%s"\n' % fn) | 1613 fn = 'decoder-g.cc.inc' 1614 assert(fn in self.files) 1615 f.write('#include "%s"\n' % fn) |
1633 inc.append(fn) | |
1634 1635 fn = 'decoder.hh' 1636 f.write('#include "%s"\n' % fn) | 1616 1617 fn = 'decoder.hh' 1618 f.write('#include "%s"\n' % fn) |
1637 inc.append(fn) | |
1638 1639 fn = 'decoder-ns.cc.inc' 1640 assert(fn in self.files) 1641 print >>f, 'namespace %s {' % self.namespace 1642 if splits > 1: 1643 print >>f, '#define __SPLIT %u' % i 1644 print >>f, '#include "%s"' % fn 1645 print >>f, '}' | 1619 1620 fn = 'decoder-ns.cc.inc' 1621 assert(fn in self.files) 1622 print >>f, 'namespace %s {' % self.namespace 1623 if splits > 1: 1624 print >>f, '#define __SPLIT %u' % i 1625 print >>f, '#include "%s"' % fn 1626 print >>f, '}' |
1646 inc.append(fn) | |
1647 | 1627 |
1648 print >>dep, file+':', ' '.join(inc) 1649 | |
1650 # instruction execution per-CPU model 1651 splits = self.splits[self.get_file('exec')] 1652 for cpu in self.cpuModels: 1653 for i in range(1, splits+1): 1654 if splits > 1: 1655 file = extn.sub(r'_%d\1' % i, cpu.filename) 1656 else: 1657 file = cpu.filename 1658 with self.open(file) as f: | 1628 # instruction execution per-CPU model 1629 splits = self.splits[self.get_file('exec')] 1630 for cpu in self.cpuModels: 1631 for i in range(1, splits+1): 1632 if splits > 1: 1633 file = extn.sub(r'_%d\1' % i, cpu.filename) 1634 else: 1635 file = cpu.filename 1636 with self.open(file) as f: |
1659 inc = [] 1660 | |
1661 fn = 'exec-g.cc.inc' 1662 assert(fn in self.files) 1663 f.write('#include "%s"\n' % fn) | 1637 fn = 'exec-g.cc.inc' 1638 assert(fn in self.files) 1639 f.write('#include "%s"\n' % fn) |
1664 inc.append(fn) | |
1665 1666 f.write(cpu.includes+"\n") 1667 1668 fn = 'decoder.hh' 1669 f.write('#include "%s"\n' % fn) | 1640 1641 f.write(cpu.includes+"\n") 1642 1643 fn = 'decoder.hh' 1644 f.write('#include "%s"\n' % fn) |
1670 inc.append(fn) | |
1671 1672 fn = 'exec-ns.cc.inc' 1673 assert(fn in self.files) 1674 print >>f, 'namespace %s {' % self.namespace 1675 print >>f, '#define CPU_EXEC_CONTEXT %s' \ 1676 % cpu.strings['CPU_exec_context'] 1677 if splits > 1: 1678 print >>f, '#define __SPLIT %u' % i 1679 print >>f, '#include "%s"' % fn 1680 print >>f, '}' | 1645 1646 fn = 'exec-ns.cc.inc' 1647 assert(fn in self.files) 1648 print >>f, 'namespace %s {' % self.namespace 1649 print >>f, '#define CPU_EXEC_CONTEXT %s' \ 1650 % cpu.strings['CPU_exec_context'] 1651 if splits > 1: 1652 print >>f, '#define __SPLIT %u' % i 1653 print >>f, '#include "%s"' % fn 1654 print >>f, '}' |
1681 inc.append(fn) | |
1682 | 1655 |
1683 inc.append("decoder.hh") 1684 print >>dep, file+':', ' '.join(inc) 1685 | |
1686 # max_inst_regs.hh 1687 self.update('max_inst_regs.hh', 1688 '''namespace %(namespace)s { 1689 const int MaxInstSrcRegs = %(maxInstSrcRegs)d; 1690 const int MaxInstDestRegs = %(maxInstDestRegs)d; 1691 const int MaxMiscDestRegs = %(maxMiscDestRegs)d;\n}\n''' % self) | 1656 # max_inst_regs.hh 1657 self.update('max_inst_regs.hh', 1658 '''namespace %(namespace)s { 1659 const int MaxInstSrcRegs = %(maxInstSrcRegs)d; 1660 const int MaxInstDestRegs = %(maxInstDestRegs)d; 1661 const int MaxMiscDestRegs = %(maxMiscDestRegs)d;\n}\n''' % self) |
1692 print >>dep, 'max_inst_regs.hh:' | |
1693 | 1662 |
1694 dep.close() 1695 1696 | |
1697 scaremonger_template ='''// DO NOT EDIT 1698// This file was automatically generated from an ISA description: 1699// %(filename)s 1700 1701'''; 1702 1703 ##################################################################### 1704 # --- 1012 unchanged lines hidden --- | 1663 scaremonger_template ='''// DO NOT EDIT 1664// This file was automatically generated from an ISA description: 1665// %(filename)s 1666 1667'''; 1668 1669 ##################################################################### 1670 # --- 1012 unchanged lines hidden --- |