Debian Codegraph @

rpython/jit/backend/ppc/locations.py

raw symbols SCIP
1 from rpython.jit.metainterp.history import INT, FLOAT, VECTOR
2 import sys
3
4 # cannot import from arch.py, currently we have a circular import
5 if sys.maxint == (2**31 - 1):
6 WORD = 4
7 FWORD = 8
8 else:
9 WORD = 8
10 FWORD = 8
11 DWORD = 2 * WORD
12
13
14 class AssemblerLocation(object):
15 _immutable_ = True
16 type = INT
17
18 def is_imm(self):
19 return False
20
21 def is_stack(self):
22 return False
23
24 def is_reg(self):
25 return False
26
27 def is_core_reg(self): # for llsupport/assembler.py
28 return self.is_reg()
29
30 def is_fp_reg(self):
31 return False
32
33 def is_vector_reg(self):
34 return False
35
36 def is_imm_float(self):
37 return False
38
39 def is_float(self):
40 return False
41
42 def as_key(self):
43 raise NotImplementedError
44
45 class RegisterLocation(AssemblerLocation):
46 _immutable_ = True
47 width = WORD
48
49 def __init__(self, value):
50 self.value = value
51
52 def __repr__(self):
53 return 'r%d' % self.value
54
55 def is_reg(self):
56 return True
57
58 def as_key(self):
59 return self.value
60
61 class FPRegisterLocation(RegisterLocation):
62 _immutable_ = True
63 type = FLOAT
64 width = FWORD
65
66 def __repr__(self):
67 return 'fp%d' % self.value
68
69 def is_reg(self):
70 return False
71
72 def is_fp_reg(self):
73 return True
74
75 def is_float(self):
76 return True
77
78 def as_key(self):
79 return self.value + 100
80
81 class VectorRegisterLocation(AssemblerLocation):
82 _immutable_ = True
83 width = WORD * 2
84 type = VECTOR
85
86 def __init__(self, value):
87 self.value = value
88
89 def __repr__(self):
90 return 'vr%d' % self.value
91
92 def is_reg(self):
93 return True
94
95 def as_key(self):
96 return self.value + 132
97
98 def is_vector_reg(self):
99 return True
100
101
102 class ImmLocation(AssemblerLocation):
103 _immutable_ = True
104 width = WORD
105
106
107 def __init__(self, value):
108 self.value = value
109
110 def getint(self):
111 return self.value
112
113 def __repr__(self):
114 return "imm(%d)" % (self.value)
115
116 def is_imm(self):
117 return True
118
119 class ConstFloatLoc(AssemblerLocation):
120 """This class represents an imm float value which is stored in memory at
121 the address stored in the field value"""
122 _immutable_ = True
123 width = FWORD
124 type = FLOAT
125
126 def __init__(self, value):
127 self.value = value
128
129 def getint(self):
130 return self.value
131
132 def __repr__(self):
133 return "imm_float(stored at %d)" % (self.value)
134
135 def is_imm_float(self):
136 return True
137
138 def as_key(self):
139 return self.value
140
141 class StackLocation(AssemblerLocation):
142 _immutable_ = True
143
144 def __init__(self, position, fp_offset, type=INT):
145 if type == FLOAT:
146 self.width = FWORD
147 else:
148 self.width = WORD
149 self.position = position
150 self.value = fp_offset
151 self.type = type
152
153 def __repr__(self):
154 return 'FP(%s)+%d' % (self.type, self.value)
155
156 def get_position(self):
157 return self.position
158
159 def assembler(self):
160 return repr(self)
161
162 def is_stack(self):
163 return True
164
165 def as_key(self):
166 return -self.position + 10000
167
168 def imm(val):
169 return ImmLocation(val)
170
171 def get_fp_offset(base_ofs, position):
172 from rpython.jit.backend.ppc.register import JITFRAME_FIXED_SIZE
173 # Argument is a frame position (0, 1, 2...).
174 # Returns the n'th word beyond the fixed frame size.
175 return base_ofs + WORD * (position + JITFRAME_FIXED_SIZE)