OLD | NEW |
1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- C++ -*-===// | 1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- 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 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 : Context(Context) {} | 131 : Context(Context) {} |
132 ~PostIncrLoweringContext() { | 132 ~PostIncrLoweringContext() { |
133 Context.advanceCur(); | 133 Context.advanceCur(); |
134 Context.advanceNext(); | 134 Context.advanceNext(); |
135 } | 135 } |
136 | 136 |
137 private: | 137 private: |
138 LoweringContext &Context; | 138 LoweringContext &Context; |
139 }; | 139 }; |
140 | 140 |
| 141 /// TargetLowering is the base class for all backends in Subzero. In addition to |
| 142 /// implementing the abstract methods in this class, each concrete target must |
| 143 /// also implement a named constructor in its own namespace. For instance, for |
| 144 /// X8632 we have: |
| 145 /// |
| 146 /// namespace X8632 { |
| 147 /// void createTargetLowering(Cfg *Func); |
| 148 /// } |
141 class TargetLowering { | 149 class TargetLowering { |
142 TargetLowering() = delete; | 150 TargetLowering() = delete; |
143 TargetLowering(const TargetLowering &) = delete; | 151 TargetLowering(const TargetLowering &) = delete; |
144 TargetLowering &operator=(const TargetLowering &) = delete; | 152 TargetLowering &operator=(const TargetLowering &) = delete; |
145 | 153 |
146 public: | 154 public: |
147 // TODO(jvoung): return a unique_ptr like the other factory functions. | |
148 static TargetLowering *createLowering(TargetArch Target, Cfg *Func); | |
149 static void staticInit(TargetArch Target); | 155 static void staticInit(TargetArch Target); |
150 // Each target must define a public static method: | 156 |
151 // static void staticInit(); | 157 static std::unique_ptr<TargetLowering> createLowering(TargetArch Target, |
152 static std::unique_ptr<Assembler> createAssembler(TargetArch Target, | 158 Cfg *Func); |
153 Cfg *Func); | 159 |
| 160 virtual std::unique_ptr<Assembler> createAssembler() const = 0; |
| 161 |
154 void translate() { | 162 void translate() { |
155 switch (Ctx->getFlags().getOptLevel()) { | 163 switch (Ctx->getFlags().getOptLevel()) { |
156 case Opt_m1: | 164 case Opt_m1: |
157 translateOm1(); | 165 translateOm1(); |
158 break; | 166 break; |
159 case Opt_0: | 167 case Opt_0: |
160 translateO0(); | 168 translateO0(); |
161 break; | 169 break; |
162 case Opt_1: | 170 case Opt_1: |
163 translateO1(); | 171 translateO1(); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 virtual void lower() {} | 486 virtual void lower() {} |
479 | 487 |
480 protected: | 488 protected: |
481 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 489 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
482 GlobalContext *Ctx; | 490 GlobalContext *Ctx; |
483 }; | 491 }; |
484 | 492 |
485 } // end of namespace Ice | 493 } // end of namespace Ice |
486 | 494 |
487 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 495 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |