Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: src/ia32/assembler-ia32.h

Issue 284503002: Simplify DoubleRegister for the ia32 port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return (reg.code() >= 6) ? reg.code() - 2 : reg.code(); 134 return (reg.code() >= 6) ? reg.code() - 2 : reg.code();
135 } 135 }
136 136
137 137
138 inline Register Register::FromAllocationIndex(int index) { 138 inline Register Register::FromAllocationIndex(int index) {
139 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); 139 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters);
140 return (index >= 4) ? from_code(index + 2) : from_code(index); 140 return (index >= 4) ? from_code(index + 2) : from_code(index);
141 } 141 }
142 142
143 143
144 struct DoubleRegister { 144 struct XMMRegister {
145 static const int kMaxNumAllocatableRegisters = 7;
145 static const int kMaxNumRegisters = 8; 146 static const int kMaxNumRegisters = 8;
146 static const int kMaxNumAllocatableRegisters = 7; 147 static int NumAllocatableRegisters() {
147 static int NumAllocatableRegisters(); 148 return kMaxNumAllocatableRegisters;
148 static int NumRegisters(); 149 }
149 static const char* AllocationIndexToString(int index);
150 150
151 static int ToAllocationIndex(DoubleRegister reg) { 151 static int ToAllocationIndex(XMMRegister reg) {
152 ASSERT(reg.code() != 0); 152 ASSERT(reg.code() != 0);
153 return reg.code() - 1; 153 return reg.code() - 1;
154 } 154 }
155 155
156 static DoubleRegister FromAllocationIndex(int index) { 156 static XMMRegister FromAllocationIndex(int index) {
157 ASSERT(index >= 0 && index < NumAllocatableRegisters()); 157 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters);
158 return from_code(index + 1); 158 return from_code(index + 1);
159 } 159 }
160 160
161 static DoubleRegister from_code(int code) { 161 static XMMRegister from_code(int code) {
162 DoubleRegister result = { code }; 162 XMMRegister result = { code };
163 return result; 163 return result;
164 } 164 }
165 165
166 bool is_valid() const { 166 bool is_valid() const {
167 return 0 <= code_ && code_ < NumRegisters(); 167 return 0 <= code_ && code_ < kMaxNumRegisters;
168 } 168 }
169
169 int code() const { 170 int code() const {
170 ASSERT(is_valid()); 171 ASSERT(is_valid());
171 return code_; 172 return code_;
172 } 173 }
173 174
174 int code_;
175 };
176
177
178 const DoubleRegister double_register_0 = { 0 };
179 const DoubleRegister double_register_1 = { 1 };
180 const DoubleRegister double_register_2 = { 2 };
181 const DoubleRegister double_register_3 = { 3 };
182 const DoubleRegister double_register_4 = { 4 };
183 const DoubleRegister double_register_5 = { 5 };
184 const DoubleRegister double_register_6 = { 6 };
185 const DoubleRegister double_register_7 = { 7 };
186 const DoubleRegister no_double_reg = { -1 };
187
188
189 struct XMMRegister : DoubleRegister {
190 static const int kNumAllocatableRegisters = 7;
191 static const int kNumRegisters = 8;
192
193 static XMMRegister from_code(int code) {
194 STATIC_ASSERT(sizeof(XMMRegister) == sizeof(DoubleRegister));
195 XMMRegister result;
196 result.code_ = code;
197 return result;
198 }
199
200 bool is(XMMRegister reg) const { return code_ == reg.code_; } 175 bool is(XMMRegister reg) const { return code_ == reg.code_; }
201 176
202 static XMMRegister FromAllocationIndex(int index) {
203 ASSERT(index >= 0 && index < NumAllocatableRegisters());
204 return from_code(index + 1);
205 }
206
207 static const char* AllocationIndexToString(int index) { 177 static const char* AllocationIndexToString(int index) {
208 ASSERT(index >= 0 && index < kNumAllocatableRegisters); 178 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters);
209 const char* const names[] = { 179 const char* const names[] = {
210 "xmm1", 180 "xmm1",
211 "xmm2", 181 "xmm2",
212 "xmm3", 182 "xmm3",
213 "xmm4", 183 "xmm4",
214 "xmm5", 184 "xmm5",
215 "xmm6", 185 "xmm6",
216 "xmm7" 186 "xmm7"
217 }; 187 };
218 return names[index]; 188 return names[index];
219 } 189 }
190
191 int code_;
220 }; 192 };
221 193
222 194
223 #define xmm0 (static_cast<const XMMRegister&>(double_register_0)) 195 typedef XMMRegister DoubleRegister;
224 #define xmm1 (static_cast<const XMMRegister&>(double_register_1)) 196
225 #define xmm2 (static_cast<const XMMRegister&>(double_register_2)) 197
226 #define xmm3 (static_cast<const XMMRegister&>(double_register_3)) 198 const XMMRegister xmm0 = { 0 };
227 #define xmm4 (static_cast<const XMMRegister&>(double_register_4)) 199 const XMMRegister xmm1 = { 1 };
228 #define xmm5 (static_cast<const XMMRegister&>(double_register_5)) 200 const XMMRegister xmm2 = { 2 };
229 #define xmm6 (static_cast<const XMMRegister&>(double_register_6)) 201 const XMMRegister xmm3 = { 3 };
230 #define xmm7 (static_cast<const XMMRegister&>(double_register_7)) 202 const XMMRegister xmm4 = { 4 };
231 #define no_xmm_reg (static_cast<const XMMRegister&>(no_double_reg)) 203 const XMMRegister xmm5 = { 5 };
204 const XMMRegister xmm6 = { 6 };
205 const XMMRegister xmm7 = { 7 };
206 const XMMRegister no_xmm_reg = { -1 };
232 207
233 208
234 enum Condition { 209 enum Condition {
235 // any value < 0 is considered no_condition 210 // any value < 0 is considered no_condition
236 no_condition = -1, 211 no_condition = -1,
237 212
238 overflow = 0, 213 overflow = 0,
239 no_overflow = 1, 214 no_overflow = 1,
240 below = 2, 215 below = 2,
241 above_equal = 3, 216 above_equal = 3,
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 private: 1222 private:
1248 Assembler* assembler_; 1223 Assembler* assembler_;
1249 #ifdef DEBUG 1224 #ifdef DEBUG
1250 int space_before_; 1225 int space_before_;
1251 #endif 1226 #endif
1252 }; 1227 };
1253 1228
1254 } } // namespace v8::internal 1229 } } // namespace v8::internal
1255 1230
1256 #endif // V8_IA32_ASSEMBLER_IA32_H_ 1231 #endif // V8_IA32_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698