Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: src/IceTargetLowering.h

Issue 1197223002: Subzero: Use C++11 member initializers where practical. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceRegAlloc.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file declares the TargetLowering, LoweringContext, and 10 // This file declares the TargetLowering, LoweringContext, and
(...skipping 21 matching lines...) Expand all
32 // instructions in a node, and insert new (lowered) instructions at 32 // instructions in a node, and insert new (lowered) instructions at
33 // the current point. Along with the instruction list container and 33 // the current point. Along with the instruction list container and
34 // associated iterators, it holds the current node, which is needed 34 // associated iterators, it holds the current node, which is needed
35 // when inserting new instructions in order to track whether variables 35 // when inserting new instructions in order to track whether variables
36 // are used as single-block or multi-block. 36 // are used as single-block or multi-block.
37 class LoweringContext { 37 class LoweringContext {
38 LoweringContext(const LoweringContext &) = delete; 38 LoweringContext(const LoweringContext &) = delete;
39 LoweringContext &operator=(const LoweringContext &) = delete; 39 LoweringContext &operator=(const LoweringContext &) = delete;
40 40
41 public: 41 public:
42 LoweringContext() : Node(nullptr), LastInserted(nullptr) {} 42 LoweringContext() = default;
43 ~LoweringContext() {} 43 ~LoweringContext() = default;
44 void init(CfgNode *Node); 44 void init(CfgNode *Node);
45 Inst *getNextInst() const { 45 Inst *getNextInst() const {
46 if (Next == End) 46 if (Next == End)
47 return nullptr; 47 return nullptr;
48 return Next; 48 return Next;
49 } 49 }
50 Inst *getNextInst(InstList::iterator &Iter) const { 50 Inst *getNextInst(InstList::iterator &Iter) const {
51 advanceForward(Iter); 51 advanceForward(Iter);
52 if (Iter == End) 52 if (Iter == End)
53 return nullptr; 53 return nullptr;
54 return Iter; 54 return Iter;
55 } 55 }
56 CfgNode *getNode() const { return Node; } 56 CfgNode *getNode() const { return Node; }
57 bool atEnd() const { return Cur == End; } 57 bool atEnd() const { return Cur == End; }
58 InstList::iterator getCur() const { return Cur; } 58 InstList::iterator getCur() const { return Cur; }
59 InstList::iterator getNext() const { return Next; } 59 InstList::iterator getNext() const { return Next; }
60 InstList::iterator getEnd() const { return End; } 60 InstList::iterator getEnd() const { return End; }
61 void insert(Inst *Inst); 61 void insert(Inst *Inst);
62 Inst *getLastInserted() const; 62 Inst *getLastInserted() const;
63 void advanceCur() { Cur = Next; } 63 void advanceCur() { Cur = Next; }
64 void advanceNext() { advanceForward(Next); } 64 void advanceNext() { advanceForward(Next); }
65 void rewind(); 65 void rewind();
66 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } 66 void setInsertPoint(const InstList::iterator &Position) { Next = Position; }
67 67
68 private: 68 private:
69 // Node is the argument to Inst::updateVars(). 69 // Node is the argument to Inst::updateVars().
70 CfgNode *Node; 70 CfgNode *Node = nullptr;
71 Inst *LastInserted; 71 Inst *LastInserted = nullptr;
72 // Cur points to the current instruction being considered. It is 72 // Cur points to the current instruction being considered. It is
73 // guaranteed to point to a non-deleted instruction, or to be End. 73 // guaranteed to point to a non-deleted instruction, or to be End.
74 InstList::iterator Cur; 74 InstList::iterator Cur;
75 // Next doubles as a pointer to the next valid instruction (if any), 75 // Next doubles as a pointer to the next valid instruction (if any),
76 // and the new-instruction insertion point. It is also updated for 76 // and the new-instruction insertion point. It is also updated for
77 // the caller in case the lowering consumes more than one high-level 77 // the caller in case the lowering consumes more than one high-level
78 // instruction. It is guaranteed to point to a non-deleted 78 // instruction. It is guaranteed to point to a non-deleted
79 // instruction after Cur, or to be End. TODO: Consider separating 79 // instruction after Cur, or to be End. TODO: Consider separating
80 // the notion of "next valid instruction" and "new instruction 80 // the notion of "next valid instruction" and "new instruction
81 // insertion point", to avoid confusion when previously-deleted 81 // insertion point", to avoid confusion when previously-deleted
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 virtual void emit(const ConstantFloat *C) const = 0; 219 virtual void emit(const ConstantFloat *C) const = 0;
220 virtual void emit(const ConstantDouble *C) const = 0; 220 virtual void emit(const ConstantDouble *C) const = 0;
221 221
222 // Performs target-specific argument lowering. 222 // Performs target-specific argument lowering.
223 virtual void lowerArguments() = 0; 223 virtual void lowerArguments() = 0;
224 224
225 virtual void initNodeForLowering(CfgNode *) {} 225 virtual void initNodeForLowering(CfgNode *) {}
226 virtual void addProlog(CfgNode *Node) = 0; 226 virtual void addProlog(CfgNode *Node) = 0;
227 virtual void addEpilog(CfgNode *Node) = 0; 227 virtual void addEpilog(CfgNode *Node) = 0;
228 228
229 virtual ~TargetLowering() {} 229 virtual ~TargetLowering() = default;
230 230
231 protected: 231 protected:
232 explicit TargetLowering(Cfg *Func); 232 explicit TargetLowering(Cfg *Func);
233 virtual void lowerAlloca(const InstAlloca *Inst) = 0; 233 virtual void lowerAlloca(const InstAlloca *Inst) = 0;
234 virtual void lowerArithmetic(const InstArithmetic *Inst) = 0; 234 virtual void lowerArithmetic(const InstArithmetic *Inst) = 0;
235 virtual void lowerAssign(const InstAssign *Inst) = 0; 235 virtual void lowerAssign(const InstAssign *Inst) = 0;
236 virtual void lowerBr(const InstBr *Inst) = 0; 236 virtual void lowerBr(const InstBr *Inst) = 0;
237 virtual void lowerCall(const InstCall *Inst) = 0; 237 virtual void lowerCall(const InstCall *Inst) = 0;
238 virtual void lowerCast(const InstCast *Inst) = 0; 238 virtual void lowerCast(const InstCast *Inst) = 0;
239 virtual void lowerFcmp(const InstFcmp *Inst) = 0; 239 virtual void lowerFcmp(const InstFcmp *Inst) = 0;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 SizeT MaxSrcs); 316 SizeT MaxSrcs);
317 317
318 void 318 void
319 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) { 319 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) {
320 Context.insert(InstBundleLock::create(Func, BundleOption)); 320 Context.insert(InstBundleLock::create(Func, BundleOption));
321 } 321 }
322 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); } 322 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); }
323 323
324 Cfg *Func; 324 Cfg *Func;
325 GlobalContext *Ctx; 325 GlobalContext *Ctx;
326 bool HasComputedFrame; 326 bool HasComputedFrame = false;
327 bool CallsReturnsTwice; 327 bool CallsReturnsTwice = false;
328 // StackAdjustment keeps track of the current stack offset from its 328 // StackAdjustment keeps track of the current stack offset from its
329 // natural location, as arguments are pushed for a function call. 329 // natural location, as arguments are pushed for a function call.
330 int32_t StackAdjustment; 330 int32_t StackAdjustment = 0;
331 SizeT NextLabelNumber; 331 SizeT NextLabelNumber = 0;
332 LoweringContext Context; 332 LoweringContext Context;
333 333
334 // Runtime helper function names 334 // Runtime helper function names
335 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; 335 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16";
336 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; 336 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8";
337 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; 337 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1";
338 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; 338 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1";
339 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; 339 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2";
340 const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; 340 const static constexpr char *H_call_ctpop_i64 = "__popcountdi2";
341 const static constexpr char *H_call_longjmp = "longjmp"; 341 const static constexpr char *H_call_longjmp = "longjmp";
(...skipping 17 matching lines...) Expand all
359 const static constexpr char *H_srem_i64 = "__moddi3"; 359 const static constexpr char *H_srem_i64 = "__moddi3";
360 const static constexpr char *H_udiv_i64 = "__udivdi3"; 360 const static constexpr char *H_udiv_i64 = "__udivdi3";
361 const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32"; 361 const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32";
362 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; 362 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32";
363 const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64"; 363 const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64";
364 const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32"; 364 const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32";
365 const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64"; 365 const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64";
366 const static constexpr char *H_urem_i64 = "__umoddi3"; 366 const static constexpr char *H_urem_i64 = "__umoddi3";
367 367
368 private: 368 private:
369 int32_t SnapshotStackAdjustment; 369 int32_t SnapshotStackAdjustment = 0;
370 }; 370 };
371 371
372 // TargetDataLowering is used for "lowering" data including initializers 372 // TargetDataLowering is used for "lowering" data including initializers
373 // for global variables, and the internal constant pools. It is separated 373 // for global variables, and the internal constant pools. It is separated
374 // out from TargetLowering because it does not require a Cfg. 374 // out from TargetLowering because it does not require a Cfg.
375 class TargetDataLowering { 375 class TargetDataLowering {
376 TargetDataLowering() = delete; 376 TargetDataLowering() = delete;
377 TargetDataLowering(const TargetDataLowering &) = delete; 377 TargetDataLowering(const TargetDataLowering &) = delete;
378 TargetDataLowering &operator=(const TargetDataLowering &) = delete; 378 TargetDataLowering &operator=(const TargetDataLowering &) = delete;
379 379
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 virtual void lower() {} 414 virtual void lower() {}
415 415
416 protected: 416 protected:
417 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 417 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
418 GlobalContext *Ctx; 418 GlobalContext *Ctx;
419 }; 419 };
420 420
421 } // end of namespace Ice 421 } // end of namespace Ice
422 422
423 #endif // SUBZERO_SRC_ICETARGETLOWERING_H 423 #endif // SUBZERO_SRC_ICETARGETLOWERING_H
OLDNEW
« no previous file with comments | « src/IceRegAlloc.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698