//===----------------------------------------------------------------------===//
///
/// \file
-/// \brief The file contains helpers for switch lowering.
+/// \brief Helpers for switch lowering.
+///
//===----------------------------------------------------------------------===//
#ifndef SUBZERO_SRC_ICESWITCHLOWERING_H
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 {
/// 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;
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>;