Debian Codegraph @

rpython/jit/backend/arm/locations.py

raw symbols SCIP
1 from rpython.jit.metainterp.history import INT, FLOAT
2 from rpython.jit.backend.arm.arch import WORD, DOUBLE_WORD, JITFRAME_FIXED_SIZE
3
4 class AssemblerLocation(object):
5 _immutable_ = True
6 type = INT
7
8 def is_imm(self):
9 return False
10
11 def is_stack(self):
12 return False
13
14 def is_raw_sp(self):
15 return False
16
17 def is_core_reg(self):
18 return False
19
20 def is_vfp_reg(self):
21 return False
22
23 def is_imm_float(self):
24 return False
25
26 def is_float(self):
27 return False
28
29 def as_key(self):
30 raise NotImplementedError
31
32 def get_position(self):
33 raise NotImplementedError # only for stack
34
35 class RegisterLocation(AssemblerLocation):
36 _immutable_ = True
37 width = WORD
38
39 def __init__(self, value):
40 self.value = value
41
42 def __repr__(self):
43 return 'r%d' % self.value
44
45 def is_core_reg(self):
46 return True
47
48 def as_key(self): # 0 <= as_key <= 15
49 return self.value
50
51
52 class VFPRegisterLocation(RegisterLocation):
53 _immutable_ = True
54 type = FLOAT
55 width = 2 * WORD
56
57 def __repr__(self):
58 return 'vfp(d%d)' % self.value
59
60 def is_core_reg(self):
61 return False
62
63 def is_vfp_reg(self):
64 return True
65
66 def as_key(self): # 20 <= as_key <= 35
67 return self.value + 20
68
69 def is_float(self):
70 return True
71
72 class SVFPRegisterLocation(VFPRegisterLocation):
73 """Single Precission VFP Register"""
74 _immutable_ = True
75 width = WORD
76 type = 'S'
77
78 def __repr__(self):
79 return 'vfp(s%d)' % self.value
80
81 class ImmLocation(AssemblerLocation):
82 _immutable_ = True
83 width = WORD
84
85 def __init__(self, value):
86 self.value = value
87
88 def getint(self):
89 return self.value
90
91 def __repr__(self):
92 return "imm(%d)" % (self.value)
93
94 def is_imm(self):
95 return True
96
97
98 class ConstFloatLoc(AssemblerLocation):
99 """This class represents an imm float value which is stored in memory at
100 the address stored in the field value"""
101 _immutable_ = True
102 width = 2 * WORD
103 type = FLOAT
104
105 def __init__(self, value):
106 self.value = value
107
108 def getint(self):
109 return self.value
110
111 def __repr__(self):
112 return "imm_float(stored at %d)" % (self.value)
113
114 def is_imm_float(self):
115 return True
116
117 def as_key(self): # a real address + 1
118 return self.value | 1
119
120 def is_float(self):
121 return True
122
123 class StackLocation(AssemblerLocation):
124 _immutable_ = True
125
126 def __init__(self, position, fp_offset, type=INT):
127 if type == FLOAT:
128 self.width = DOUBLE_WORD
129 else:
130 self.width = WORD
131 self.position = position
132 self.value = fp_offset
133 self.type = type
134
135 def __repr__(self):
136 return 'FP(%s)+%d' % (self.type, self.position,)
137
138 def location_code(self):
139 return 'b'
140
141 def get_position(self):
142 return self.position
143
144 def assembler(self):
145 return repr(self)
146
147 def is_stack(self):
148 return True
149
150 def as_key(self): # an aligned word + 10000
151 return self.position + 10000
152
153 def is_float(self):
154 return self.type == FLOAT
155
156 class RawSPStackLocation(AssemblerLocation):
157 _immutable_ = True
158
159 def __init__(self, sp_offset, type=INT):
160 if type == FLOAT:
161 self.width = DOUBLE_WORD
162 else:
163 self.width = WORD
164 self.value = sp_offset
165 self.type = type
166
167 def __repr__(self):
168 return 'SP(%s)+%d' % (self.type, self.value,)
169
170 def is_raw_sp(self):
171 return True
172
173 def is_float(self):
174 return self.type == FLOAT
175
176 def as_key(self): # a word >= 1000, and < 1000 + size of SP frame
177 return self.value + 1000
178
179
180 def imm(i):
181 return ImmLocation(i)
182
183
184 def get_fp_offset(base_ofs, position):
185 return base_ofs + WORD * (position + JITFRAME_FIXED_SIZE)