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 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 _imul_imm(T, Src0, ImmConst); | 2221 _imul_imm(T, Src0, ImmConst); |
2222 _mov(Dest, T); | 2222 _mov(Dest, T); |
2223 } else { | 2223 } else { |
2224 _mov(T, Src0); | 2224 _mov(T, Src0); |
2225 _imul(T, Src0 == Src1 ? T : Src1); | 2225 _imul(T, Src0 == Src1 ? T : Src1); |
2226 _mov(Dest, T); | 2226 _mov(Dest, T); |
2227 } | 2227 } |
2228 break; | 2228 break; |
2229 case InstArithmetic::Shl: | 2229 case InstArithmetic::Shl: |
2230 _mov(T, Src0); | 2230 _mov(T, Src0); |
2231 if (!llvm::isa<ConstantInteger32>(Src1)) | 2231 if (!llvm::isa<ConstantInteger32>(Src1) && |
| 2232 !llvm::isa<ConstantInteger64>(Src1)) |
2232 Src1 = copyToReg8(Src1, Traits::RegisterSet::Reg_cl); | 2233 Src1 = copyToReg8(Src1, Traits::RegisterSet::Reg_cl); |
2233 _shl(T, Src1); | 2234 _shl(T, Src1); |
2234 _mov(Dest, T); | 2235 _mov(Dest, T); |
2235 break; | 2236 break; |
2236 case InstArithmetic::Lshr: | 2237 case InstArithmetic::Lshr: |
2237 _mov(T, Src0); | 2238 _mov(T, Src0); |
2238 if (!llvm::isa<ConstantInteger32>(Src1)) | 2239 if (!llvm::isa<ConstantInteger32>(Src1) && |
| 2240 !llvm::isa<ConstantInteger64>(Src1)) |
2239 Src1 = copyToReg8(Src1, Traits::RegisterSet::Reg_cl); | 2241 Src1 = copyToReg8(Src1, Traits::RegisterSet::Reg_cl); |
2240 _shr(T, Src1); | 2242 _shr(T, Src1); |
2241 _mov(Dest, T); | 2243 _mov(Dest, T); |
2242 break; | 2244 break; |
2243 case InstArithmetic::Ashr: | 2245 case InstArithmetic::Ashr: |
2244 _mov(T, Src0); | 2246 _mov(T, Src0); |
2245 if (!llvm::isa<ConstantInteger32>(Src1)) | 2247 if (!llvm::isa<ConstantInteger32>(Src1) && |
| 2248 !llvm::isa<ConstantInteger64>(Src1)) |
2246 Src1 = copyToReg8(Src1, Traits::RegisterSet::Reg_cl); | 2249 Src1 = copyToReg8(Src1, Traits::RegisterSet::Reg_cl); |
2247 _sar(T, Src1); | 2250 _sar(T, Src1); |
2248 _mov(Dest, T); | 2251 _mov(Dest, T); |
2249 break; | 2252 break; |
2250 case InstArithmetic::Udiv: { | 2253 case InstArithmetic::Udiv: { |
2251 // div and idiv are the few arithmetic operators that do not allow | 2254 // div and idiv are the few arithmetic operators that do not allow |
2252 // immediates as the operand. | 2255 // immediates as the operand. |
2253 Src1 = legalize(Src1, Legal_Reg | Legal_Mem); | 2256 Src1 = legalize(Src1, Legal_Reg | Legal_Mem); |
2254 RegNumT Eax; | 2257 RegNumT Eax; |
2255 RegNumT Edx; | 2258 RegNumT Edx; |
(...skipping 5076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7332 if (isVectorType(Ty)) | 7335 if (isVectorType(Ty)) |
7333 return From; | 7336 return From; |
7334 Const = llvm::cast<Constant>(From); | 7337 Const = llvm::cast<Constant>(From); |
7335 } | 7338 } |
7336 // There should be no constants of vector type (other than undef). | 7339 // There should be no constants of vector type (other than undef). |
7337 assert(!isVectorType(Ty)); | 7340 assert(!isVectorType(Ty)); |
7338 | 7341 |
7339 // If the operand is a 64 bit constant integer we need to legalize it to a | 7342 // If the operand is a 64 bit constant integer we need to legalize it to a |
7340 // register in x86-64. | 7343 // register in x86-64. |
7341 if (Traits::Is64Bit) { | 7344 if (Traits::Is64Bit) { |
7342 if (llvm::isa<ConstantInteger64>(Const)) { | 7345 if (auto *C64 = llvm::dyn_cast<ConstantInteger64>(Const)) { |
7343 if (RegNum.hasValue()) { | 7346 if (!Utils::IsInt(32, C64->getValue())) { |
7344 assert(Traits::getGprForType(IceType_i64, RegNum) == RegNum); | 7347 if (RegNum.hasValue()) { |
| 7348 assert(Traits::getGprForType(IceType_i64, RegNum) == RegNum); |
| 7349 } |
| 7350 return copyToReg(Const, RegNum); |
7345 } | 7351 } |
7346 return copyToReg(Const, RegNum); | |
7347 } | 7352 } |
7348 } | 7353 } |
7349 | 7354 |
7350 // If the operand is an 32 bit constant integer, we should check whether we | 7355 // If the operand is an 32 bit constant integer, we should check whether we |
7351 // need to randomize it or pool it. | 7356 // need to randomize it or pool it. |
7352 if (auto *C = llvm::dyn_cast<ConstantInteger32>(Const)) { | 7357 if (auto *C = llvm::dyn_cast<ConstantInteger32>(Const)) { |
7353 Operand *NewConst = randomizeOrPoolImmediate(C, RegNum); | 7358 Operand *NewConst = randomizeOrPoolImmediate(C, RegNum); |
7354 if (NewConst != Const) { | 7359 if (NewConst != Const) { |
7355 return NewConst; | 7360 return NewConst; |
7356 } | 7361 } |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7966 emitGlobal(*Var, SectionSuffix); | 7971 emitGlobal(*Var, SectionSuffix); |
7967 } | 7972 } |
7968 } | 7973 } |
7969 } break; | 7974 } break; |
7970 } | 7975 } |
7971 } | 7976 } |
7972 } // end of namespace X86NAMESPACE | 7977 } // end of namespace X86NAMESPACE |
7973 } // end of namespace Ice | 7978 } // end of namespace Ice |
7974 | 7979 |
7975 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 7980 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
OLD | NEW |