| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 #undef X | 108 #undef X |
| 109 }; | 109 }; |
| 110 const size_t TableTypeX8632AttributesSize = | 110 const size_t TableTypeX8632AttributesSize = |
| 111 llvm::array_lengthof(TableTypeX8632Attributes); | 111 llvm::array_lengthof(TableTypeX8632Attributes); |
| 112 | 112 |
| 113 // Return the type which the elements of the vector have in the X86 | 113 // Return the type which the elements of the vector have in the X86 |
| 114 // representation of the vector. | 114 // representation of the vector. |
| 115 Type getInVectorElementType(Type Ty) { | 115 Type getInVectorElementType(Type Ty) { |
| 116 assert(isVectorType(Ty)); | 116 assert(isVectorType(Ty)); |
| 117 size_t Index = static_cast<size_t>(Ty); | 117 size_t Index = static_cast<size_t>(Ty); |
| 118 (void)Index; |
| 118 assert(Index < TableTypeX8632AttributesSize); | 119 assert(Index < TableTypeX8632AttributesSize); |
| 119 return TableTypeX8632Attributes[Ty].InVectorElementType; | 120 return TableTypeX8632Attributes[Ty].InVectorElementType; |
| 120 } | 121 } |
| 121 | 122 |
| 122 // The maximum number of arguments to pass in XMM registers | 123 // The maximum number of arguments to pass in XMM registers |
| 123 const unsigned X86_MAX_XMM_ARGS = 4; | 124 const unsigned X86_MAX_XMM_ARGS = 4; |
| 124 // The number of bits in a byte | 125 // The number of bits in a byte |
| 125 const unsigned X86_CHAR_BIT = 8; | 126 const unsigned X86_CHAR_BIT = 8; |
| 126 | 127 |
| 127 // Instruction set options | 128 // Instruction set options |
| (...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 assert(Src0->getType() == IceType_v16i1); | 2045 assert(Src0->getType() == IceType_v16i1); |
| 2045 InstCall *Call = makeHelperCall("Sz_bitcast_v16i1_to_i16", Dest, 1); | 2046 InstCall *Call = makeHelperCall("Sz_bitcast_v16i1_to_i16", Dest, 1); |
| 2046 Call->addArg(Src0); | 2047 Call->addArg(Src0); |
| 2047 lowerCall(Call); | 2048 lowerCall(Call); |
| 2048 } break; | 2049 } break; |
| 2049 case IceType_i32: | 2050 case IceType_i32: |
| 2050 case IceType_f32: { | 2051 case IceType_f32: { |
| 2051 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); | 2052 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); |
| 2052 Type DestType = Dest->getType(); | 2053 Type DestType = Dest->getType(); |
| 2053 Type SrcType = Src0RM->getType(); | 2054 Type SrcType = Src0RM->getType(); |
| 2055 (void)DestType; |
| 2054 assert((DestType == IceType_i32 && SrcType == IceType_f32) || | 2056 assert((DestType == IceType_i32 && SrcType == IceType_f32) || |
| 2055 (DestType == IceType_f32 && SrcType == IceType_i32)); | 2057 (DestType == IceType_f32 && SrcType == IceType_i32)); |
| 2056 // a.i32 = bitcast b.f32 ==> | 2058 // a.i32 = bitcast b.f32 ==> |
| 2057 // t.f32 = b.f32 | 2059 // t.f32 = b.f32 |
| 2058 // s.f32 = spill t.f32 | 2060 // s.f32 = spill t.f32 |
| 2059 // a.i32 = s.f32 | 2061 // a.i32 = s.f32 |
| 2060 Variable *T = NULL; | 2062 Variable *T = NULL; |
| 2061 // TODO: Should be able to force a spill setup by calling legalize() with | 2063 // TODO: Should be able to force a spill setup by calling legalize() with |
| 2062 // Legal_Mem and not Legal_Reg or Legal_Imm. | 2064 // Legal_Mem and not Legal_Reg or Legal_Imm. |
| 2063 Variable *Spill = Func->makeVariable(SrcType, Context.getNode()); | 2065 Variable *Spill = Func->makeVariable(SrcType, Context.getNode()); |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2744 // Make sure that the atomic load isn't elided when unused. | 2746 // Make sure that the atomic load isn't elided when unused. |
| 2745 Context.insert(InstFakeUse::create(Func, Dest->getLo())); | 2747 Context.insert(InstFakeUse::create(Func, Dest->getLo())); |
| 2746 Context.insert(InstFakeUse::create(Func, Dest->getHi())); | 2748 Context.insert(InstFakeUse::create(Func, Dest->getHi())); |
| 2747 return; | 2749 return; |
| 2748 } | 2750 } |
| 2749 InstLoad *Load = InstLoad::create(Func, Dest, Instr->getArg(0)); | 2751 InstLoad *Load = InstLoad::create(Func, Dest, Instr->getArg(0)); |
| 2750 lowerLoad(Load); | 2752 lowerLoad(Load); |
| 2751 // Make sure the atomic load isn't elided when unused, by adding a FakeUse. | 2753 // Make sure the atomic load isn't elided when unused, by adding a FakeUse. |
| 2752 // Since lowerLoad may fuse the load w/ an arithmetic instruction, | 2754 // Since lowerLoad may fuse the load w/ an arithmetic instruction, |
| 2753 // insert the FakeUse on the last-inserted instruction's dest. | 2755 // insert the FakeUse on the last-inserted instruction's dest. |
| 2754 Context.insert(InstFakeUse::create(Func, | 2756 Context.insert( |
| 2755 Context.getLastInserted()->getDest())); | 2757 InstFakeUse::create(Func, Context.getLastInserted()->getDest())); |
| 2756 return; | 2758 return; |
| 2757 } | 2759 } |
| 2758 case Intrinsics::AtomicRMW: | 2760 case Intrinsics::AtomicRMW: |
| 2759 if (!Intrinsics::VerifyMemoryOrder( | 2761 if (!Intrinsics::VerifyMemoryOrder( |
| 2760 llvm::cast<ConstantInteger>(Instr->getArg(3))->getValue())) { | 2762 llvm::cast<ConstantInteger>(Instr->getArg(3))->getValue())) { |
| 2761 Func->setError("Unexpected memory ordering for AtomicRMW"); | 2763 Func->setError("Unexpected memory ordering for AtomicRMW"); |
| 2762 return; | 2764 return; |
| 2763 } | 2765 } |
| 2764 lowerAtomicRMW(Instr->getDest(), | 2766 lowerAtomicRMW(Instr->getDest(), |
| 2765 static_cast<uint32_t>(llvm::cast<ConstantInteger>( | 2767 static_cast<uint32_t>(llvm::cast<ConstantInteger>( |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3137 break; | 3139 break; |
| 3138 } | 3140 } |
| 3139 OperandX8632Mem *Addr = FormMemoryOperand(Ptr, Dest->getType()); | 3141 OperandX8632Mem *Addr = FormMemoryOperand(Ptr, Dest->getType()); |
| 3140 Variable *T = NULL; | 3142 Variable *T = NULL; |
| 3141 _mov(T, Val); | 3143 _mov(T, Val); |
| 3142 _xchg(Addr, T); | 3144 _xchg(Addr, T); |
| 3143 _mov(Dest, T); | 3145 _mov(Dest, T); |
| 3144 return; | 3146 return; |
| 3145 } | 3147 } |
| 3146 // Otherwise, we need a cmpxchg loop. | 3148 // Otherwise, we need a cmpxchg loop. |
| 3149 (void)NeedsCmpxchg; |
| 3147 assert(NeedsCmpxchg); | 3150 assert(NeedsCmpxchg); |
| 3148 expandAtomicRMWAsCmpxchg(Op_Lo, Op_Hi, Dest, Ptr, Val); | 3151 expandAtomicRMWAsCmpxchg(Op_Lo, Op_Hi, Dest, Ptr, Val); |
| 3149 } | 3152 } |
| 3150 | 3153 |
| 3151 void TargetX8632::expandAtomicRMWAsCmpxchg(LowerBinOp Op_Lo, LowerBinOp Op_Hi, | 3154 void TargetX8632::expandAtomicRMWAsCmpxchg(LowerBinOp Op_Lo, LowerBinOp Op_Hi, |
| 3152 Variable *Dest, Operand *Ptr, | 3155 Variable *Dest, Operand *Ptr, |
| 3153 Operand *Val) { | 3156 Operand *Val) { |
| 3154 // Expand a more complex RMW operation as a cmpxchg loop: | 3157 // Expand a more complex RMW operation as a cmpxchg loop: |
| 3155 // For 64-bit: | 3158 // For 64-bit: |
| 3156 // mov eax, [ptr] | 3159 // mov eax, [ptr] |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 for (SizeT i = 0; i < Size; ++i) { | 4136 for (SizeT i = 0; i < Size; ++i) { |
| 4134 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; | 4137 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; |
| 4135 } | 4138 } |
| 4136 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4139 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
| 4137 } | 4140 } |
| 4138 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName | 4141 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName |
| 4139 << "\n"; | 4142 << "\n"; |
| 4140 } | 4143 } |
| 4141 | 4144 |
| 4142 } // end of namespace Ice | 4145 } // end of namespace Ice |
| OLD | NEW |