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 |
30 : public ::Ice::X86Internal::TargetX86Base<TargetX8664> { | |
26 TargetX8664() = delete; | 31 TargetX8664() = delete; |
27 TargetX8664(const TargetX8664 &) = delete; | 32 TargetX8664(const TargetX8664 &) = delete; |
28 TargetX8664 &operator=(const TargetX8664 &) = delete; | 33 TargetX8664 &operator=(const TargetX8664 &) = delete; |
29 | 34 |
30 public: | 35 public: |
31 static TargetX8664 *create(Cfg *Func); | 36 static TargetX8664 *create(Cfg *Func) { return new TargetX8664(Func); } |
32 | 37 |
33 private: | 38 private: |
34 explicit TargetX8664(Cfg *Func) : TargetLowering(Func) {} | 39 friend class ::Ice::X86Internal::TargetX86Base<TargetX8664>; |
40 | |
41 explicit TargetX8664(Cfg *Func) | |
42 : ::Ice::X86Internal::TargetX86Base<TargetX8664>(Func) {} | |
43 | |
44 Operand *createNaClReadTPSrcOperand() { | |
45 Variable *TDB = callNaClReadTp(); | |
46 Variable *RZP = materializeRZP(); | |
47 Constant *TPOffset = Ctx->getConstantInt8(0x20); | |
jvoung (off chromium)
2015/07/30 21:16:22
Hmm this magic offset doesn't seem particularly fa
John
2015/07/31 21:05:54
I got confused with the comments in
native_client
| |
48 return Traits::X86OperandMem::create(Func, IceType_i32, RZP, TPOffset, TDB); | |
49 } | |
50 | |
51 Variable *callNaClReadTp() { | |
52 Variable *TDB = makeReg(IceType_i32); | |
53 InstCall *Call = makeHelperCall(H_call_read_tp, TDB, 0); | |
54 lowerCall(Call); | |
55 return TDB; | |
56 } | |
57 | |
58 Variable *materializeRZP() { | |
59 Variable *RZP = makeReg(IceType_i32, Traits::RegisterSet::Reg_r15d); | |
jvoung (off chromium)
2015/07/30 21:16:22
Should this use getPhysicalRegister() and RZP mark
John
2015/07/31 21:05:54
N/A anymore (this method was removed.)
As to RZP
jvoung (off chromium)
2015/07/31 21:21:05
Okay sounds fine for this CL. Just raising awarene
John
2015/07/31 21:29:06
You are awesome at finding things that will be pa
| |
60 Context.insert(InstFakeDef::create(Func, RZP)); | |
61 return RZP; | |
62 } | |
35 }; | 63 }; |
36 | 64 |
37 class TargetDataX8664 : public TargetDataLowering { | 65 class TargetDataX8664 : public TargetDataLowering { |
38 TargetDataX8664() = delete; | 66 TargetDataX8664() = delete; |
39 TargetDataX8664(const TargetDataX8664 &) = delete; | 67 TargetDataX8664(const TargetDataX8664 &) = delete; |
40 TargetDataX8664 &operator=(const TargetDataX8664 &) = delete; | 68 TargetDataX8664 &operator=(const TargetDataX8664 &) = delete; |
41 | 69 |
42 public: | 70 public: |
43 ~TargetDataX8664() override = default; | 71 ~TargetDataX8664() override = default; |
44 | 72 |
45 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) { | 73 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) { |
46 return makeUnique<TargetDataX8664>(Ctx); | 74 return makeUnique<TargetDataX8664>(Ctx); |
47 } | 75 } |
48 | 76 |
49 void lowerGlobals(const VariableDeclarationList &Vars, | 77 void lowerGlobals(const VariableDeclarationList &Vars, |
50 const IceString &SectionSuffix) override; | 78 const IceString &SectionSuffix) override; |
51 | 79 |
52 void lowerConstants() override; | 80 void lowerConstants() override; |
53 | 81 |
54 private: | 82 private: |
55 ENABLE_MAKE_UNIQUE; | 83 ENABLE_MAKE_UNIQUE; |
56 | 84 |
57 explicit TargetDataX8664(GlobalContext *Ctx) : TargetDataLowering(Ctx) {} | 85 explicit TargetDataX8664(GlobalContext *Ctx) : TargetDataLowering(Ctx) {} |
86 template <typename T> static void emitConstantPool(GlobalContext *Ctx); | |
58 }; | 87 }; |
59 | 88 |
60 class TargetHeaderX8664 : public TargetHeaderLowering { | 89 class TargetHeaderX8664 : public TargetHeaderLowering { |
61 TargetHeaderX8664() = delete; | 90 TargetHeaderX8664() = delete; |
62 TargetHeaderX8664(const TargetHeaderX8664 &) = delete; | 91 TargetHeaderX8664(const TargetHeaderX8664 &) = delete; |
63 TargetHeaderX8664 &operator=(const TargetHeaderX8664 &) = delete; | 92 TargetHeaderX8664 &operator=(const TargetHeaderX8664 &) = delete; |
64 | 93 |
65 public: | 94 public: |
66 ~TargetHeaderX8664() = default; | 95 ~TargetHeaderX8664() = default; |
67 | 96 |
68 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { | 97 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) { |
69 return makeUnique<TargetHeaderX8664>(Ctx); | 98 return makeUnique<TargetHeaderX8664>(Ctx); |
70 } | 99 } |
71 | 100 |
72 private: | 101 private: |
73 ENABLE_MAKE_UNIQUE; | 102 ENABLE_MAKE_UNIQUE; |
74 | 103 |
75 explicit TargetHeaderX8664(GlobalContext *Ctx) : TargetHeaderLowering(Ctx) {} | 104 explicit TargetHeaderX8664(GlobalContext *Ctx) : TargetHeaderLowering(Ctx) {} |
76 }; | 105 }; |
77 } // end of namespace Ice | 106 } // end of namespace Ice |
78 | 107 |
79 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664_H | 108 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664_H |
OLD | NEW |