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 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3381 break; | 3381 break; |
3382 } | 3382 } |
3383 if (Shift + LogMult <= 3) { | 3383 if (Shift + LogMult <= 3) { |
3384 Index = IndexVariable0; | 3384 Index = IndexVariable0; |
3385 Shift += LogMult; | 3385 Shift += LogMult; |
3386 continue; | 3386 continue; |
3387 } | 3387 } |
3388 } | 3388 } |
3389 } | 3389 } |
3390 | 3390 |
| 3391 // Base is Base=Var+Const || Base is Base=Const+Var ==> |
| 3392 // set Base=Var, Offset+=Const |
| 3393 // Base is Base=Var-Const ==> |
| 3394 // set Base=Var, Offset-=Const |
| 3395 const InstArithmetic *ArithInst = |
| 3396 llvm::dyn_cast_or_null<const InstArithmetic>(BaseInst); |
| 3397 if (ArithInst && (ArithInst->getOp() == InstArithmetic::Add || |
| 3398 ArithInst->getOp() == InstArithmetic::Sub)) { |
| 3399 bool IsAdd = ArithInst->getOp() == InstArithmetic::Add; |
| 3400 Variable *Var = NULL; |
| 3401 ConstantInteger *Const = NULL; |
| 3402 if (Variable *VariableOperand = |
| 3403 llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) { |
| 3404 Var = VariableOperand; |
| 3405 Const = llvm::dyn_cast<ConstantInteger>(ArithInst->getSrc(1)); |
| 3406 } else if (IsAdd) { |
| 3407 Const = llvm::dyn_cast<ConstantInteger>(ArithInst->getSrc(0)); |
| 3408 Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1)); |
| 3409 } |
| 3410 if (!(Const && Var)) { |
| 3411 break; |
| 3412 } |
| 3413 Base = Var; |
| 3414 Offset += IsAdd ? Const->getValue() : -Const->getValue(); |
| 3415 continue; |
| 3416 } |
| 3417 |
3391 // Index is Index=Var<<Const && Const+Shift<=3 ==> | 3418 // Index is Index=Var<<Const && Const+Shift<=3 ==> |
3392 // Index=Var, Shift+=Const | 3419 // Index=Var, Shift+=Const |
3393 | 3420 |
3394 // Index is Index=Const*Var && log2(Const)+Shift<=3 ==> | 3421 // Index is Index=Const*Var && log2(Const)+Shift<=3 ==> |
3395 // Index=Var, Shift+=log2(Const) | 3422 // Index=Var, Shift+=log2(Const) |
3396 | 3423 |
3397 // Index && Shift==0 && Base is Base=Var*Const && log2(Const)+Shift<=3 ==> | 3424 // Index && Shift==0 && Base is Base=Var*Const && log2(Const)+Shift<=3 ==> |
3398 // swap(Index,Base) | 3425 // swap(Index,Base) |
3399 // Similar for Base=Const*Var and Base=Var<<Const | 3426 // Similar for Base=Const*Var and Base=Var<<Const |
3400 | 3427 |
3401 // Base is Base=Var+Const ==> | |
3402 // set Base=Var, Offset+=Const | |
3403 | |
3404 // Base is Base=Const+Var ==> | |
3405 // set Base=Var, Offset+=Const | |
3406 | |
3407 // Base is Base=Var-Const ==> | |
3408 // set Base=Var, Offset-=Const | |
3409 | |
3410 // Index is Index=Var+Const ==> | 3428 // Index is Index=Var+Const ==> |
3411 // set Index=Var, Offset+=(Const<<Shift) | 3429 // set Index=Var, Offset+=(Const<<Shift) |
3412 | 3430 |
3413 // Index is Index=Const+Var ==> | 3431 // Index is Index=Const+Var ==> |
3414 // set Index=Var, Offset+=(Const<<Shift) | 3432 // set Index=Var, Offset+=(Const<<Shift) |
3415 | 3433 |
3416 // Index is Index=Var-Const ==> | 3434 // Index is Index=Var-Const ==> |
3417 // set Index=Var, Offset-=(Const<<Shift) | 3435 // set Index=Var, Offset-=(Const<<Shift) |
3418 | 3436 |
3419 // TODO: consider overflow issues with respect to Offset. | 3437 // TODO: consider overflow issues with respect to Offset. |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4032 int32_t RegNum = AvailableTypedRegisters.find_first(); | 4050 int32_t RegNum = AvailableTypedRegisters.find_first(); |
4033 Var->setRegNum(RegNum); | 4051 Var->setRegNum(RegNum); |
4034 AvailableRegisters[RegNum] = false; | 4052 AvailableRegisters[RegNum] = false; |
4035 } | 4053 } |
4036 } | 4054 } |
4037 } | 4055 } |
4038 } | 4056 } |
4039 | 4057 |
4040 template <> void ConstantInteger::emit(GlobalContext *Ctx) const { | 4058 template <> void ConstantInteger::emit(GlobalContext *Ctx) const { |
4041 Ostream &Str = Ctx->getStrEmit(); | 4059 Ostream &Str = Ctx->getStrEmit(); |
4042 Str << getValue(); | 4060 Str << (int64_t) getValue(); |
4043 } | 4061 } |
4044 | 4062 |
4045 template <> void ConstantFloat::emit(GlobalContext *Ctx) const { | 4063 template <> void ConstantFloat::emit(GlobalContext *Ctx) const { |
4046 Ostream &Str = Ctx->getStrEmit(); | 4064 Ostream &Str = Ctx->getStrEmit(); |
4047 // It would be better to prefix with ".L$" instead of "L$", but | 4065 // It would be better to prefix with ".L$" instead of "L$", but |
4048 // llvm-mc doesn't parse "dword ptr [.L$foo]". | 4066 // llvm-mc doesn't parse "dword ptr [.L$foo]". |
4049 Str << "dword ptr [L$" << IceType_f32 << "$" << getPoolEntryID() << "]"; | 4067 Str << "dword ptr [L$" << IceType_f32 << "$" << getPoolEntryID() << "]"; |
4050 } | 4068 } |
4051 | 4069 |
4052 template <> void ConstantDouble::emit(GlobalContext *Ctx) const { | 4070 template <> void ConstantDouble::emit(GlobalContext *Ctx) const { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4148 for (SizeT i = 0; i < Size; ++i) { | 4166 for (SizeT i = 0; i < Size; ++i) { |
4149 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; | 4167 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; |
4150 } | 4168 } |
4151 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4169 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
4152 } | 4170 } |
4153 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName | 4171 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName |
4154 << "\n"; | 4172 << "\n"; |
4155 } | 4173 } |
4156 | 4174 |
4157 } // end of namespace Ice | 4175 } // end of namespace Ice |
OLD | NEW |