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 3371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Index is Index=Var<<Const && Const+Shift<=3 ==> | 3391 // Index is Index=Var<<Const && Const+Shift<=3 ==> |
3392 // Index=Var, Shift+=Const | 3392 // Index=Var, Shift+=Const |
jvoung (off chromium)
2014/08/12 00:34:57
Could you move these comments for the << opts, to
wala
2014/08/12 00:46:54
Done.
| |
3393 | 3393 |
3394 // Index is Index=Const*Var && log2(Const)+Shift<=3 ==> | 3394 // Index is Index=Const*Var && log2(Const)+Shift<=3 ==> |
3395 // Index=Var, Shift+=log2(Const) | 3395 // Index=Var, Shift+=log2(Const) |
3396 | 3396 |
3397 // Index && Shift==0 && Base is Base=Var*Const && log2(Const)+Shift<=3 ==> | 3397 // Index && Shift==0 && Base is Base=Var*Const && log2(Const)+Shift<=3 ==> |
3398 // swap(Index,Base) | 3398 // swap(Index,Base) |
3399 // Similar for Base=Const*Var and Base=Var<<Const | 3399 // Similar for Base=Const*Var and Base=Var<<Const |
3400 | 3400 |
3401 // Base is Base=Var+Const ==> | 3401 // Base is Base=Var+Const || Base is Base=Const+Var ==> |
3402 // set Base=Var, Offset+=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 ==> | 3403 // Base is Base=Var-Const ==> |
3408 // set Base=Var, Offset-=Const | 3404 // set Base=Var, Offset-=Const |
3405 const InstArithmetic *ArithInst = | |
3406 llvm::dyn_cast_or_null<const InstArithmetic>(BaseInst); | |
3407 if (ArithInst && (ArithInst->getOp() == InstArithmetic::Add || | |
3408 ArithInst->getOp() == InstArithmetic::Sub)) { | |
3409 bool IsAdd = ArithInst->getOp() == InstArithmetic::Add; | |
3410 Variable *Var = NULL; | |
3411 ConstantInteger *Const = NULL; | |
3412 if (Variable *VariableOperand = | |
3413 llvm::dyn_cast<Variable>(ArithInst->getSrc(0))) { | |
3414 Var = VariableOperand; | |
3415 Const = llvm::dyn_cast<ConstantInteger>(ArithInst->getSrc(1)); | |
3416 } else if (IsAdd) { | |
3417 Const = llvm::dyn_cast<ConstantInteger>(ArithInst->getSrc(0)); | |
3418 Var = llvm::dyn_cast<Variable>(ArithInst->getSrc(1)); | |
3419 } | |
3420 if (!(Const && Var)) { | |
3421 break; | |
3422 } | |
3423 Base = Var; | |
3424 Offset += IsAdd ? Const->getValue() : -Const->getValue(); | |
3425 continue; | |
3426 } | |
3409 | 3427 |
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 |
(...skipping 613 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 |