-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstr_helpers.py
executable file
·62 lines (49 loc) · 1.18 KB
/
instr_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python3
def isreg(d):
if type(d) == dict:
return 'register' in d.keys()
return False
def is_half_width(r):
if 'half_width' in r.keys():
if r['half_width']:
return 'w'
return ''
def safe_pullregs(operands):
rs = []
for o in operands:
if 'register' in o.keys():
rs.append(o['register'])
return rs
def pulltypes(operands):
o_types = []
for o in operands:
if 'register' in o.keys():
o_types.append('register')
elif 'immediate' in o.keys():
o_types.append('immediate')
elif 'label' in o.keys():
o_types.append('label')
else:
o_types.append(None)
return o_types
fpfmtmap = {
16: 'h',
32: 's',
64: 'd',
128: 'q'
}
float_load_fmt_map = {
32: 'w',
64: 'd',
128: 'q'
}
def get_fl_flag(reg):
"""Return the appropriate RISC-V char suffix for the width
"""
if type(reg) == dict:
if 'width' in reg.keys():
return fpfmtmap[reg['width']]
def get_fl_ld_flag(reg):
if type(reg) == dict:
if 'width' in reg.keys():
return float_load_fmt_map[reg['width']]