Chromium Code Reviews| 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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1368 case InstArithmetic::Fsub: | 1368 case InstArithmetic::Fsub: |
| 1369 case InstArithmetic::Fmul: | 1369 case InstArithmetic::Fmul: |
| 1370 case InstArithmetic::Fdiv: | 1370 case InstArithmetic::Fdiv: |
| 1371 case InstArithmetic::Frem: | 1371 case InstArithmetic::Frem: |
| 1372 llvm_unreachable("FP instruction with i64 type"); | 1372 llvm_unreachable("FP instruction with i64 type"); |
| 1373 break; | 1373 break; |
| 1374 } | 1374 } |
| 1375 } else if (isVectorType(Dest->getType())) { | 1375 } else if (isVectorType(Dest->getType())) { |
| 1376 // TODO: Trap on integer divide and integer modulo by zero. | 1376 // TODO: Trap on integer divide and integer modulo by zero. |
| 1377 // See: https://code.google.com/p/nativeclient/issues/detail?id=3899 | 1377 // See: https://code.google.com/p/nativeclient/issues/detail?id=3899 |
| 1378 if (llvm::isa<OperandX8632Mem>(Src1)) | |
| 1379 Src1 = legalizeToVar(Src1); | |
| 1378 switch (Inst->getOp()) { | 1380 switch (Inst->getOp()) { |
| 1379 case InstArithmetic::_num: | 1381 case InstArithmetic::_num: |
| 1380 llvm_unreachable("Unknown arithmetic operator"); | 1382 llvm_unreachable("Unknown arithmetic operator"); |
| 1381 break; | 1383 break; |
| 1382 case InstArithmetic::Add: { | 1384 case InstArithmetic::Add: { |
| 1383 Variable *T = makeReg(Dest->getType()); | 1385 Variable *T = makeReg(Dest->getType()); |
| 1384 _movp(T, Src0); | 1386 _movp(T, Src0); |
| 1385 _padd(T, Src1); | 1387 _padd(T, Src1); |
| 1386 _movp(Dest, T); | 1388 _movp(Dest, T); |
| 1387 } break; | 1389 } break; |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2083 Variable *T = makeReg(Dest->getType()); | 2085 Variable *T = makeReg(Dest->getType()); |
| 2084 _cvt(T, Src0RM, InstX8632Cvt::Float2float); | 2086 _cvt(T, Src0RM, InstX8632Cvt::Float2float); |
| 2085 _mov(Dest, T); | 2087 _mov(Dest, T); |
| 2086 break; | 2088 break; |
| 2087 } | 2089 } |
| 2088 case InstCast::Fptosi: | 2090 case InstCast::Fptosi: |
| 2089 if (isVectorType(Dest->getType())) { | 2091 if (isVectorType(Dest->getType())) { |
| 2090 assert(Dest->getType() == IceType_v4i32 && | 2092 assert(Dest->getType() == IceType_v4i32 && |
| 2091 Inst->getSrc(0)->getType() == IceType_v4f32); | 2093 Inst->getSrc(0)->getType() == IceType_v4f32); |
| 2092 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); | 2094 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); |
| 2095 if (llvm::isa<OperandX8632Mem>(Src0RM)) | |
| 2096 Src0RM = legalizeToVar(Src0RM); | |
| 2093 Variable *T = makeReg(Dest->getType()); | 2097 Variable *T = makeReg(Dest->getType()); |
| 2094 _cvt(T, Src0RM, InstX8632Cvt::Tps2dq); | 2098 _cvt(T, Src0RM, InstX8632Cvt::Tps2dq); |
| 2095 _movp(Dest, T); | 2099 _movp(Dest, T); |
| 2096 } else if (Dest->getType() == IceType_i64) { | 2100 } else if (Dest->getType() == IceType_i64) { |
| 2097 // Use a helper for converting floating-point values to 64-bit | 2101 // Use a helper for converting floating-point values to 64-bit |
| 2098 // integers. SSE2 appears to have no way to convert from xmm | 2102 // integers. SSE2 appears to have no way to convert from xmm |
| 2099 // registers to something like the edx:eax register pair, and | 2103 // registers to something like the edx:eax register pair, and |
| 2100 // gcc and clang both want to use x87 instructions complete with | 2104 // gcc and clang both want to use x87 instructions complete with |
| 2101 // temporary manipulation of the status word. This helper is | 2105 // temporary manipulation of the status word. This helper is |
| 2102 // not needed for x86-64. | 2106 // not needed for x86-64. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2158 if (Dest->getType() == IceType_i1) | 2162 if (Dest->getType() == IceType_i1) |
| 2159 _and(T_2, Ctx->getConstantInt1(1)); | 2163 _and(T_2, Ctx->getConstantInt1(1)); |
| 2160 _mov(Dest, T_2); | 2164 _mov(Dest, T_2); |
| 2161 } | 2165 } |
| 2162 break; | 2166 break; |
| 2163 case InstCast::Sitofp: | 2167 case InstCast::Sitofp: |
| 2164 if (isVectorType(Dest->getType())) { | 2168 if (isVectorType(Dest->getType())) { |
| 2165 assert(Dest->getType() == IceType_v4f32 && | 2169 assert(Dest->getType() == IceType_v4f32 && |
| 2166 Inst->getSrc(0)->getType() == IceType_v4i32); | 2170 Inst->getSrc(0)->getType() == IceType_v4i32); |
| 2167 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); | 2171 Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem); |
| 2172 if (llvm::isa<OperandX8632Mem>(Src0RM)) | |
| 2173 Src0RM = legalizeToVar(Src0RM); | |
| 2168 Variable *T = makeReg(Dest->getType()); | 2174 Variable *T = makeReg(Dest->getType()); |
| 2169 _cvt(T, Src0RM, InstX8632Cvt::Dq2ps); | 2175 _cvt(T, Src0RM, InstX8632Cvt::Dq2ps); |
| 2170 _movp(Dest, T); | 2176 _movp(Dest, T); |
| 2171 } else if (Inst->getSrc(0)->getType() == IceType_i64) { | 2177 } else if (Inst->getSrc(0)->getType() == IceType_i64) { |
| 2172 // Use a helper for x86-32. | 2178 // Use a helper for x86-32. |
| 2173 const SizeT MaxSrcs = 1; | 2179 const SizeT MaxSrcs = 1; |
| 2174 Type DestType = Dest->getType(); | 2180 Type DestType = Dest->getType(); |
| 2175 InstCall *Call = | 2181 InstCall *Call = |
| 2176 makeHelperCall(isFloat32Asserting32Or64(DestType) ? H_sitofp_i64_f32 | 2182 makeHelperCall(isFloat32Asserting32Or64(DestType) ? H_sitofp_i64_f32 |
| 2177 : H_sitofp_i64_f64, | 2183 : H_sitofp_i64_f64, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2465 Variable *T = nullptr; | 2471 Variable *T = nullptr; |
| 2466 | 2472 |
| 2467 if (Condition == InstFcmp::True) { | 2473 if (Condition == InstFcmp::True) { |
| 2468 // makeVectorOfOnes() requires an integer vector type. | 2474 // makeVectorOfOnes() requires an integer vector type. |
| 2469 T = makeVectorOfMinusOnes(IceType_v4i32); | 2475 T = makeVectorOfMinusOnes(IceType_v4i32); |
| 2470 } else if (Condition == InstFcmp::False) { | 2476 } else if (Condition == InstFcmp::False) { |
| 2471 T = makeVectorOfZeros(Dest->getType()); | 2477 T = makeVectorOfZeros(Dest->getType()); |
| 2472 } else { | 2478 } else { |
| 2473 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); | 2479 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); |
| 2474 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); | 2480 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); |
| 2481 if (llvm::isa<OperandX8632Mem>(Src1RM)) | |
| 2482 Src1RM = legalizeToVar(Src1RM); | |
| 2475 | 2483 |
| 2476 switch (Condition) { | 2484 switch (Condition) { |
| 2477 default: { | 2485 default: { |
| 2478 CondX86::CmppsCond Predicate = TableFcmp[Index].Predicate; | 2486 CondX86::CmppsCond Predicate = TableFcmp[Index].Predicate; |
| 2479 assert(Predicate != CondX86::Cmpps_Invalid); | 2487 assert(Predicate != CondX86::Cmpps_Invalid); |
| 2480 T = makeReg(Src0RM->getType()); | 2488 T = makeReg(Src0RM->getType()); |
| 2481 _movp(T, Src0RM); | 2489 _movp(T, Src0RM); |
| 2482 _cmpps(T, Src1RM, Predicate); | 2490 _cmpps(T, Src1RM, Predicate); |
| 2483 } break; | 2491 } break; |
| 2484 case InstFcmp::One: { | 2492 case InstFcmp::One: { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2579 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc1, Src1)); | 2587 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc1, Src1)); |
| 2580 Src0 = NewSrc0; | 2588 Src0 = NewSrc0; |
| 2581 Src1 = NewSrc1; | 2589 Src1 = NewSrc1; |
| 2582 Ty = NewTy; | 2590 Ty = NewTy; |
| 2583 } | 2591 } |
| 2584 | 2592 |
| 2585 InstIcmp::ICond Condition = Inst->getCondition(); | 2593 InstIcmp::ICond Condition = Inst->getCondition(); |
| 2586 | 2594 |
| 2587 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); | 2595 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); |
| 2588 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); | 2596 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); |
| 2597 if (llvm::isa<OperandX8632Mem>(Src0RM)) | |
|
jvoung (off chromium)
2015/03/23 21:30:35
Vs the other places where only Src1RM is legalized
Jim Stichnoth
2015/03/23 22:10:03
Done - pushed the appropriate legalization into ea
| |
| 2598 Src0RM = legalizeToVar(Src0RM); | |
| 2599 if (llvm::isa<OperandX8632Mem>(Src1RM)) | |
| 2600 Src1RM = legalizeToVar(Src1RM); | |
| 2589 | 2601 |
| 2590 // SSE2 only has signed comparison operations. Transform unsigned | 2602 // SSE2 only has signed comparison operations. Transform unsigned |
| 2591 // inputs in a manner that allows for the use of signed comparison | 2603 // inputs in a manner that allows for the use of signed comparison |
| 2592 // operations by flipping the high order bits. | 2604 // operations by flipping the high order bits. |
| 2593 if (Condition == InstIcmp::Ugt || Condition == InstIcmp::Uge || | 2605 if (Condition == InstIcmp::Ugt || Condition == InstIcmp::Uge || |
| 2594 Condition == InstIcmp::Ult || Condition == InstIcmp::Ule) { | 2606 Condition == InstIcmp::Ult || Condition == InstIcmp::Ule) { |
| 2595 Variable *T0 = makeReg(Ty); | 2607 Variable *T0 = makeReg(Ty); |
| 2596 Variable *T1 = makeReg(Ty); | 2608 Variable *T1 = makeReg(Ty); |
| 2597 Variable *HighOrderBits = makeVectorOfHighOrderBits(Ty); | 2609 Variable *HighOrderBits = makeVectorOfHighOrderBits(Ty); |
| 2598 _movp(T0, Src0RM); | 2610 _movp(T0, Src0RM); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3085 SecondVal); | 3097 SecondVal); |
| 3086 return; | 3098 return; |
| 3087 } | 3099 } |
| 3088 case Intrinsics::Fabs: { | 3100 case Intrinsics::Fabs: { |
| 3089 Operand *Src = legalize(Instr->getArg(0)); | 3101 Operand *Src = legalize(Instr->getArg(0)); |
| 3090 Type Ty = Src->getType(); | 3102 Type Ty = Src->getType(); |
| 3091 Variable *Dest = Instr->getDest(); | 3103 Variable *Dest = Instr->getDest(); |
| 3092 Variable *T = makeVectorOfFabsMask(Ty); | 3104 Variable *T = makeVectorOfFabsMask(Ty); |
| 3093 // The pand instruction operates on an m128 memory operand, so if | 3105 // The pand instruction operates on an m128 memory operand, so if |
| 3094 // Src is an f32 or f64, we need to make sure it's in a register. | 3106 // Src is an f32 or f64, we need to make sure it's in a register. |
| 3095 if (!isVectorType(Ty)) | 3107 if (isVectorType(Ty)) { |
| 3108 if (llvm::isa<OperandX8632Mem>(Src)) | |
| 3109 Src = legalizeToVar(Src); | |
| 3110 } else { | |
| 3096 Src = legalizeToVar(Src); | 3111 Src = legalizeToVar(Src); |
| 3112 } | |
| 3097 _pand(T, Src); | 3113 _pand(T, Src); |
| 3098 if (isVectorType(Ty)) | 3114 if (isVectorType(Ty)) |
| 3099 _movp(Dest, T); | 3115 _movp(Dest, T); |
| 3100 else | 3116 else |
| 3101 _mov(Dest, T); | 3117 _mov(Dest, T); |
| 3102 return; | 3118 return; |
| 3103 } | 3119 } |
| 3104 case Intrinsics::Longjmp: { | 3120 case Intrinsics::Longjmp: { |
| 3105 InstCall *Call = makeHelperCall(H_call_longjmp, nullptr, 2); | 3121 InstCall *Call = makeHelperCall(H_call_longjmp, nullptr, 2); |
| 3106 Call->addArg(Instr->getArg(0)); | 3122 Call->addArg(Instr->getArg(0)); |
| (...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4847 case FT_Asm: | 4863 case FT_Asm: |
| 4848 case FT_Iasm: { | 4864 case FT_Iasm: { |
| 4849 OstreamLocker L(Ctx); | 4865 OstreamLocker L(Ctx); |
| 4850 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 4866 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
| 4851 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 4867 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
| 4852 } break; | 4868 } break; |
| 4853 } | 4869 } |
| 4854 } | 4870 } |
| 4855 | 4871 |
| 4856 } // end of namespace Ice | 4872 } // end of namespace Ice |
| OLD | NEW |