1# Use condition code registers for the ARM architecture.
2# Previously the integer register file was used for these registers.
3def upgrader(cpt):
4    if cpt.get('root','isa') == 'arm':
5        for sec in cpt.sections():
6            import re
7
8            re_cpu_match = re.match('^(.*sys.*\.cpu[^.]*)\.xc\.(.+)$', sec)
9            # Search for all the execution contexts
10            if not re_cpu_match:
11                continue
12
13            items = []
14            for (item,value) in cpt.items(sec):
15                items.append(item)
16            if 'ccRegs' not in items:
17                intRegs = cpt.get(sec, 'intRegs').split()
18
19                # Move those 5 integer registers to the ccRegs register file
20                ccRegs = intRegs[38:43]
21                del      intRegs[38:43]
22
23                ccRegs.append('0') # CCREG_ZERO
24
25                cpt.set(sec, 'intRegs', ' '.join(intRegs))
26                cpt.set(sec, 'ccRegs',  ' '.join(ccRegs))
27
28legacy_version = 13
29