Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
Jim Stichnoth | 92a6e5b | 2015-12-02 16:52:44 -0800 | [diff] [blame] | 11 | /// \brief Declares the TargetLoweringX8632 class, which implements the |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 12 | /// TargetLowering interface for the x86-32 architecture. |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 13 | /// |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
| 17 | #define SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
| 18 | |
John Porto | aff4ccf | 2015-06-10 16:35:06 -0700 | [diff] [blame] | 19 | #include "IceAssemblerX8632.h" |
Jim Stichnoth | a18cc9c | 2014-09-30 19:10:22 -0700 | [diff] [blame] | 20 | #include "IceDefs.h" |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 21 | #include "IceRegistersX8632.h" |
Jim Stichnoth | a18cc9c | 2014-09-30 19:10:22 -0700 | [diff] [blame] | 22 | #include "IceTargetLowering.h" |
John Porto | 4a56686 | 2016-01-04 09:33:41 -0800 | [diff] [blame] | 23 | #include "IceInstX8632.h" |
| 24 | #define X86NAMESPACE X8632 |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 25 | #include "IceTargetLoweringX86Base.h" |
John Porto | 4a56686 | 2016-01-04 09:33:41 -0800 | [diff] [blame] | 26 | #undef X86NAMESPACE |
| 27 | #include "IceTargetLoweringX8632Traits.h" |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 28 | |
| 29 | namespace Ice { |
John Porto | 4a56686 | 2016-01-04 09:33:41 -0800 | [diff] [blame] | 30 | namespace X8632 { |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 31 | |
John Porto | 4a56686 | 2016-01-04 09:33:41 -0800 | [diff] [blame] | 32 | class TargetX8632 final : public ::Ice::X8632::TargetX86Base<X8632::Traits> { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 33 | TargetX8632() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 34 | TargetX8632(const TargetX8632 &) = delete; |
| 35 | TargetX8632 &operator=(const TargetX8632 &) = delete; |
| 36 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 37 | public: |
John Porto | 53611e2 | 2015-12-30 07:30:10 -0800 | [diff] [blame] | 38 | ~TargetX8632() = default; |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 39 | |
John Porto | 53611e2 | 2015-12-30 07:30:10 -0800 | [diff] [blame] | 40 | static std::unique_ptr<::Ice::TargetLowering> create(Cfg *Func) { |
| 41 | return makeUnique<TargetX8632>(Func); |
| 42 | } |
| 43 | |
| 44 | std::unique_ptr<::Ice::Assembler> createAssembler() const override { |
| 45 | return makeUnique<X8632::AssemblerX8632>(); |
| 46 | } |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 47 | |
John Porto | e0d9afa | 2015-08-05 10:13:44 -0700 | [diff] [blame] | 48 | protected: |
John Porto | 56958cb | 2016-01-14 09:18:18 -0800 | [diff] [blame] | 49 | void _add_sp(Operand *Adjustment); |
| 50 | void _mov_sp(Operand *NewValue); |
John Porto | ac2388c | 2016-01-22 07:10:56 -0800 | [diff] [blame] | 51 | Traits::X86OperandMem *_sandbox_mem_reference(X86OperandMem *Mem); |
John Porto | 56958cb | 2016-01-14 09:18:18 -0800 | [diff] [blame] | 52 | void _sub_sp(Operand *Adjustment); |
David Sehr | b9a404d | 2016-01-21 08:09:27 -0800 | [diff] [blame] | 53 | void _link_bp(); |
| 54 | void _unlink_bp(); |
Stephen White | 17078c7 | 2019-02-27 14:39:14 -0500 | [diff] [blame] | 55 | void _push_reg(RegNumT RegNum); |
| 56 | void _pop_reg(RegNumT RegNum); |
John Porto | 56958cb | 2016-01-14 09:18:18 -0800 | [diff] [blame] | 57 | |
John Porto | ac2388c | 2016-01-22 07:10:56 -0800 | [diff] [blame] | 58 | void initRebasePtr(); |
| 59 | void initSandbox(); |
| 60 | bool legalizeOptAddrForSandbox(OptAddr *Addr); |
David Sehr | b9a404d | 2016-01-21 08:09:27 -0800 | [diff] [blame] | 61 | void emitSandboxedReturn(); |
John Porto | 56958cb | 2016-01-14 09:18:18 -0800 | [diff] [blame] | 62 | void lowerIndirectJump(Variable *JumpTarget); |
David Sehr | b9a404d | 2016-01-21 08:09:27 -0800 | [diff] [blame] | 63 | void emitGetIP(CfgNode *Node); |
David Sehr | 0c68bef | 2016-01-20 10:00:23 -0800 | [diff] [blame] | 64 | Inst *emitCallToTarget(Operand *CallTarget, Variable *ReturnReg) override; |
| 65 | Variable *moveReturnValueToRegister(Operand *Value, Type ReturnType) override; |
John Porto | e0d9afa | 2015-08-05 10:13:44 -0700 | [diff] [blame] | 66 | |
John Porto | 453660f | 2015-07-31 14:52:52 -0700 | [diff] [blame] | 67 | private: |
John Porto | 53611e2 | 2015-12-30 07:30:10 -0800 | [diff] [blame] | 68 | ENABLE_MAKE_UNIQUE; |
John Porto | 4a56686 | 2016-01-04 09:33:41 -0800 | [diff] [blame] | 69 | friend class X8632::TargetX86Base<X8632::Traits>; |
John Porto | 453660f | 2015-07-31 14:52:52 -0700 | [diff] [blame] | 70 | |
David Sehr | 6b80cf1 | 2016-01-21 23:16:58 -0800 | [diff] [blame] | 71 | explicit TargetX8632(Cfg *Func) : TargetX86Base(Func) {} |
| 72 | |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 73 | Operand *createNaClReadTPSrcOperand() { |
| 74 | Constant *Zero = Ctx->getConstantZero(IceType_i32); |
| 75 | return Traits::X86OperandMem::create(Func, IceType_i32, nullptr, Zero, |
| 76 | nullptr, 0, |
| 77 | Traits::X86OperandMem::SegReg_GS); |
| 78 | } |
Jan Voung | fb79284 | 2015-06-11 15:27:50 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
John Porto | 4a56686 | 2016-01-04 09:33:41 -0800 | [diff] [blame] | 81 | } // end of namespace X8632 |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 82 | } // end of namespace Ice |
| 83 | |
| 84 | #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H |