Skip to content

Commit 02976f5

Browse files
[TableGen] Use "using" instead of "typedef" (NFC) (#167168)
Identified with modernize-use-using.
1 parent 26bb121 commit 02976f5

23 files changed

+78
-81
lines changed

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class AsmMatcherInfo;
141141
// RegisterSets can be seen in the outputted AsmMatcher tables occasionally, and
142142
// can even affect compiler output (at least seen in diagnostics produced when
143143
// all matches fail). So we use a type that sorts them consistently.
144-
typedef std::set<const Record *, LessRecordByID> RegisterSet;
144+
using RegisterSet = std::set<const Record *, LessRecordByID>;
145145

146146
class AsmMatcherEmitter {
147147
const RecordKeeper &Records;
@@ -779,8 +779,8 @@ class AsmMatcherInfo {
779779
std::vector<OperandMatchEntry> OperandMatchInfo;
780780

781781
/// Map of Register records to their class information.
782-
typedef std::map<const Record *, ClassInfo *, LessRecordByID>
783-
RegisterClassesTy;
782+
using RegisterClassesTy =
783+
std::map<const Record *, ClassInfo *, LessRecordByID>;
784784
RegisterClassesTy RegisterClasses;
785785

786786
/// Map of Predicate records to their subtarget information.
@@ -1275,7 +1275,7 @@ void AsmMatcherInfo::buildRegisterClasses(
12751275
const auto &Registers = Target.getRegBank().getRegisters();
12761276
auto &RegClassList = Target.getRegBank().getRegClasses();
12771277

1278-
typedef std::set<RegisterSet, LessRegisterSet> RegisterSetSet;
1278+
using RegisterSetSet = std::set<RegisterSet, LessRegisterSet>;
12791279

12801280
// The register sets used for matching.
12811281
RegisterSetSet RegisterSets;
@@ -1515,7 +1515,7 @@ AsmMatcherInfo::AsmMatcherInfo(const Record *asmParser,
15151515
void AsmMatcherInfo::buildOperandMatchInfo() {
15161516
/// Map containing a mask with all operands indices that can be found for
15171517
/// that class inside a instruction.
1518-
typedef std::map<ClassInfo *, unsigned, deref<std::less<>>> OpClassMaskTy;
1518+
using OpClassMaskTy = std::map<ClassInfo *, unsigned, deref<std::less<>>>;
15191519
OpClassMaskTy OpClassMask;
15201520

15211521
bool CallCustomParserForAllOperands =

llvm/utils/TableGen/AsmWriterEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ static unsigned CountNumOperands(StringRef AsmString, unsigned Variant) {
814814
namespace {
815815

816816
struct AliasPriorityComparator {
817-
typedef std::pair<CodeGenInstAlias, int> ValueType;
817+
using ValueType = std::pair<CodeGenInstAlias, int>;
818818
bool operator()(const ValueType &LHS, const ValueType &RHS) const {
819819
if (LHS.second == RHS.second) {
820820
// We don't actually care about the order, but for consistency it
@@ -845,8 +845,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
845845
bool PassSubtarget = AsmWriter->getValueAsInt("PassSubtarget");
846846

847847
// Create a map from the qualified name to a list of potential matches.
848-
typedef std::set<std::pair<CodeGenInstAlias, int>, AliasPriorityComparator>
849-
AliasWithPriority;
848+
using AliasWithPriority =
849+
std::set<std::pair<CodeGenInstAlias, int>, AliasPriorityComparator>;
850850
std::map<std::string, AliasWithPriority> AliasMap;
851851
for (const Record *R : Records.getAllDerivedDefinitions("InstAlias")) {
852852
int Priority = R->getValueAsInt("EmitPriority");

llvm/utils/TableGen/Basic/SequenceToOffsetTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ inline void printChar(raw_ostream &OS, char C) {
4444
/// @tparam Less A stable comparator for SeqT elements.
4545
template <typename SeqT, typename Less = std::less<typename SeqT::value_type>>
4646
class SequenceToOffsetTable {
47-
typedef typename SeqT::value_type ElemT;
47+
using ElemT = typename SeqT::value_type;
4848

4949
// Define a comparator for SeqT that sorts a suffix immediately before a
5050
// sequence with that suffix.
@@ -58,7 +58,7 @@ class SequenceToOffsetTable {
5858

5959
// Keep sequences ordered according to SeqLess so suffixes are easy to find.
6060
// Map each sequence to its offset in the table.
61-
typedef std::map<SeqT, unsigned, SeqLess> SeqMap;
61+
using SeqMap = std::map<SeqT, unsigned, SeqLess>;
6262

6363
// Sequences added so far, with suffixes removed.
6464
SeqMap Seqs;

llvm/utils/TableGen/CodeGenMapTable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
#include "llvm/TableGen/Record.h"
8585

8686
using namespace llvm;
87-
typedef std::map<std::string, std::vector<const Record *>> InstrRelMapTy;
88-
typedef std::map<std::vector<const Init *>, std::vector<const Record *>>
89-
RowInstrMapTy;
87+
using InstrRelMapTy = std::map<std::string, std::vector<const Record *>>;
88+
using RowInstrMapTy =
89+
std::map<std::vector<const Init *>, std::vector<const Record *>>;
9090

9191
namespace {
9292

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ bool TypeInfer::EnforceSameSize(TypeSetByHwMode &A, TypeSetByHwMode &B) {
776776
if (B.empty())
777777
Changed |= EnforceAny(B);
778778

779-
typedef SmallSet<TypeSize, 2, TypeSizeComparator> TypeSizeSet;
779+
using TypeSizeSet = SmallSet<TypeSize, 2, TypeSizeComparator>;
780780

781781
auto NoSize = [](const TypeSizeSet &Sizes, MVT T) -> bool {
782782
return !Sizes.contains(T.getSizeInBits());
@@ -4129,7 +4129,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
41294129
}
41304130
}
41314131

4132-
typedef std::pair<TreePatternNode *, unsigned> NameRecord;
4132+
using NameRecord = std::pair<TreePatternNode *, unsigned>;
41334133

41344134
static void FindNames(TreePatternNode &P,
41354135
std::map<StringRef, NameRecord> &Names,
@@ -4590,7 +4590,7 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
45904590
}
45914591

45924592
/// Dependent variable map for CodeGenDAGPattern variant generation
4593-
typedef StringMap<int> DepVarMap;
4593+
using DepVarMap = StringMap<int>;
45944594

45954595
static void FindDepVarsOf(TreePatternNode &N, DepVarMap &DepMap) {
45964596
if (N.isLeaf()) {

llvm/utils/TableGen/Common/CodeGenDAGPatterns.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ struct TypeInfer {
349349
};
350350

351351
/// Set type used to track multiply used variables in patterns
352-
typedef StringSet<> MultipleUseVarSet;
352+
using MultipleUseVarSet = StringSet<>;
353353

354354
/// SDTypeConstraint - This is a discriminated union of constraints,
355355
/// corresponding to the SDTypeConstraint tablegen class in Target.td.
@@ -1217,13 +1217,13 @@ class CodeGenDAGPatterns {
12171217
iterator_range<pf_iterator> ptfs() const { return PatternFragments; }
12181218

12191219
// Patterns to match information.
1220-
typedef std::vector<PatternToMatch>::const_iterator ptm_iterator;
1220+
using ptm_iterator = std::vector<PatternToMatch>::const_iterator;
12211221
ptm_iterator ptm_begin() const { return PatternsToMatch.begin(); }
12221222
ptm_iterator ptm_end() const { return PatternsToMatch.end(); }
12231223
iterator_range<ptm_iterator> ptms() const { return PatternsToMatch; }
12241224

12251225
/// Parse the Pattern for an instruction, and insert the result in DAGInsts.
1226-
typedef std::map<const Record *, DAGInstruction, LessRecordByID> DAGInstMap;
1226+
using DAGInstMap = std::map<const Record *, DAGInstruction, LessRecordByID>;
12271227
void parseInstructionPattern(CodeGenInstruction &CGI, const ListInit *Pattern,
12281228
DAGInstMap &DAGInsts);
12291229

llvm/utils/TableGen/Common/CodeGenHwModes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct HwMode {
3636

3737
struct HwModeSelect {
3838
HwModeSelect(const Record *R, CodeGenHwModes &CGH);
39-
typedef std::pair<unsigned, const Record *> PairType;
39+
using PairType = std::pair<unsigned, const Record *>;
4040
std::vector<PairType> Items;
4141
void dump() const;
4242
};

llvm/utils/TableGen/Common/CodeGenInstruction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ class CGIOperandList {
158158
OperandInfo &back() { return OperandList.back(); }
159159
const OperandInfo &back() const { return OperandList.back(); }
160160

161-
typedef std::vector<OperandInfo>::iterator iterator;
162-
typedef std::vector<OperandInfo>::const_iterator const_iterator;
161+
using iterator = std::vector<OperandInfo>::iterator;
162+
using const_iterator = std::vector<OperandInfo>::const_iterator;
163163
iterator begin() { return OperandList.begin(); }
164164
const_iterator begin() const { return OperandList.begin(); }
165165
iterator end() { return OperandList.end(); }

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,7 @@ void CodeGenRegBank::computeRegUnitLaneMasks() {
21632163
CodeGenRegister::RegUnitLaneMaskList RegUnitLaneMasks(
21642164
RegUnits.count(), LaneBitmask::getAll());
21652165
// Iterate through SubRegisters.
2166-
typedef CodeGenRegister::SubRegMap SubRegMap;
2166+
using SubRegMap = CodeGenRegister::SubRegMap;
21672167
const SubRegMap &SubRegs = Register.getSubRegs();
21682168
for (auto [SubRegIndex, SubReg] : SubRegs) {
21692169
// Ignore non-leaf subregisters, their lane masks are fully covered by
@@ -2282,9 +2282,8 @@ void CodeGenRegBank::inferCommonSubClass(CodeGenRegisterClass *RC) {
22822282
//
22832283
void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
22842284
// Map SubRegIndex to set of registers in RC supporting that SubRegIndex.
2285-
typedef std::map<const CodeGenSubRegIndex *, CodeGenRegister::Vec,
2286-
deref<std::less<>>>
2287-
SubReg2SetMap;
2285+
using SubReg2SetMap = std::map<const CodeGenSubRegIndex *,
2286+
CodeGenRegister::Vec, deref<std::less<>>>;
22882287

22892288
// Compute the set of registers supporting each SubRegIndex.
22902289
SubReg2SetMap SRSets;

llvm/utils/TableGen/Common/CodeGenRegisters.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ class CodeGenSubRegIndex {
9393
std::string getQualifiedName() const;
9494

9595
// Map of composite subreg indices.
96-
typedef std::map<CodeGenSubRegIndex *, CodeGenSubRegIndex *,
97-
deref<std::less<>>>
98-
CompMap;
96+
using CompMap =
97+
std::map<CodeGenSubRegIndex *, CodeGenSubRegIndex *, deref<std::less<>>>;
9998

10099
// Returns the subreg index that results from composing this with Idx.
101100
// Returns NULL if this and Idx don't compose.
@@ -180,8 +179,8 @@ class CodeGenRegister {
180179
bool Constant = false;
181180

182181
// Map SubRegIndex -> Register.
183-
typedef std::map<CodeGenSubRegIndex *, CodeGenRegister *, deref<std::less<>>>
184-
SubRegMap;
182+
using SubRegMap =
183+
std::map<CodeGenSubRegIndex *, CodeGenRegister *, deref<std::less<>>>;
185184

186185
CodeGenRegister(const Record *R, unsigned Enum);
187186

@@ -220,7 +219,7 @@ class CodeGenRegister {
220219
return SubReg2Idx.lookup(Reg);
221220
}
222221

223-
typedef std::vector<const CodeGenRegister *> SuperRegList;
222+
using SuperRegList = std::vector<const CodeGenRegister *>;
224223

225224
// Get the list of super-registers in topological order, small to large.
226225
// This is valid after computeSubRegs visits all registers during RegBank
@@ -248,8 +247,8 @@ class CodeGenRegister {
248247
}
249248

250249
// List of register units in ascending order.
251-
typedef SparseBitVector<> RegUnitList;
252-
typedef SmallVector<LaneBitmask, 16> RegUnitLaneMaskList;
250+
using RegUnitList = SparseBitVector<>;
251+
using RegUnitLaneMaskList = SmallVector<LaneBitmask, 16>;
253252

254253
// How many entries in RegUnitList are native?
255254
RegUnitList NativeRegUnits;
@@ -281,7 +280,7 @@ class CodeGenRegister {
281280
unsigned getWeight(const CodeGenRegBank &RegBank) const;
282281

283282
// Canonically ordered set.
284-
typedef std::vector<const CodeGenRegister *> Vec;
283+
using Vec = std::vector<const CodeGenRegister *>;
285284

286285
private:
287286
bool SubRegsComplete;
@@ -590,7 +589,7 @@ struct RegUnit {
590589

591590
// Each RegUnitSet is a sorted vector with a name.
592591
struct RegUnitSet {
593-
typedef std::vector<unsigned>::const_iterator iterator;
592+
using iterator = std::vector<unsigned>::const_iterator;
594593

595594
std::string Name;
596595
std::vector<unsigned> Units;
@@ -602,7 +601,7 @@ struct RegUnitSet {
602601

603602
// Base vector for identifying TopoSigs. The contents uniquely identify a
604603
// TopoSig, only computeSuperRegs needs to know how.
605-
typedef SmallVector<unsigned, 16> TopoSigId;
604+
using TopoSigId = SmallVector<unsigned, 16>;
606605

607606
// CodeGenRegBank - Represent a target's registers and the relations between
608607
// them.
@@ -621,8 +620,8 @@ class CodeGenRegBank {
621620

622621
CodeGenSubRegIndex *createSubRegIndex(StringRef Name, StringRef NameSpace);
623622

624-
typedef std::map<SmallVector<CodeGenSubRegIndex *, 8>, CodeGenSubRegIndex *>
625-
ConcatIdxMap;
623+
using ConcatIdxMap =
624+
std::map<SmallVector<CodeGenSubRegIndex *, 8>, CodeGenSubRegIndex *>;
626625
ConcatIdxMap ConcatIdx;
627626

628627
// Registers.
@@ -639,7 +638,7 @@ class CodeGenRegBank {
639638
// Register classes.
640639
std::list<CodeGenRegisterClass> RegClasses;
641640
DenseMap<const Record *, CodeGenRegisterClass *> Def2RC;
642-
typedef std::map<CodeGenRegisterClass::Key, CodeGenRegisterClass *> RCKeyMap;
641+
using RCKeyMap = std::map<CodeGenRegisterClass::Key, CodeGenRegisterClass *>;
643642
RCKeyMap Key2RC;
644643

645644
// Register categories.

0 commit comments

Comments
 (0)