4 ## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
27 ## Generate the register and immediate operands for each instruction
29 def calculate_regid_reg(tag
):
31 return chr(ord(x
) + 1)
33 ordered_implregs
= ["SP", "FP", "LR"]
39 for reg
in ordered_implregs
:
42 if ("A_IMPLICIT_WRITES_" + reg
) in hex_common
.attribdict
[tag
]:
46 mapdict
[srcdst_lett
] = reg
47 srcdst_lett
= letter_inc(srcdst_lett
)
50 mapdict
[src_lett
] = reg
51 src_lett
= letter_inc(src_lett
)
54 mapdict
[dst_lett
] = reg
55 dst_lett
= letter_inc(dst_lett
)
56 return retstr
, mapdict
59 def calculate_regid_letters(tag
):
60 retstr
, mapdict
= calculate_regid_reg(tag
)
64 def strip_reg_prefix(x
):
65 y
= x
.replace("UREG.", "")
66 y
= y
.replace("MREG.", "")
67 return y
.replace("GREG.", "")
71 hex_common
.read_semantics_file(sys
.argv
[1])
72 hex_common
.read_attribs_file(sys
.argv
[2])
73 tagregs
= hex_common
.get_tagregs(full
=True)
74 tagimms
= hex_common
.get_tagimms()
76 with
open(sys
.argv
[3], "w") as f
:
77 for tag
in hex_common
.tags
:
82 for regtype
, regid
, _
, numregs
in regs
:
83 if hex_common
.is_read(regid
):
84 if regid
[0] not in regids
:
86 rregs
.append(regtype
+ regid
+ numregs
)
87 if hex_common
.is_written(regid
):
88 wregs
.append(regtype
+ regid
+ numregs
)
89 if regid
[0] not in regids
:
91 for attrib
in hex_common
.attribdict
[tag
]:
92 if hex_common
.attribinfo
[attrib
]["rreg"]:
93 rregs
.append(strip_reg_prefix(attribinfo
[attrib
]["rreg"]))
94 if hex_common
.attribinfo
[attrib
]["wreg"]:
95 wregs
.append(strip_reg_prefix(attribinfo
[attrib
]["wreg"]))
96 regids
+= calculate_regid_letters(tag
)
98 f
'REGINFO({tag},"{regids}",\t/*RD:*/\t"{",".join(rregs)}",'
99 f
'\t/*WR:*/\t"{",".join(wregs)}")\n'
102 for tag
in hex_common
.tags
:
104 f
.write(f
"IMMINFO({tag}")
106 f
.write(""",'u',0,0,'U',0,0""")
107 for sign
, size
, shamt
in imms
:
112 f
.write(f
""",'{sign}',{size},{shamt}""")
118 f
.write(f
""",'{myu}',0,0""")
122 if __name__
== "__main__":