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