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

Side by Side Diff: src/arm/macro-assembler-arm.cc

Issue 2826001: ARM: Be more smart about switching instructions when immediates... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 6 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 211
212 void MacroAssembler::Move(Register dst, Register src) { 212 void MacroAssembler::Move(Register dst, Register src) {
213 if (!dst.is(src)) { 213 if (!dst.is(src)) {
214 mov(dst, src); 214 mov(dst, src);
215 } 215 }
216 } 216 }
217 217
218 218
219 void MacroAssembler::And(Register dst, Register src1, const Operand& src2,
220 Condition cond) {
221 if (!CpuFeatures::IsSupported(ARMv7) || src2.is_single_instruction()) {
222 and_(dst, src1, src2, LeaveCC, cond);
223 return;
224 }
225 int32_t immediate = src2.immediate();
226 if (immediate == 0) {
227 mov(dst, Operand(0), LeaveCC, cond);
228 return;
229 }
230 if (IsPowerOf2(immediate + 1) && ((immediate & 1) != 0)) {
231 ubfx(dst, src1, 0, WhichPowerOf2(immediate + 1), cond);
232 return;
233 }
234 and_(dst, src1, src2, LeaveCC, cond);
235 }
236
237
238 void MacroAssembler::Ubfx(Register dst, Register src1, int lsb, int width,
239 Condition cond) {
240 ASSERT(lsb < 32);
241 if (!CpuFeatures::IsSupported(ARMv7)) {
242 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1);
243 and_(dst, src1, Operand(mask), LeaveCC, cond);
244 if (lsb != 0) {
245 mov(dst, Operand(dst, LSR, lsb), LeaveCC, cond);
246 }
247 } else {
248 ubfx(dst, src1, lsb, width, cond);
249 }
250 }
251
252
253 void MacroAssembler::Sbfx(Register dst, Register src1, int lsb, int width,
254 Condition cond) {
255 ASSERT(lsb < 32);
256 if (!CpuFeatures::IsSupported(ARMv7)) {
257 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1);
258 and_(dst, src1, Operand(mask), LeaveCC, cond);
259 int shift_up = 32 - lsb - width;
260 int shift_down = lsb + shift_up;
261 if (shift_up != 0) {
262 mov(dst, Operand(dst, LSL, shift_up), LeaveCC, cond);
263 }
264 if (shift_down != 0) {
265 mov(dst, Operand(dst, ASR, shift_down), LeaveCC, cond);
266 }
267 } else {
268 sbfx(dst, src1, lsb, width, cond);
269 }
270 }
271
272
219 void MacroAssembler::SmiJumpTable(Register index, Vector<Label*> targets) { 273 void MacroAssembler::SmiJumpTable(Register index, Vector<Label*> targets) {
220 // Empty the const pool. 274 // Empty the const pool.
221 CheckConstPool(true, true); 275 CheckConstPool(true, true);
222 add(pc, pc, Operand(index, 276 add(pc, pc, Operand(index,
223 LSL, 277 LSL,
224 assembler::arm::Instr::kInstrSizeLog2 - kSmiTagSize)); 278 assembler::arm::Instr::kInstrSizeLog2 - kSmiTagSize));
225 BlockConstPoolBefore(pc_offset() + (targets.length() + 1) * kInstrSize); 279 BlockConstPoolBefore(pc_offset() + (targets.length() + 1) * kInstrSize);
226 nop(); // Jump table alignment. 280 nop(); // Jump table alignment.
227 for (int i = 0; i < targets.length(); i++) { 281 for (int i = 0; i < targets.length(); i++) {
228 b(targets[i]); 282 b(targets[i]);
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 1798
1745 void CodePatcher::Emit(Address addr) { 1799 void CodePatcher::Emit(Address addr) {
1746 masm()->emit(reinterpret_cast<Instr>(addr)); 1800 masm()->emit(reinterpret_cast<Instr>(addr));
1747 } 1801 }
1748 #endif // ENABLE_DEBUGGER_SUPPORT 1802 #endif // ENABLE_DEBUGGER_SUPPORT
1749 1803
1750 1804
1751 } } // namespace v8::internal 1805 } } // namespace v8::internal
1752 1806
1753 #endif // V8_TARGET_ARCH_ARM 1807 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698