OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// |
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 // This file implements the TargetLoweringX8632 class, which | 10 // This file implements the TargetLoweringX8632 class, which |
(...skipping 3432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3443 Variable *ValLo = llvm::cast<Variable>(loOperand(ValVar)); | 3443 Variable *ValLo = llvm::cast<Variable>(loOperand(ValVar)); |
3444 Variable *ValHi = llvm::cast<Variable>(hiOperand(ValVar)); | 3444 Variable *ValHi = llvm::cast<Variable>(hiOperand(ValVar)); |
3445 Context.insert(InstFakeUse::create(Func, ValLo)); | 3445 Context.insert(InstFakeUse::create(Func, ValLo)); |
3446 Context.insert(InstFakeUse::create(Func, ValHi)); | 3446 Context.insert(InstFakeUse::create(Func, ValHi)); |
3447 } | 3447 } |
3448 } else { | 3448 } else { |
3449 // For xchg, the loop is slightly smaller and ebx/ecx are used. | 3449 // For xchg, the loop is slightly smaller and ebx/ecx are used. |
3450 Context.insert(InstFakeUse::create(Func, T_ebx)); | 3450 Context.insert(InstFakeUse::create(Func, T_ebx)); |
3451 Context.insert(InstFakeUse::create(Func, T_ecx)); | 3451 Context.insert(InstFakeUse::create(Func, T_ecx)); |
3452 } | 3452 } |
3453 // The address base is also reused in the loop. | 3453 // The address base (if any) is also reused in the loop. |
3454 Context.insert(InstFakeUse::create(Func, Addr->getBase())); | 3454 if (Variable *Base = Addr->getBase()) |
| 3455 Context.insert(InstFakeUse::create(Func, Base)); |
3455 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); | 3456 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); |
3456 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); | 3457 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); |
3457 _mov(DestLo, T_eax); | 3458 _mov(DestLo, T_eax); |
3458 _mov(DestHi, T_edx); | 3459 _mov(DestHi, T_edx); |
3459 return; | 3460 return; |
3460 } | 3461 } |
3461 OperandX8632Mem *Addr = FormMemoryOperand(Ptr, Ty); | 3462 OperandX8632Mem *Addr = FormMemoryOperand(Ptr, Ty); |
3462 Variable *T_eax = makeReg(Ty, RegX8632::Reg_eax); | 3463 Variable *T_eax = makeReg(Ty, RegX8632::Reg_eax); |
3463 _mov(T_eax, Addr); | 3464 _mov(T_eax, Addr); |
3464 InstX8632Label *Label = InstX8632Label::create(Func, this); | 3465 InstX8632Label *Label = InstX8632Label::create(Func, this); |
3465 Context.insert(Label); | 3466 Context.insert(Label); |
3466 // We want to pick a different register for T than Eax, so don't use | 3467 // We want to pick a different register for T than Eax, so don't use |
3467 // _mov(T == nullptr, T_eax). | 3468 // _mov(T == nullptr, T_eax). |
3468 Variable *T = makeReg(Ty); | 3469 Variable *T = makeReg(Ty); |
3469 _mov(T, T_eax); | 3470 _mov(T, T_eax); |
3470 (this->*Op_Lo)(T, Val); | 3471 (this->*Op_Lo)(T, Val); |
3471 const bool Locked = true; | 3472 const bool Locked = true; |
3472 _cmpxchg(Addr, T_eax, T, Locked); | 3473 _cmpxchg(Addr, T_eax, T, Locked); |
3473 _br(CondX86::Br_ne, Label); | 3474 _br(CondX86::Br_ne, Label); |
3474 // If Val is a variable, model the extended live range of Val through | 3475 // If Val is a variable, model the extended live range of Val through |
3475 // the end of the loop, since it will be re-used by the loop. | 3476 // the end of the loop, since it will be re-used by the loop. |
3476 if (Variable *ValVar = llvm::dyn_cast<Variable>(Val)) { | 3477 if (Variable *ValVar = llvm::dyn_cast<Variable>(Val)) { |
3477 Context.insert(InstFakeUse::create(Func, ValVar)); | 3478 Context.insert(InstFakeUse::create(Func, ValVar)); |
3478 } | 3479 } |
3479 // The address base is also reused in the loop. | 3480 // The address base (if any) is also reused in the loop. |
3480 Context.insert(InstFakeUse::create(Func, Addr->getBase())); | 3481 if (Variable *Base = Addr->getBase()) |
| 3482 Context.insert(InstFakeUse::create(Func, Base)); |
3481 _mov(Dest, T_eax); | 3483 _mov(Dest, T_eax); |
3482 } | 3484 } |
3483 | 3485 |
3484 // Lowers count {trailing, leading} zeros intrinsic. | 3486 // Lowers count {trailing, leading} zeros intrinsic. |
3485 // | 3487 // |
3486 // We could do constant folding here, but that should have | 3488 // We could do constant folding here, but that should have |
3487 // been done by the front-end/middle-end optimizations. | 3489 // been done by the front-end/middle-end optimizations. |
3488 void TargetX8632::lowerCountZeros(bool Cttz, Type Ty, Variable *Dest, | 3490 void TargetX8632::lowerCountZeros(bool Cttz, Type Ty, Variable *Dest, |
3489 Operand *FirstVal, Operand *SecondVal) { | 3491 Operand *FirstVal, Operand *SecondVal) { |
3490 // TODO(jvoung): Determine if the user CPU supports LZCNT (BMI). | 3492 // TODO(jvoung): Determine if the user CPU supports LZCNT (BMI). |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4847 case FT_Asm: | 4849 case FT_Asm: |
4848 case FT_Iasm: { | 4850 case FT_Iasm: { |
4849 OstreamLocker L(Ctx); | 4851 OstreamLocker L(Ctx); |
4850 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 4852 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
4851 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 4853 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
4852 } break; | 4854 } break; |
4853 } | 4855 } |
4854 } | 4856 } |
4855 | 4857 |
4856 } // end of namespace Ice | 4858 } // end of namespace Ice |
OLD | NEW |