OLD | NEW |
1 //===--- CGExprScalar.cpp - Emit LLVM Code for Scalar Exprs ---------------===// | 1 //===--- CGExprScalar.cpp - Emit LLVM Code for Scalar Exprs ---------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
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 contains code to emit Expr nodes with scalar LLVM types as LLVM code. | 10 // This contains code to emit Expr nodes with scalar LLVM types as LLVM code. |
(...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 return Builder.CreateLShr(Ops.LHS, RHS, "shr"); | 2065 return Builder.CreateLShr(Ops.LHS, RHS, "shr"); |
2066 return Builder.CreateAShr(Ops.LHS, RHS, "shr"); | 2066 return Builder.CreateAShr(Ops.LHS, RHS, "shr"); |
2067 } | 2067 } |
2068 | 2068 |
2069 enum IntrinsicType { VCMPEQ, VCMPGT }; | 2069 enum IntrinsicType { VCMPEQ, VCMPGT }; |
2070 // return corresponding comparison intrinsic for given vector type | 2070 // return corresponding comparison intrinsic for given vector type |
2071 static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT, | 2071 static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT, |
2072 BuiltinType::Kind ElemKind) { | 2072 BuiltinType::Kind ElemKind) { |
2073 switch (ElemKind) { | 2073 switch (ElemKind) { |
2074 default: assert(0 && "unexpected element type"); | 2074 default: assert(0 && "unexpected element type"); |
| 2075 #if 0 |
2075 case BuiltinType::Char_U: | 2076 case BuiltinType::Char_U: |
2076 case BuiltinType::UChar: | 2077 case BuiltinType::UChar: |
2077 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p : | 2078 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p : |
2078 llvm::Intrinsic::ppc_altivec_vcmpgtub_p; | 2079 llvm::Intrinsic::ppc_altivec_vcmpgtub_p; |
2079 break; | 2080 break; |
2080 case BuiltinType::Char_S: | 2081 case BuiltinType::Char_S: |
2081 case BuiltinType::SChar: | 2082 case BuiltinType::SChar: |
2082 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p : | 2083 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p : |
2083 llvm::Intrinsic::ppc_altivec_vcmpgtsb_p; | 2084 llvm::Intrinsic::ppc_altivec_vcmpgtsb_p; |
2084 break; | 2085 break; |
(...skipping 12 matching lines...) Expand all Loading... |
2097 break; | 2098 break; |
2098 case BuiltinType::Int: | 2099 case BuiltinType::Int: |
2099 case BuiltinType::Long: | 2100 case BuiltinType::Long: |
2100 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p : | 2101 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p : |
2101 llvm::Intrinsic::ppc_altivec_vcmpgtsw_p; | 2102 llvm::Intrinsic::ppc_altivec_vcmpgtsw_p; |
2102 break; | 2103 break; |
2103 case BuiltinType::Float: | 2104 case BuiltinType::Float: |
2104 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p : | 2105 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p : |
2105 llvm::Intrinsic::ppc_altivec_vcmpgtfp_p; | 2106 llvm::Intrinsic::ppc_altivec_vcmpgtfp_p; |
2106 break; | 2107 break; |
| 2108 #endif |
2107 } | 2109 } |
2108 return llvm::Intrinsic::not_intrinsic; | 2110 return llvm::Intrinsic::not_intrinsic; |
2109 } | 2111 } |
2110 | 2112 |
2111 Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, | 2113 Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, |
2112 unsigned SICmpOpc, unsigned FCmpOpc) { | 2114 unsigned SICmpOpc, unsigned FCmpOpc) { |
2113 TestAndClearIgnoreResultAssign(); | 2115 TestAndClearIgnoreResultAssign(); |
2114 Value *Result; | 2116 Value *Result; |
2115 QualType LHSTy = E->getLHS()->getType(); | 2117 QualType LHSTy = E->getLHS()->getType(); |
2116 if (const MemberPointerType *MPT = LHSTy->getAs<MemberPointerType>()) { | 2118 if (const MemberPointerType *MPT = LHSTy->getAs<MemberPointerType>()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 ID = GetIntrinsic(VCMPGT, ElementKind); | 2157 ID = GetIntrinsic(VCMPGT, ElementKind); |
2156 std::swap(FirstVecArg, SecondVecArg); | 2158 std::swap(FirstVecArg, SecondVecArg); |
2157 break; | 2159 break; |
2158 case BO_GT: | 2160 case BO_GT: |
2159 CR6 = CR6_LT; | 2161 CR6 = CR6_LT; |
2160 ID = GetIntrinsic(VCMPGT, ElementKind); | 2162 ID = GetIntrinsic(VCMPGT, ElementKind); |
2161 break; | 2163 break; |
2162 case BO_LE: | 2164 case BO_LE: |
2163 if (ElementKind == BuiltinType::Float) { | 2165 if (ElementKind == BuiltinType::Float) { |
2164 CR6 = CR6_LT; | 2166 CR6 = CR6_LT; |
| 2167 #if defined(TARGET_ENABLED_POWERPC) |
2165 ID = llvm::Intrinsic::ppc_altivec_vcmpgefp_p; | 2168 ID = llvm::Intrinsic::ppc_altivec_vcmpgefp_p; |
2166 std::swap(FirstVecArg, SecondVecArg); | 2169 std::swap(FirstVecArg, SecondVecArg); |
| 2170 #else |
| 2171 llvm_unreachable("Using Intrinsic::ppc_altivec_vcmpgefp_p w/out" |
| 2172 " TARGET_ENABLED_POWERPC defined!"); |
| 2173 #endif // TARGET_ENABLED_POWERPC |
2167 } | 2174 } |
2168 else { | 2175 else { |
2169 CR6 = CR6_EQ; | 2176 CR6 = CR6_EQ; |
2170 ID = GetIntrinsic(VCMPGT, ElementKind); | 2177 ID = GetIntrinsic(VCMPGT, ElementKind); |
2171 } | 2178 } |
2172 break; | 2179 break; |
2173 case BO_GE: | 2180 case BO_GE: |
2174 if (ElementKind == BuiltinType::Float) { | 2181 if (ElementKind == BuiltinType::Float) { |
2175 CR6 = CR6_LT; | 2182 CR6 = CR6_LT; |
| 2183 #if defined(TARGET_ENABLED_POWERPC) |
2176 ID = llvm::Intrinsic::ppc_altivec_vcmpgefp_p; | 2184 ID = llvm::Intrinsic::ppc_altivec_vcmpgefp_p; |
| 2185 #else |
| 2186 llvm_unreachable("Using Intrinsic::ppc_altivec_vcmpgefp_p w/out" |
| 2187 " TARGET_ENABLED_POWERPC defined!"); |
| 2188 #endif // TARGET_ENABLED_POWERPC |
2177 } | 2189 } |
2178 else { | 2190 else { |
2179 CR6 = CR6_EQ; | 2191 CR6 = CR6_EQ; |
2180 ID = GetIntrinsic(VCMPGT, ElementKind); | 2192 ID = GetIntrinsic(VCMPGT, ElementKind); |
2181 std::swap(FirstVecArg, SecondVecArg); | 2193 std::swap(FirstVecArg, SecondVecArg); |
2182 } | 2194 } |
2183 break; | 2195 break; |
2184 } | 2196 } |
2185 | 2197 |
2186 Value *CR6Param = Builder.getInt32(CR6); | 2198 Value *CR6Param = Builder.getInt32(CR6); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 case BO_LAnd: | 2761 case BO_LAnd: |
2750 case BO_LOr: | 2762 case BO_LOr: |
2751 case BO_Assign: | 2763 case BO_Assign: |
2752 case BO_Comma: | 2764 case BO_Comma: |
2753 assert(false && "Not valid compound assignment operators"); | 2765 assert(false && "Not valid compound assignment operators"); |
2754 break; | 2766 break; |
2755 } | 2767 } |
2756 | 2768 |
2757 llvm_unreachable("Unhandled compound assignment operator"); | 2769 llvm_unreachable("Unhandled compound assignment operator"); |
2758 } | 2770 } |
OLD | NEW |