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

Side by Side Diff: src/IceAssemblerX86BaseImpl.h

Issue 1339603006: Subzero: Generate correct code for shifts by a large immediate. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Change comment Created 5 years, 3 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 | tests_lit/llvm2ice_tests/shift.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceAssemblerX86BaseImpl.h - base x86 assembler -*- C++ -*-=// 1 //===- subzero/src/IceAssemblerX86BaseImpl.h - base x86 assembler -*- C++ -*-=//
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 3353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 intptr_t position = Buffer.size(); 3364 intptr_t position = Buffer.size();
3365 emitUint8(0); 3365 emitUint8(0);
3366 if (!getPreliminary()) 3366 if (!getPreliminary())
3367 label->nearLinkTo(position); 3367 label->nearLinkTo(position);
3368 } 3368 }
3369 3369
3370 template <class Machine> 3370 template <class Machine>
3371 void AssemblerX86Base<Machine>::emitGenericShift( 3371 void AssemblerX86Base<Machine>::emitGenericShift(
3372 int rm, Type Ty, typename Traits::GPRRegister reg, const Immediate &imm) { 3372 int rm, Type Ty, typename Traits::GPRRegister reg, const Immediate &imm) {
3373 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 3373 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
3374 assert(imm.is_int8()); 3374 // We don't assert that imm fits into 8 bits; instead, it gets masked below.
3375 // Note that we don't mask it further (e.g. to 5 bits) because we want the
3376 // same processor behavior regardless of whether it's an immediate (masked to
3377 // 8 bits) or in register cl (essentially ecx masked to 8 bits).
3375 if (Ty == IceType_i16) 3378 if (Ty == IceType_i16)
3376 emitOperandSizeOverride(); 3379 emitOperandSizeOverride();
3377 emitRexB(Ty, reg); 3380 emitRexB(Ty, reg);
3378 if (imm.value() == 1) { 3381 if (imm.value() == 1) {
3379 emitUint8(isByteSizedArithType(Ty) ? 0xD0 : 0xD1); 3382 emitUint8(isByteSizedArithType(Ty) ? 0xD0 : 0xD1);
3380 emitOperand(rm, typename Traits::Operand(reg)); 3383 emitOperand(rm, typename Traits::Operand(reg));
3381 } else { 3384 } else {
3382 emitUint8(isByteSizedArithType(Ty) ? 0xC0 : 0xC1); 3385 emitUint8(isByteSizedArithType(Ty) ? 0xC0 : 0xC1);
3383 emitOperand(rm, typename Traits::Operand(reg)); 3386 emitOperand(rm, typename Traits::Operand(reg));
3384 emitUint8(imm.value() & 0xFF); 3387 emitUint8(imm.value() & 0xFF);
3385 } 3388 }
3386 } 3389 }
3387 3390
3388 template <class Machine> 3391 template <class Machine>
3389 void AssemblerX86Base<Machine>::emitGenericShift( 3392 void AssemblerX86Base<Machine>::emitGenericShift(
3390 int rm, Type Ty, const typename Traits::Operand &operand, 3393 int rm, Type Ty, const typename Traits::Operand &operand,
3391 typename Traits::GPRRegister shifter) { 3394 typename Traits::GPRRegister shifter) {
3392 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 3395 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
3393 assert(shifter == Traits::Encoded_Reg_Counter); 3396 assert(shifter == Traits::Encoded_Reg_Counter);
3394 (void)shifter; 3397 (void)shifter;
3395 if (Ty == IceType_i16) 3398 if (Ty == IceType_i16)
3396 emitOperandSizeOverride(); 3399 emitOperandSizeOverride();
3397 emitRexB(Ty, operand.rm()); 3400 emitRexB(Ty, operand.rm());
3398 emitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); 3401 emitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3);
3399 emitOperand(rm, operand); 3402 emitOperand(rm, operand);
3400 } 3403 }
3401 3404
3402 } // end of namespace X86Internal 3405 } // end of namespace X86Internal
3403 } // end of namespace Ice 3406 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/shift.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698