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 |
| 11 | /// This file declares the TargetLoweringX8632 class, which |
| 12 | /// implements the TargetLowering interface for the x86-32 |
| 13 | /// architecture. |
| 14 | /// |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
| 18 | #define SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
| 19 | |
John Porto | aff4ccf | 2015-06-10 16:35:06 -0700 | [diff] [blame] | 20 | #include "IceAssemblerX8632.h" |
Jim Stichnoth | a18cc9c | 2014-09-30 19:10:22 -0700 | [diff] [blame] | 21 | #include "IceDefs.h" |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 22 | #include "IceInstX8632.h" |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 23 | #include "IceRegistersX8632.h" |
Jim Stichnoth | a18cc9c | 2014-09-30 19:10:22 -0700 | [diff] [blame] | 24 | #include "IceTargetLowering.h" |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 25 | #include "IceTargetLoweringX8632Traits.h" |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 26 | #include "IceTargetLoweringX86Base.h" |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 27 | |
| 28 | namespace Ice { |
| 29 | |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 30 | class TargetX8632 final |
| 31 | : public ::Ice::X86Internal::TargetX86Base<TargetX8632> { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 32 | TargetX8632() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 33 | TargetX8632(const TargetX8632 &) = delete; |
| 34 | TargetX8632 &operator=(const TargetX8632 &) = delete; |
| 35 | |
Andrew Scull | 86df4e9 | 2015-07-30 13:54:44 -0700 | [diff] [blame] | 36 | void emitJumpTable(const Cfg *Func, |
| 37 | const InstJumpTable *JumpTable) const override; |
| 38 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 39 | public: |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 40 | using X86InstructionSet = X8632::Traits::InstructionSet; |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 41 | |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 42 | static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); } |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 43 | |
John Porto | e0d9afa | 2015-08-05 10:13:44 -0700 | [diff] [blame] | 44 | protected: |
| 45 | void lowerCall(const InstCall *Instr) override; |
John Porto | 729b5f6 | 2015-08-06 07:44:30 -0700 | [diff] [blame] | 46 | void lowerArguments() override; |
| 47 | void lowerRet(const InstRet *Inst) override; |
| 48 | void addProlog(CfgNode *Node) override; |
| 49 | void addEpilog(CfgNode *Node) override; |
John Porto | e0d9afa | 2015-08-05 10:13:44 -0700 | [diff] [blame] | 50 | |
John Porto | 453660f | 2015-07-31 14:52:52 -0700 | [diff] [blame] | 51 | private: |
| 52 | friend class ::Ice::X86Internal::TargetX86Base<TargetX8632>; |
| 53 | |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 54 | Operand *createNaClReadTPSrcOperand() { |
| 55 | Constant *Zero = Ctx->getConstantZero(IceType_i32); |
| 56 | return Traits::X86OperandMem::create(Func, IceType_i32, nullptr, Zero, |
| 57 | nullptr, 0, |
| 58 | Traits::X86OperandMem::SegReg_GS); |
| 59 | } |
| 60 | |
John Porto | 5aeed95 | 2015-07-21 13:39:09 -0700 | [diff] [blame] | 61 | explicit TargetX8632(Cfg *Func) : TargetX86Base(Func) {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
John Porto | 0f86d03 | 2015-06-15 07:44:27 -0700 | [diff] [blame] | 64 | class TargetDataX8632 final : public TargetDataLowering { |
Jan Voung | 72984d8 | 2015-01-29 14:42:38 -0800 | [diff] [blame] | 65 | TargetDataX8632() = delete; |
| 66 | TargetDataX8632(const TargetDataX8632 &) = delete; |
| 67 | TargetDataX8632 &operator=(const TargetDataX8632 &) = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 68 | |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 69 | public: |
John Porto | 453660f | 2015-07-31 14:52:52 -0700 | [diff] [blame] | 70 | ~TargetDataX8632() override = default; |
| 71 | |
Jan Voung | fb79284 | 2015-06-11 15:27:50 -0700 | [diff] [blame] | 72 | static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) { |
John Porto | 453660f | 2015-07-31 14:52:52 -0700 | [diff] [blame] | 73 | return makeUnique<TargetDataX8632>(Ctx); |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 74 | } |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 75 | |
John Porto | 8b1a705 | 2015-06-17 13:20:08 -0700 | [diff] [blame] | 76 | void lowerGlobals(const VariableDeclarationList &Vars, |
| 77 | const IceString &SectionSuffix) override; |
John Porto | 0f86d03 | 2015-06-15 07:44:27 -0700 | [diff] [blame] | 78 | void lowerConstants() override; |
Andrew Scull | 86df4e9 | 2015-07-30 13:54:44 -0700 | [diff] [blame] | 79 | void lowerJumpTables() override; |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 80 | |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 81 | private: |
John Porto | 453660f | 2015-07-31 14:52:52 -0700 | [diff] [blame] | 82 | ENABLE_MAKE_UNIQUE; |
| 83 | |
| 84 | explicit TargetDataX8632(GlobalContext *Ctx); |
Jim Stichnoth | fa4efea | 2015-01-27 05:06:03 -0800 | [diff] [blame] | 85 | template <typename T> static void emitConstantPool(GlobalContext *Ctx); |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Jan Voung | fb79284 | 2015-06-11 15:27:50 -0700 | [diff] [blame] | 88 | class TargetHeaderX8632 final : public TargetHeaderLowering { |
| 89 | TargetHeaderX8632() = delete; |
| 90 | TargetHeaderX8632(const TargetHeaderX8632 &) = delete; |
| 91 | TargetHeaderX8632 &operator=(const TargetHeaderX8632 &) = delete; |
| 92 | |
| 93 | public: |
| 94 | static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { |
| 95 | return std::unique_ptr<TargetHeaderLowering>(new TargetHeaderX8632(Ctx)); |
| 96 | } |
| 97 | |
| 98 | protected: |
| 99 | explicit TargetHeaderX8632(GlobalContext *Ctx); |
| 100 | |
| 101 | private: |
| 102 | ~TargetHeaderX8632() = default; |
| 103 | }; |
| 104 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 105 | } // end of namespace Ice |
| 106 | |
| 107 | #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H |