OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8664.h - lowering for x86-64 -*- C++ -*-=// | 1 //===- subzero/src/IceTargetLoweringX8664.h - lowering for x86-64 -*- 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 /// \file | 10 /// \file |
11 /// This file declares the TargetLoweringX8664 class, which implements the | 11 /// This file declares the TargetLoweringX8664 class, which implements the |
12 /// TargetLowering interface for the X86 64-bit architecture. | 12 /// TargetLowering interface for the X86 64-bit architecture. |
13 /// | 13 /// |
14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
15 | 15 |
16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8664_H | 16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8664_H |
17 #define SUBZERO_SRC_ICETARGETLOWERINGX8664_H | 17 #define SUBZERO_SRC_ICETARGETLOWERINGX8664_H |
18 | 18 |
| 19 #include "IceAssemblerX8664.h" |
19 #include "IceCfg.h" | 20 #include "IceCfg.h" |
20 #include "IceGlobalContext.h" | 21 #include "IceGlobalContext.h" |
| 22 #include "IceInstX8664.h" |
21 #include "IceTargetLowering.h" | 23 #include "IceTargetLowering.h" |
| 24 #include "IceTargetLoweringX8664Traits.h" |
| 25 #include "IceTargetLoweringX86Base.h" |
22 | 26 |
23 namespace Ice { | 27 namespace Ice { |
24 | 28 |
25 class TargetX8664 : public TargetLowering { | 29 class TargetX8664 final : public ::Ice::X86Internal::TargetX86Base<TargetX8664>
{ |
26 TargetX8664() = delete; | 30 TargetX8664() = delete; |
27 TargetX8664(const TargetX8664 &) = delete; | 31 TargetX8664(const TargetX8664 &) = delete; |
28 TargetX8664 &operator=(const TargetX8664 &) = delete; | 32 TargetX8664 &operator=(const TargetX8664 &) = delete; |
29 | 33 |
30 public: | 34 public: |
31 static TargetX8664 *create(Cfg *Func); | 35 static TargetX8664 *create(Cfg *Func) { return new TargetX8664(Func); } |
32 | 36 |
33 private: | 37 private: |
34 explicit TargetX8664(Cfg *Func) : TargetLowering(Func) {} | 38 friend class ::Ice::X86Internal::TargetX86Base<TargetX8664>; |
| 39 |
| 40 explicit TargetX8664(Cfg *Func) : ::Ice::X86Internal::TargetX86Base<TargetX866
4>(Func) {} |
| 41 |
| 42 Operand *createNaClReadTPSrcOperand() { |
| 43 Variable *TDB = callNaClReadTp(); |
| 44 Variable *RZP = materializeRZP(); |
| 45 Constant *TPOffset = Ctx->getConstantInt8(0x20); |
| 46 return Traits::X86OperandMem::create(Func, IceType_i32, RZP, TPOffset, TDB); |
| 47 } |
| 48 |
| 49 Variable *callNaClReadTp() { |
| 50 Variable *TDB = makeReg(IceType_i32); |
| 51 InstCall *Call = makeHelperCall(H_call_read_tp, TDB, 0); |
| 52 lowerCall(Call); |
| 53 return TDB; |
| 54 } |
| 55 |
| 56 Variable *materializeRZP() { |
| 57 Variable *RZP = makeReg(IceType_i32, Traits::RegisterSet::Reg_r15d); |
| 58 Context.insert(InstFakeDef::create(Func, RZP)); |
| 59 return RZP; |
| 60 } |
35 }; | 61 }; |
36 | 62 |
37 class TargetDataX8664 : public TargetDataLowering { | 63 class TargetDataX8664 : public TargetDataLowering { |
38 TargetDataX8664() = delete; | 64 TargetDataX8664() = delete; |
39 TargetDataX8664(const TargetDataX8664 &) = delete; | 65 TargetDataX8664(const TargetDataX8664 &) = delete; |
40 TargetDataX8664 &operator=(const TargetDataX8664 &) = delete; | 66 TargetDataX8664 &operator=(const TargetDataX8664 &) = delete; |
41 | 67 |
42 public: | 68 public: |
43 ~TargetDataX8664() override = default; | 69 ~TargetDataX8664() override = default; |
44 | 70 |
45 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) { | 71 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) { |
46 return makeUnique<TargetDataX8664>(Ctx); | 72 return makeUnique<TargetDataX8664>(Ctx); |
47 } | 73 } |
48 | 74 |
49 void lowerGlobals(const VariableDeclarationList &Vars, | 75 void lowerGlobals(const VariableDeclarationList &Vars, |
50 const IceString &SectionSuffix) override; | 76 const IceString &SectionSuffix) override; |
51 | 77 |
52 void lowerConstants() override; | 78 void lowerConstants() override; |
53 | 79 |
54 private: | 80 private: |
55 ENABLE_MAKE_UNIQUE; | 81 ENABLE_MAKE_UNIQUE; |
56 | 82 |
57 explicit TargetDataX8664(GlobalContext *Ctx) : TargetDataLowering(Ctx) {} | 83 explicit TargetDataX8664(GlobalContext *Ctx) : TargetDataLowering(Ctx) {} |
| 84 template <typename T> static void emitConstantPool(GlobalContext *Ctx); |
58 }; | 85 }; |
59 | 86 |
60 class TargetHeaderX8664 : public TargetHeaderLowering { | 87 class TargetHeaderX8664 : public TargetHeaderLowering { |
61 TargetHeaderX8664() = delete; | 88 TargetHeaderX8664() = delete; |
62 TargetHeaderX8664(const TargetHeaderX8664 &) = delete; | 89 TargetHeaderX8664(const TargetHeaderX8664 &) = delete; |
63 TargetHeaderX8664 &operator=(const TargetHeaderX8664 &) = delete; | 90 TargetHeaderX8664 &operator=(const TargetHeaderX8664 &) = delete; |
64 | 91 |
65 public: | 92 public: |
66 ~TargetHeaderX8664() = default; | 93 ~TargetHeaderX8664() = default; |
67 | 94 |
68 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { | 95 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { |
69 return makeUnique<TargetHeaderX8664>(Ctx); | 96 return makeUnique<TargetHeaderX8664>(Ctx); |
70 } | 97 } |
71 | 98 |
72 private: | 99 private: |
73 ENABLE_MAKE_UNIQUE; | 100 ENABLE_MAKE_UNIQUE; |
74 | 101 |
75 explicit TargetHeaderX8664(GlobalContext *Ctx) : TargetHeaderLowering(Ctx) {} | 102 explicit TargetHeaderX8664(GlobalContext *Ctx) : TargetHeaderLowering(Ctx) {} |
76 }; | 103 }; |
77 } // end of namespace Ice | 104 } // end of namespace Ice |
78 | 105 |
79 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664_H | 106 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664_H |
OLD | NEW |