Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// | 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| (...skipping 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2481 // is passed. | 2481 // is passed. |
| 2482 for (SizeT i = 0, NumArgs = Instr->getNumArgs(); i < NumArgs; ++i) { | 2482 for (SizeT i = 0, NumArgs = Instr->getNumArgs(); i < NumArgs; ++i) { |
| 2483 Operand *Arg = Instr->getArg(i); | 2483 Operand *Arg = Instr->getArg(i); |
| 2484 const Type Ty = Arg->getType(); | 2484 const Type Ty = Arg->getType(); |
| 2485 // The PNaCl ABI requires the width of arguments to be at least 32 bits. | 2485 // The PNaCl ABI requires the width of arguments to be at least 32 bits. |
| 2486 assert(typeWidthInBytes(Ty) >= 4); | 2486 assert(typeWidthInBytes(Ty) >= 4); |
| 2487 if (isVectorType(Ty) && (Traits::getRegisterForXmmArgNum(XmmArgs.size()) != | 2487 if (isVectorType(Ty) && (Traits::getRegisterForXmmArgNum(XmmArgs.size()) != |
| 2488 Variable::NoRegister)) { | 2488 Variable::NoRegister)) { |
| 2489 XmmArgs.push_back(Arg); | 2489 XmmArgs.push_back(Arg); |
| 2490 } else if (isScalarFloatingType(Ty) && Traits::X86_PASS_SCALAR_FP_IN_XMM && | 2490 } else if (isScalarFloatingType(Ty) && Traits::X86_PASS_SCALAR_FP_IN_XMM && |
| 2491 (Traits::getRegisterForXmmArgNum(0) != Variable::NoRegister)) { | 2491 (Traits::getRegisterForXmmArgNum(XmmArgs.size()) != |
| 2492 Variable::NoRegister)) { | |
| 2492 XmmArgs.push_back(Arg); | 2493 XmmArgs.push_back(Arg); |
| 2493 } else if (isScalarIntegerType(Ty) && | 2494 } else if (isScalarIntegerType(Ty) && |
| 2494 (Traits::getRegisterForGprArgNum(Ty, GprArgs.size()) != | 2495 (Traits::getRegisterForGprArgNum(Ty, GprArgs.size()) != |
| 2495 Variable::NoRegister)) { | 2496 Variable::NoRegister)) { |
| 2496 GprArgs.emplace_back(Ty, Arg); | 2497 GprArgs.emplace_back(Ty, Arg); |
| 2497 } else { | 2498 } else { |
| 2498 // Place on stack. | 2499 // Place on stack. |
| 2499 StackArgs.push_back(Arg); | 2500 StackArgs.push_back(Arg); |
| 2500 if (isVectorType(Arg->getType())) { | 2501 if (isVectorType(Arg->getType())) { |
| 2501 ParameterAreaSizeBytes = | 2502 ParameterAreaSizeBytes = |
| (...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4592 template <typename TraitsType> | 4593 template <typename TraitsType> |
| 4593 void TargetX86Base<TraitsType>::lowerCountZeros(bool Cttz, Type Ty, | 4594 void TargetX86Base<TraitsType>::lowerCountZeros(bool Cttz, Type Ty, |
| 4594 Variable *Dest, | 4595 Variable *Dest, |
| 4595 Operand *FirstVal, | 4596 Operand *FirstVal, |
| 4596 Operand *SecondVal) { | 4597 Operand *SecondVal) { |
| 4597 // TODO(jvoung): Determine if the user CPU supports LZCNT (BMI). | 4598 // TODO(jvoung): Determine if the user CPU supports LZCNT (BMI). |
| 4598 // Then the instructions will handle the Val == 0 case much more simply | 4599 // Then the instructions will handle the Val == 0 case much more simply |
| 4599 // and won't require conversion from bit position to number of zeros. | 4600 // and won't require conversion from bit position to number of zeros. |
| 4600 // | 4601 // |
| 4601 // Otherwise: | 4602 // Otherwise: |
| 4602 // bsr IF_NOT_ZERO, Val | 4603 // bsr IF_NOT_ZERO, Val |
|
Jim Stichnoth
2016/01/26 23:58:55
These comments should be updated.
More importantl
John
2016/01/27 13:03:15
Look at the subzero output for one of the test_bit
| |
| 4603 // mov T_DEST, 63 | 4604 // mov T_DEST, 63 |
| 4604 // cmovne T_DEST, IF_NOT_ZERO | 4605 // cmovne T_DEST, IF_NOT_ZERO |
| 4605 // xor T_DEST, 31 | 4606 // xor T_DEST, 31 |
| 4606 // mov DEST, T_DEST | 4607 // mov DEST, T_DEST |
| 4607 // | 4608 // |
| 4608 // NOTE: T_DEST must be a register because cmov requires its dest to be a | 4609 // NOTE: T_DEST must be a register because cmov requires its dest to be a |
| 4609 // register. Also, bsf and bsr require their dest to be a register. | 4610 // register. Also, bsf and bsr require their dest to be a register. |
| 4610 // | 4611 // |
| 4611 // The xor DEST, 31 converts a bit position to # of leading zeroes. | 4612 // The xor DEST, 31 converts a bit position to # of leading zeroes. |
| 4612 // E.g., for 000... 00001100, bsr will say that the most significant bit | 4613 // E.g., for 000... 00001100, bsr will say that the most significant bit |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 4626 Variable *T = makeReg(DestTy); | 4627 Variable *T = makeReg(DestTy); |
| 4627 Operand *FirstValRM = legalize(FirstVal, Legal_Mem | Legal_Reg); | 4628 Operand *FirstValRM = legalize(FirstVal, Legal_Mem | Legal_Reg); |
| 4628 if (Cttz) { | 4629 if (Cttz) { |
| 4629 _bsf(T, FirstValRM); | 4630 _bsf(T, FirstValRM); |
| 4630 } else { | 4631 } else { |
| 4631 _bsr(T, FirstValRM); | 4632 _bsr(T, FirstValRM); |
| 4632 } | 4633 } |
| 4633 Variable *T_Dest = makeReg(DestTy); | 4634 Variable *T_Dest = makeReg(DestTy); |
| 4634 Constant *_31 = Ctx->getConstantInt32(31); | 4635 Constant *_31 = Ctx->getConstantInt32(31); |
| 4635 Constant *_32 = Ctx->getConstantInt(DestTy, 32); | 4636 Constant *_32 = Ctx->getConstantInt(DestTy, 32); |
| 4637 Constant *_63 = Ctx->getConstantInt(DestTy, 63); | |
| 4638 Constant *_64 = Ctx->getConstantInt(DestTy, 64); | |
| 4636 if (Cttz) { | 4639 if (Cttz) { |
| 4637 _mov(T_Dest, _32); | 4640 if (DestTy == IceType_i64) { |
| 4641 _mov(T_Dest, _64); | |
| 4642 } else { | |
| 4643 _mov(T_Dest, _32); | |
| 4644 } | |
| 4638 } else { | 4645 } else { |
| 4639 Constant *_63 = Ctx->getConstantInt(DestTy, 63); | 4646 Constant *_127 = Ctx->getConstantInt(DestTy, 127); |
| 4640 _mov(T_Dest, _63); | 4647 if (DestTy == IceType_i64) { |
| 4648 _mov(T_Dest, _127); | |
| 4649 } else { | |
| 4650 _mov(T_Dest, _63); | |
| 4651 } | |
| 4641 } | 4652 } |
| 4642 _cmov(T_Dest, T, Traits::Cond::Br_ne); | 4653 _cmov(T_Dest, T, Traits::Cond::Br_ne); |
| 4643 if (!Cttz) { | 4654 if (!Cttz) { |
| 4644 _xor(T_Dest, _31); | 4655 if (DestTy == IceType_i64) { |
| 4656 Constant *_63 = Ctx->getConstantInt32(63); | |
| 4657 _xor(T_Dest, _63); | |
| 4658 } else { | |
| 4659 _xor(T_Dest, _31); | |
| 4660 } | |
| 4645 } | 4661 } |
| 4646 if (Traits::Is64Bit || Ty == IceType_i32) { | 4662 if (Traits::Is64Bit || Ty == IceType_i32) { |
| 4647 _mov(Dest, T_Dest); | 4663 _mov(Dest, T_Dest); |
| 4648 return; | 4664 return; |
| 4649 } | 4665 } |
| 4650 _add(T_Dest, _32); | 4666 _add(T_Dest, _32); |
| 4651 auto *DestLo = llvm::cast<Variable>(loOperand(Dest)); | 4667 auto *DestLo = llvm::cast<Variable>(loOperand(Dest)); |
| 4652 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest)); | 4668 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest)); |
| 4653 // Will be using "test" on this, so we need a registerized variable. | 4669 // Will be using "test" on this, so we need a registerized variable. |
| 4654 Variable *SecondVar = legalizeToReg(SecondVal); | 4670 Variable *SecondVar = legalizeToReg(SecondVal); |
| (...skipping 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7434 emitGlobal(*Var, SectionSuffix); | 7450 emitGlobal(*Var, SectionSuffix); |
| 7435 } | 7451 } |
| 7436 } | 7452 } |
| 7437 } break; | 7453 } break; |
| 7438 } | 7454 } |
| 7439 } | 7455 } |
| 7440 } // end of namespace X86NAMESPACE | 7456 } // end of namespace X86NAMESPACE |
| 7441 } // end of namespace Ice | 7457 } // end of namespace Ice |
| 7442 | 7458 |
| 7443 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 7459 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
| OLD | NEW |