| OLD | NEW |
| 1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===// | 1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 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 // This file declares the TargetLoweringX8632 class, which | 10 // This file declares the TargetLoweringX8632 class, which |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 113 } |
| 114 bool hasFramePointer() const override { return IsEbpBasedFrame; } | 114 bool hasFramePointer() const override { return IsEbpBasedFrame; } |
| 115 SizeT getFrameOrStackReg() const override { | 115 SizeT getFrameOrStackReg() const override { |
| 116 return IsEbpBasedFrame ? RegX8632::Reg_ebp : RegX8632::Reg_esp; | 116 return IsEbpBasedFrame ? RegX8632::Reg_ebp : RegX8632::Reg_esp; |
| 117 } | 117 } |
| 118 size_t typeWidthInBytesOnStack(Type Ty) const override { | 118 size_t typeWidthInBytesOnStack(Type Ty) const override { |
| 119 // Round up to the next multiple of 4 bytes. In particular, i1, | 119 // Round up to the next multiple of 4 bytes. In particular, i1, |
| 120 // i8, and i16 are rounded up to 4 bytes. | 120 // i8, and i16 are rounded up to 4 bytes. |
| 121 return (typeWidthInBytes(Ty) + 3) & ~3; | 121 return (typeWidthInBytes(Ty) + 3) & ~3; |
| 122 } | 122 } |
| 123 |
| 123 void emitVariable(const Variable *Var) const override; | 124 void emitVariable(const Variable *Var) const override; |
| 124 | 125 |
| 125 const char *getConstantPrefix() const final { return "$"; } | 126 const char *getConstantPrefix() const final { return "$"; } |
| 126 void emit(const ConstantUndef *C) const final; | 127 void emit(const ConstantUndef *C) const final; |
| 127 void emit(const ConstantInteger32 *C) const final; | 128 void emit(const ConstantInteger32 *C) const final; |
| 128 void emit(const ConstantInteger64 *C) const final; | 129 void emit(const ConstantInteger64 *C) const final; |
| 129 void emit(const ConstantFloat *C) const final; | 130 void emit(const ConstantFloat *C) const final; |
| 130 void emit(const ConstantDouble *C) const final; | 131 void emit(const ConstantDouble *C) const final; |
| 131 | 132 |
| 132 void lowerArguments() override; | 133 void lowerArguments() override; |
| 133 void initNodeForLowering(CfgNode *Node) override; | 134 void initNodeForLowering(CfgNode *Node) override; |
| 134 void addProlog(CfgNode *Node) override; | 135 void addProlog(CfgNode *Node) override; |
| 135 void addEpilog(CfgNode *Node) override; | 136 void addEpilog(CfgNode *Node) override; |
| 136 // Ensure that a 64-bit Variable has been split into 2 32-bit | 137 // Ensure that a 64-bit Variable has been split into 2 32-bit |
| 137 // Variables, creating them if necessary. This is needed for all | 138 // Variables, creating them if necessary. This is needed for all |
| 138 // I64 operations, and it is needed for pushing F64 arguments for | 139 // I64 operations, and it is needed for pushing F64 arguments for |
| 139 // function calls using the 32-bit push instruction (though the | 140 // function calls using the 32-bit push instruction (though the |
| 140 // latter could be done by directly writing to the stack). | 141 // latter could be done by directly writing to the stack). |
| 141 void split64(Variable *Var); | 142 void split64(Variable *Var); |
| 143 Operand *loOperand(Operand *Operand); |
| 144 Operand *hiOperand(Operand *Operand); |
| 142 void finishArgumentLowering(Variable *Arg, Variable *FramePtr, | 145 void finishArgumentLowering(Variable *Arg, Variable *FramePtr, |
| 143 size_t BasicFrameOffset, size_t &InArgsSizeBytes); | 146 size_t BasicFrameOffset, size_t &InArgsSizeBytes); |
| 144 Operand *loOperand(Operand *Operand); | |
| 145 Operand *hiOperand(Operand *Operand); | |
| 146 X8632::Address stackVarToAsmOperand(const Variable *Var) const; | 147 X8632::Address stackVarToAsmOperand(const Variable *Var) const; |
| 147 | 148 |
| 148 enum X86InstructionSet { | 149 enum X86InstructionSet { |
| 149 Begin, | 150 Begin, |
| 150 // SSE2 is the PNaCl baseline instruction set. | 151 // SSE2 is the PNaCl baseline instruction set. |
| 151 SSE2 = Begin, | 152 SSE2 = Begin, |
| 152 SSE4_1, | 153 SSE4_1, |
| 153 End | 154 End |
| 154 }; | 155 }; |
| 155 | 156 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 199 |
| 199 typedef void (TargetX8632::*LowerBinOp)(Variable *, Operand *); | 200 typedef void (TargetX8632::*LowerBinOp)(Variable *, Operand *); |
| 200 void expandAtomicRMWAsCmpxchg(LowerBinOp op_lo, LowerBinOp op_hi, | 201 void expandAtomicRMWAsCmpxchg(LowerBinOp op_lo, LowerBinOp op_hi, |
| 201 Variable *Dest, Operand *Ptr, Operand *Val); | 202 Variable *Dest, Operand *Ptr, Operand *Val); |
| 202 | 203 |
| 203 void eliminateNextVectorSextInstruction(Variable *SignExtendedResult); | 204 void eliminateNextVectorSextInstruction(Variable *SignExtendedResult); |
| 204 | 205 |
| 205 void scalarizeArithmetic(InstArithmetic::OpKind K, Variable *Dest, | 206 void scalarizeArithmetic(InstArithmetic::OpKind K, Variable *Dest, |
| 206 Operand *Src0, Operand *Src1); | 207 Operand *Src0, Operand *Src1); |
| 207 | 208 |
| 208 void sortByAlignment(VarList &Dest, const VarList &Source) const; | |
| 209 | |
| 210 // Operand legalization helpers. To deal with address mode | 209 // Operand legalization helpers. To deal with address mode |
| 211 // constraints, the helpers will create a new Operand and emit | 210 // constraints, the helpers will create a new Operand and emit |
| 212 // instructions that guarantee that the Operand kind is one of those | 211 // instructions that guarantee that the Operand kind is one of those |
| 213 // indicated by the LegalMask (a bitmask of allowed kinds). If the | 212 // indicated by the LegalMask (a bitmask of allowed kinds). If the |
| 214 // input Operand is known to already meet the constraints, it may be | 213 // input Operand is known to already meet the constraints, it may be |
| 215 // simply returned as the result, without creating any new | 214 // simply returned as the result, without creating any new |
| 216 // instructions or operands. | 215 // instructions or operands. |
| 217 enum OperandLegalization { | 216 enum OperandLegalization { |
| 218 Legal_None = 0, | 217 Legal_None = 0, |
| 219 Legal_Reg = 1 << 0, // physical register, not stack location | 218 Legal_Reg = 1 << 0, // physical register, not stack location |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 295 } |
| 297 void _bsf(Variable *Dest, Operand *Src0) { | 296 void _bsf(Variable *Dest, Operand *Src0) { |
| 298 Context.insert(InstX8632Bsf::create(Func, Dest, Src0)); | 297 Context.insert(InstX8632Bsf::create(Func, Dest, Src0)); |
| 299 } | 298 } |
| 300 void _bsr(Variable *Dest, Operand *Src0) { | 299 void _bsr(Variable *Dest, Operand *Src0) { |
| 301 Context.insert(InstX8632Bsr::create(Func, Dest, Src0)); | 300 Context.insert(InstX8632Bsr::create(Func, Dest, Src0)); |
| 302 } | 301 } |
| 303 void _bswap(Variable *SrcDest) { | 302 void _bswap(Variable *SrcDest) { |
| 304 Context.insert(InstX8632Bswap::create(Func, SrcDest)); | 303 Context.insert(InstX8632Bswap::create(Func, SrcDest)); |
| 305 } | 304 } |
| 306 void | |
| 307 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) { | |
| 308 Context.insert(InstBundleLock::create(Func, BundleOption)); | |
| 309 } | |
| 310 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); } | |
| 311 void _cbwdq(Variable *Dest, Operand *Src0) { | 305 void _cbwdq(Variable *Dest, Operand *Src0) { |
| 312 Context.insert(InstX8632Cbwdq::create(Func, Dest, Src0)); | 306 Context.insert(InstX8632Cbwdq::create(Func, Dest, Src0)); |
| 313 } | 307 } |
| 314 void _cmov(Variable *Dest, Operand *Src0, CondX86::BrCond Condition) { | 308 void _cmov(Variable *Dest, Operand *Src0, CondX86::BrCond Condition) { |
| 315 Context.insert(InstX8632Cmov::create(Func, Dest, Src0, Condition)); | 309 Context.insert(InstX8632Cmov::create(Func, Dest, Src0, Condition)); |
| 316 } | 310 } |
| 317 void _cmp(Operand *Src0, Operand *Src1) { | 311 void _cmp(Operand *Src0, Operand *Src1) { |
| 318 Context.insert(InstX8632Icmp::create(Func, Src0, Src1)); | 312 Context.insert(InstX8632Icmp::create(Func, Src0, Src1)); |
| 319 } | 313 } |
| 320 void _cmpps(Variable *Dest, Operand *Src0, CondX86::CmppsCond Condition) { | 314 void _cmpps(Variable *Dest, Operand *Src0, CondX86::CmppsCond Condition) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 591 |
| 598 private: | 592 private: |
| 599 void lowerGlobal(const VariableDeclaration &Var) const; | 593 void lowerGlobal(const VariableDeclaration &Var) const; |
| 600 ~TargetDataX8632() override {} | 594 ~TargetDataX8632() override {} |
| 601 template <typename T> static void emitConstantPool(GlobalContext *Ctx); | 595 template <typename T> static void emitConstantPool(GlobalContext *Ctx); |
| 602 }; | 596 }; |
| 603 | 597 |
| 604 } // end of namespace Ice | 598 } // end of namespace Ice |
| 605 | 599 |
| 606 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H | 600 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
| OLD | NEW |