OSDN Git Service

Subzero: Cleanup Inst==>Instr.
[android-x86/external-swiftshader.git] / src / IceSwitchLowering.h
index e1cdb8a..5b9f673 100644 (file)
@@ -8,7 +8,8 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// \brief The file contains helpers for switch lowering.
+/// \brief Helpers for switch lowering.
+///
 //===----------------------------------------------------------------------===//
 
 #ifndef SUBZERO_SRC_ICESWITCHLOWERING_H
@@ -20,8 +21,7 @@ namespace Ice {
 
 class CaseCluster;
 
-using CaseClusterArray =
-    std::vector<CaseCluster, CfgLocalAllocator<CaseCluster>>;
+using CaseClusterArray = CfgVector<CaseCluster>;
 
 /// A cluster of cases can be tested by a common method during switch lowering.
 class CaseCluster {
@@ -60,7 +60,7 @@ public:
 
   /// Discover cases which can be clustered together and return the clusters
   /// ordered by case value.
-  static CaseClusterArray clusterizeSwitch(Cfg *Func, const InstSwitch *Inst);
+  static CaseClusterArray clusterizeSwitch(Cfg *Func, const InstSwitch *Instr);
 
 private:
   CaseClusterKind Kind;
@@ -75,33 +75,30 @@ private:
   bool tryAppend(const CaseCluster &New);
 };
 
-/// Store the jump table data so that it can be emitted later in the correct
-/// ELF section once the offsets from the start of the function are known.
+/// Store the jump table data so that it can be emitted later in the correct ELF
+/// section once the offsets from the start of the function are known.
 class JumpTableData {
   JumpTableData() = delete;
   JumpTableData &operator=(const JumpTableData &) = delete;
 
 public:
-  JumpTableData(IceString FuncName, SizeT Id, SizeT NumTargets)
-      : FuncName(FuncName), Id(Id) {
-    TargetOffsets.reserve(NumTargets);
-  }
+  using TargetList = std::vector<intptr_t>;
+
+  JumpTableData(const IceString &FuncName, SizeT Id,
+                const TargetList &TargetOffsets)
+      : FuncName(FuncName), Id(Id), TargetOffsets(TargetOffsets) {}
   JumpTableData(const JumpTableData &) = default;
   JumpTableData(JumpTableData &&) = default;
   JumpTableData &operator=(JumpTableData &&) = default;
 
-  void pushTarget(intptr_t Offset) { TargetOffsets.emplace_back(Offset); }
-
   const IceString &getFunctionName() const { return FuncName; }
   SizeT getId() const { return Id; }
-  const std::vector<intptr_t> &getTargetOffsets() const {
-    return TargetOffsets;
-  }
+  const TargetList &getTargetOffsets() const { return TargetOffsets; }
 
 private:
   IceString FuncName;
   SizeT Id;
-  std::vector<intptr_t> TargetOffsets;
+  TargetList TargetOffsets;
 };
 
 using JumpTableDataList = std::vector<JumpTableData>;