Debian Codegraph @

rpython/jit/backend/riscv/locations.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 from rpython.jit.backend.riscv.arch import FLEN, JITFRAME_FIXED_SIZE, XLEN
4 from rpython.jit.metainterp.history import FLOAT, INT
5 from rpython.rlib.rarithmetic import r_int32
6
7
8 class AssemblerLocation(object):
9 _immutable_ = True
10 type = INT
11
12 def is_imm(self):
13 return False
14
15 def is_stack(self):
16 return False
17
18 def is_raw_sp(self):
19 return False
20
21 def is_core_reg(self):
22 return False
23
24 def is_fp_reg(self):
25 return False
26
27 def is_imm_float(self):
28 return False
29
30 def is_float(self):
31 return False
32
33 def as_key(self):
34 raise NotImplementedError
35
36 def get_position(self):
37 raise NotImplementedError
38
39
40 class RegisterLocation(AssemblerLocation):
41 _immutable_ = True
42 width = XLEN
43
44 def __init__(self, value):
45 self.value = value
46
47 def __repr__(self):
48 return 'x%d' % self.value
49
50 def __int__(self):
51 return self.value
52
53 def is_core_reg(self):
54 return True
55
56 def as_key(self):
57 return self.value
58
59
60 class ZeroRegisterLocation(AssemblerLocation):
61 _immutable_ = True
62 width = XLEN
63
64 def __init__(self):
65 self.value = 0
66
67 def __repr__(self):
68 return "zero"
69
70 def __int__(self):
71 return self.value
72
73 def is_core_reg(self):
74 return True
75
76 def as_key(self):
77 return self.value
78
79
80 class FloatRegisterLocation(RegisterLocation):
81 _immutable_ = True
82 type = FLOAT
83 width = FLEN
84
85 def __repr__(self):
86 return 'f%d' % self.value
87
88 def __int__(self):
89 return self.value
90
91 def is_core_reg(self):
92 return False
93
94 def is_fp_reg(self):
95 return True
96
97 def as_key(self):
98 return self.value + 40
99
100 def is_float(self):
101 return True
102
103
104 class ImmLocation(AssemblerLocation):
105 _immutable_ = True
106
107 def __init__(self, value):
108 assert not isinstance(value, r_int32)
109 self.value = value
110
111 def __repr__(self):
112 return "imm(%d)" % (self.value)
113
114 def is_imm(self):
115 return True
116
117
118 class StackLocation(AssemblerLocation):
119 _immutable_ = True
120
121 def __init__(self, position, fp_offset, type=INT):
122 self.position = position
123 self.value = fp_offset
124 self.type = type
125 if type == FLOAT:
126 self.width = FLEN
127 else:
128 self.width = XLEN
129
130 def __repr__(self):
131 return 'FP(%s)+%d' % (self.type, self.position)
132
133 def get_position(self):
134 return self.position
135
136 def is_stack(self):
137 return True
138
139 def as_key(self):
140 return self.position + 10000
141
142 def is_float(self):
143 return self.type == FLOAT
144
145
146 def get_fp_offset(base_ofs, position):
147 return base_ofs + XLEN * (position + JITFRAME_FIXED_SIZE)
148
149
150 class FloatImmLocation(AssemblerLocation):
151 """This class represents an imm float value (bitcasted to integer)"""
152 _immutable_ = True
153 type = FLOAT
154
155 def __init__(self, value):
156 self.value = value
157
158 def __repr__(self):
159 return "imm_float(bits=%x)" % (self.value)
160
161 def is_imm_float(self):
162 return True
163
164 def as_key(self):
165 return self.value
166
167 def is_float(self):
168 return True