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

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

Issue 975283002: Use Rotate*() functions instead of doing this manually. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 9 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
« no previous file with comments | « no previous file | src/arm/disasm-arm.cc » ('j') | src/base/bits.h » ('J')
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 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are 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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 // Low-level code emission routines depending on the addressing mode. 1004 // Low-level code emission routines depending on the addressing mode.
1005 // If this returns true then you have to use the rotate_imm and immed_8 1005 // If this returns true then you have to use the rotate_imm and immed_8
1006 // that it returns, because it may have already changed the instruction 1006 // that it returns, because it may have already changed the instruction
1007 // to match them! 1007 // to match them!
1008 static bool fits_shifter(uint32_t imm32, 1008 static bool fits_shifter(uint32_t imm32,
1009 uint32_t* rotate_imm, 1009 uint32_t* rotate_imm,
1010 uint32_t* immed_8, 1010 uint32_t* immed_8,
1011 Instr* instr) { 1011 Instr* instr) {
1012 // imm32 must be unsigned. 1012 // imm32 must be unsigned.
1013 for (int rot = 0; rot < 16; rot++) { 1013 for (int rot = 0; rot < 16; rot++) {
1014 uint32_t imm8 = 1014 uint32_t imm8 = base::bits::RotateLeft32(imm32, 2 * rot);
1015 rot == 0 ? imm32 : (imm32 << 2 * rot) | (imm32 >> (32 - 2 * rot));
1016 if ((imm8 <= 0xff)) { 1015 if ((imm8 <= 0xff)) {
1017 *rotate_imm = rot; 1016 *rotate_imm = rot;
1018 *immed_8 = imm8; 1017 *immed_8 = imm8;
1019 return true; 1018 return true;
1020 } 1019 }
1021 } 1020 }
1022 // If the opcode is one with a complementary version and the complementary 1021 // If the opcode is one with a complementary version and the complementary
1023 // immediate fits, change the opcode. 1022 // immediate fits, change the opcode.
1024 if (instr != NULL) { 1023 if (instr != NULL) {
1025 if ((*instr & kMovMvnMask) == kMovMvnPattern) { 1024 if ((*instr & kMovMvnMask) == kMovMvnPattern) {
(...skipping 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 3317
3319 Instr Assembler::PatchMovwImmediate(Instr instruction, uint32_t immediate) { 3318 Instr Assembler::PatchMovwImmediate(Instr instruction, uint32_t immediate) {
3320 instruction &= ~EncodeMovwImmediate(0xffff); 3319 instruction &= ~EncodeMovwImmediate(0xffff);
3321 return instruction | EncodeMovwImmediate(immediate); 3320 return instruction | EncodeMovwImmediate(immediate);
3322 } 3321 }
3323 3322
3324 3323
3325 int Assembler::DecodeShiftImm(Instr instr) { 3324 int Assembler::DecodeShiftImm(Instr instr) {
3326 int rotate = Instruction::RotateValue(instr) * 2; 3325 int rotate = Instruction::RotateValue(instr) * 2;
3327 int immed8 = Instruction::Immed8Value(instr); 3326 int immed8 = Instruction::Immed8Value(instr);
3328 return (immed8 >> rotate) | (immed8 << (32 - rotate)); 3327 return base::bits::RotateRight32(immed8, rotate);
3329 } 3328 }
3330 3329
3331 3330
3332 Instr Assembler::PatchShiftImm(Instr instr, int immed) { 3331 Instr Assembler::PatchShiftImm(Instr instr, int immed) {
3333 uint32_t rotate_imm = 0; 3332 uint32_t rotate_imm = 0;
3334 uint32_t immed_8 = 0; 3333 uint32_t immed_8 = 0;
3335 bool immed_fits = fits_shifter(immed, &rotate_imm, &immed_8, NULL); 3334 bool immed_fits = fits_shifter(immed, &rotate_imm, &immed_8, NULL);
3336 DCHECK(immed_fits); 3335 DCHECK(immed_fits);
3337 USE(immed_fits); 3336 USE(immed_fits);
3338 return (instr & ~kOff12Mask) | (rotate_imm << 8) | immed_8; 3337 return (instr & ~kOff12Mask) | (rotate_imm << 8) | immed_8;
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 assm->instr_at_put( 4007 assm->instr_at_put(
4009 rinfo.pc(), Assembler::SetLdrRegisterImmediateOffset(instr, offset)); 4008 rinfo.pc(), Assembler::SetLdrRegisterImmediateOffset(instr, offset));
4010 } 4009 }
4011 } 4010 }
4012 } 4011 }
4013 4012
4014 4013
4015 } } // namespace v8::internal 4014 } } // namespace v8::internal
4016 4015
4017 #endif // V8_TARGET_ARCH_ARM 4016 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/disasm-arm.cc » ('j') | src/base/bits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698