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

Side by Side Diff: src/IceSwitchLowering.h

Issue 1860473002: Subzero. Refactors Switch Lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: git pull Created 4 years, 8 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/IceInst.cpp ('k') | src/IceSwitchLowering.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/IceSwitchLowering.h - Switch lowering --------*- C++ -*-===// 1 //===- subzero/src/IceSwitchLowering.h - Switch lowering --------*- C++ -*-===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
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 /// \brief Helpers for switch lowering. 11 /// \brief Helpers for switch lowering.
12 /// 12 ///
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICESWITCHLOWERING_H 15 #ifndef SUBZERO_SRC_ICESWITCHLOWERING_H
16 #define SUBZERO_SRC_ICESWITCHLOWERING_H 16 #define SUBZERO_SRC_ICESWITCHLOWERING_H
17 17
18 #include "IceDefs.h" 18 #include "IceDefs.h"
19 #include "IceStringPool.h" 19 #include "IceStringPool.h"
20 20
21 #include <string>
22
21 namespace Ice { 23 namespace Ice {
22 24
23 class CaseCluster; 25 class CaseCluster;
24 26
25 using CaseClusterArray = CfgVector<CaseCluster>; 27 using CaseClusterArray = CfgVector<CaseCluster>;
26 28
27 /// A cluster of cases can be tested by a common method during switch lowering. 29 /// A cluster of cases can be tested by a common method during switch lowering.
28 class CaseCluster { 30 class CaseCluster {
29 CaseCluster() = delete; 31 CaseCluster() = delete;
30 32
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 80
79 /// Store the jump table data so that it can be emitted later in the correct ELF 81 /// Store the jump table data so that it can be emitted later in the correct ELF
80 /// section once the offsets from the start of the function are known. 82 /// section once the offsets from the start of the function are known.
81 class JumpTableData { 83 class JumpTableData {
82 JumpTableData() = delete; 84 JumpTableData() = delete;
83 JumpTableData &operator=(const JumpTableData &) = delete; 85 JumpTableData &operator=(const JumpTableData &) = delete;
84 86
85 public: 87 public:
86 using TargetList = std::vector<intptr_t>; 88 using TargetList = std::vector<intptr_t>;
87 89
88 JumpTableData(GlobalString FuncName, SizeT Id, 90 JumpTableData(GlobalString Name, GlobalString FuncName, SizeT Id,
89 const TargetList &TargetOffsets) 91 const TargetList &TargetOffsets)
90 : FuncName(FuncName), Id(Id), TargetOffsets(TargetOffsets) {} 92 : Name(Name), FuncName(FuncName), Id(Id), TargetOffsets(TargetOffsets) {}
91 JumpTableData(const JumpTableData &) = default; 93 JumpTableData(const JumpTableData &) = default;
92 JumpTableData(JumpTableData &&) = default; 94 JumpTableData(JumpTableData &&) = default;
93 JumpTableData &operator=(JumpTableData &&) = default; 95 JumpTableData &operator=(JumpTableData &&) = default;
94 96
95 const GlobalString getFunctionName() const { return FuncName; } 97 GlobalString getName() const { return Name; }
98 GlobalString getFunctionName() const { return FuncName; }
96 SizeT getId() const { return Id; } 99 SizeT getId() const { return Id; }
97 const TargetList &getTargetOffsets() const { return TargetOffsets; } 100 const TargetList &getTargetOffsets() const { return TargetOffsets; }
101 static std::string createSectionName(const GlobalString Name) {
102 if (Name.hasStdString()) {
103 return Name.toString() + "$jumptable";
104 }
105 return std::to_string(Name.getID()) + "$jumptable";
106 }
107 std::string getSectionName() const { return createSectionName(FuncName); }
98 108
99 private: 109 private:
110 GlobalString Name;
100 GlobalString FuncName; 111 GlobalString FuncName;
101 SizeT Id; 112 SizeT Id;
102 TargetList TargetOffsets; 113 TargetList TargetOffsets;
103 }; 114 };
104 115
105 using JumpTableDataList = std::vector<JumpTableData>; 116 using JumpTableDataList = std::vector<JumpTableData>;
106 117
107 } // end of namespace Ice 118 } // end of namespace Ice
108 119
109 #endif // SUBZERO_SRC_ICESWITCHLOWERING_H 120 #endif // SUBZERO_SRC_ICESWITCHLOWERING_H
OLDNEW
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceSwitchLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698