Skip to content

Commit 39ad315

Browse files
authored
[TableGen] Use default member initializers. NFC. (#144349)
Automated with clang-tidy -fix -checks=-*,modernize-use-default-member-init
1 parent a54712c commit 39ad315

10 files changed

+45
-55
lines changed

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ struct MatchableInfo {
388388
StringRef Token;
389389

390390
/// The unique class instance this operand should match.
391-
ClassInfo *Class;
391+
ClassInfo *Class = nullptr;
392392

393393
/// The operand name this is, if anything.
394394
StringRef SrcOpName;
@@ -397,18 +397,17 @@ struct MatchableInfo {
397397
StringRef OrigSrcOpName;
398398

399399
/// The suboperand index within SrcOpName, or -1 for the entire operand.
400-
int SubOpIdx;
400+
int SubOpIdx = -1;
401401

402402
/// Whether the token is "isolated", i.e., it is preceded and followed
403403
/// by separators.
404404
bool IsIsolatedToken;
405405

406406
/// Register record if this token is singleton register.
407-
const Record *SingletonReg;
407+
const Record *SingletonReg = nullptr;
408408

409409
explicit AsmOperand(bool IsIsolatedToken, StringRef T)
410-
: Token(T), Class(nullptr), SubOpIdx(-1),
411-
IsIsolatedToken(IsIsolatedToken), SingletonReg(nullptr) {}
410+
: Token(T), IsIsolatedToken(IsIsolatedToken) {}
412411
};
413412

414413
/// ResOperand - This represents a single operand in the result instruction

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3604,16 +3604,14 @@ class InstAnalyzer {
36043604
const CodeGenDAGPatterns &CDP;
36053605

36063606
public:
3607-
bool hasSideEffects;
3608-
bool mayStore;
3609-
bool mayLoad;
3610-
bool isBitcast;
3611-
bool isVariadic;
3612-
bool hasChain;
3613-
3614-
InstAnalyzer(const CodeGenDAGPatterns &cdp)
3615-
: CDP(cdp), hasSideEffects(false), mayStore(false), mayLoad(false),
3616-
isBitcast(false), isVariadic(false), hasChain(false) {}
3607+
bool hasSideEffects = false;
3608+
bool mayStore = false;
3609+
bool mayLoad = false;
3610+
bool isBitcast = false;
3611+
bool isVariadic = false;
3612+
bool hasChain = false;
3613+
3614+
InstAnalyzer(const CodeGenDAGPatterns &cdp) : CDP(cdp) {}
36173615

36183616
void Analyze(const PatternToMatch &Pat) {
36193617
const TreePatternNode &N = Pat.getSrcPattern();

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ CodeGenRegister::CodeGenRegister(const Record *R, unsigned Enum)
164164
: TheDef(R), EnumValue(Enum),
165165
CostPerUse(R->getValueAsListOfInts("CostPerUse")),
166166
CoveredBySubRegs(R->getValueAsBit("CoveredBySubRegs")),
167-
HasDisjunctSubRegs(false), Constant(R->getValueAsBit("isConstant")),
168-
SubRegsComplete(false), SuperRegsComplete(false), TopoSig(~0u) {
167+
Constant(R->getValueAsBit("isConstant")), SubRegsComplete(false),
168+
SuperRegsComplete(false), TopoSig(~0u) {
169169
Artificial = R->getValueAsBit("isArtificial");
170170
}
171171

llvm/utils/TableGen/Common/CodeGenRegisters.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ struct RegUnit {
564564
// Weight assigned to this RegUnit for estimating register pressure.
565565
// This is useful when equalizing weights in register classes with mixed
566566
// register topologies.
567-
unsigned Weight;
567+
unsigned Weight = 0;
568568

569569
// Each native RegUnit corresponds to one or two root registers. The full
570570
// set of registers containing this unit can be computed as the union of
@@ -573,14 +573,12 @@ struct RegUnit {
573573

574574
// Index into RegClassUnitSets where we can find the list of UnitSets that
575575
// contain this unit.
576-
unsigned RegClassUnitSetsIdx;
576+
unsigned RegClassUnitSetsIdx = 0;
577577
// A register unit is artificial if at least one of its roots is
578578
// artificial.
579-
bool Artificial;
579+
bool Artificial = false;
580580

581-
RegUnit() : Weight(0), RegClassUnitSetsIdx(0), Artificial(false) {
582-
Roots[0] = Roots[1] = nullptr;
583-
}
581+
RegUnit() { Roots[0] = Roots[1] = nullptr; }
584582

585583
ArrayRef<const CodeGenRegister *> getRoots() const {
586584
assert(!(Roots[1] && !Roots[0]) && "Invalid roots array");

llvm/utils/TableGen/Common/CodeGenSchedule.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ struct CodeGenRegisterFile {
193193
unsigned MaxMovesEliminatedPerCycle;
194194
bool AllowZeroMoveEliminationOnly;
195195

196-
unsigned NumPhysRegs;
196+
unsigned NumPhysRegs = 0;
197197
std::vector<CodeGenRegisterCost> Costs;
198198

199199
CodeGenRegisterFile(StringRef name, const Record *def,
200200
unsigned MaxMoveElimPerCy = 0,
201201
bool AllowZeroMoveElimOnly = false)
202202
: Name(name), RegisterFileDef(def),
203203
MaxMovesEliminatedPerCycle(MaxMoveElimPerCy),
204-
AllowZeroMoveEliminationOnly(AllowZeroMoveElimOnly), NumPhysRegs(0) {}
204+
AllowZeroMoveEliminationOnly(AllowZeroMoveElimOnly) {}
205205

206206
bool hasDefaultCosts() const { return Costs.empty(); }
207207
};
@@ -261,16 +261,16 @@ struct CodeGenProcModel {
261261
std::vector<CodeGenRegisterFile> RegisterFiles;
262262

263263
// Optional Retire Control Unit definition.
264-
const Record *RetireControlUnit;
264+
const Record *RetireControlUnit = nullptr;
265265

266266
// Load/Store queue descriptors.
267-
const Record *LoadQueue;
268-
const Record *StoreQueue;
267+
const Record *LoadQueue = nullptr;
268+
const Record *StoreQueue = nullptr;
269269

270270
CodeGenProcModel(unsigned Idx, std::string Name, const Record *MDef,
271271
const Record *IDef)
272-
: Index(Idx), ModelName(std::move(Name)), ModelDef(MDef), ItinsDef(IDef),
273-
RetireControlUnit(nullptr), LoadQueue(nullptr), StoreQueue(nullptr) {}
272+
: Index(Idx), ModelName(std::move(Name)), ModelDef(MDef), ItinsDef(IDef) {
273+
}
274274

275275
bool hasItineraries() const {
276276
return !ItinsDef->getValueAsListOfDefs("IID").empty();

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ class RuleMatcher : public Matcher {
501501

502502
/// ID for the next instruction variable defined with
503503
/// implicitlyDefineInsnVar()
504-
unsigned NextInsnVarID;
504+
unsigned NextInsnVarID = 0;
505505

506506
/// ID for the next output instruction allocated with allocateOutputInsnID()
507-
unsigned NextOutputInsnID;
507+
unsigned NextOutputInsnID = 0;
508508

509509
/// ID for the next temporary register ID allocated with allocateTempRegID()
510-
unsigned NextTempRegID;
510+
unsigned NextTempRegID = 0;
511511

512512
/// ID for the next recorded type. Starts at -1 and counts down.
513513
TempTypeIdx NextTempTypeIdx = -1;
@@ -545,9 +545,7 @@ class RuleMatcher : public Matcher {
545545
StringRef FlagName, GISelFlags FlagBit);
546546

547547
public:
548-
RuleMatcher(ArrayRef<SMLoc> SrcLoc)
549-
: NextInsnVarID(0), NextOutputInsnID(0), NextTempRegID(0), SrcLoc(SrcLoc),
550-
RuleID(NextRuleID++) {}
548+
RuleMatcher(ArrayRef<SMLoc> SrcLoc) : SrcLoc(SrcLoc), RuleID(NextRuleID++) {}
551549
RuleMatcher(RuleMatcher &&Other) = default;
552550
RuleMatcher &operator=(RuleMatcher &&Other) = default;
553551

@@ -2039,12 +2037,12 @@ class CopyConstantAsImmRenderer : public OperandRenderer {
20392037
unsigned NewInsnID;
20402038
/// The name of the operand.
20412039
const std::string SymbolicName;
2042-
bool Signed;
2040+
bool Signed = true;
20432041

20442042
public:
20452043
CopyConstantAsImmRenderer(unsigned NewInsnID, StringRef SymbolicName)
20462044
: OperandRenderer(OR_CopyConstantAsImm), NewInsnID(NewInsnID),
2047-
SymbolicName(SymbolicName), Signed(true) {}
2045+
SymbolicName(SymbolicName) {}
20482046

20492047
static bool classof(const OperandRenderer *R) {
20502048
return R->getKind() == OR_CopyConstantAsImm;
@@ -2359,7 +2357,7 @@ class BuildMIAction : public MatchAction {
23592357
private:
23602358
unsigned InsnID;
23612359
const CodeGenInstruction *I;
2362-
InstructionMatcher *Matched;
2360+
InstructionMatcher *Matched = nullptr;
23632361
std::vector<std::unique_ptr<OperandRenderer>> OperandRenderers;
23642362
SmallPtrSet<const Record *, 4> DeadImplicitDefs;
23652363

@@ -2372,7 +2370,7 @@ class BuildMIAction : public MatchAction {
23722370

23732371
public:
23742372
BuildMIAction(unsigned InsnID, const CodeGenInstruction *I)
2375-
: MatchAction(AK_BuildMI), InsnID(InsnID), I(I), Matched(nullptr) {}
2373+
: MatchAction(AK_BuildMI), InsnID(InsnID), I(I) {}
23762374

23772375
static bool classof(const MatchAction *A) {
23782376
return A->getKind() == AK_BuildMI;

llvm/utils/TableGen/Common/PredicateExpander.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ namespace llvm {
2525
class Record;
2626

2727
class PredicateExpander {
28-
bool EmitCallsByRef;
29-
bool NegatePredicate;
30-
bool ExpandForMC;
28+
bool EmitCallsByRef = true;
29+
bool NegatePredicate = false;
30+
bool ExpandForMC = false;
3131
StringRef TargetName;
3232

3333
PredicateExpander(const PredicateExpander &) = delete;
@@ -38,8 +38,7 @@ class PredicateExpander {
3838

3939
public:
4040
explicit PredicateExpander(StringRef Target, unsigned Indent = 1)
41-
: EmitCallsByRef(true), NegatePredicate(false), ExpandForMC(false),
42-
TargetName(Target), Indent(Indent, 2) {}
41+
: TargetName(Target), Indent(Indent, 2) {}
4342
bool isByRef() const { return EmitCallsByRef; }
4443
bool shouldNegate() const { return NegatePredicate; }
4544
bool shouldExpandForMC() const { return ExpandForMC; }

llvm/utils/TableGen/DAGISelMatcherGen.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class MatcherGen {
7676
/// NextRecordedOperandNo - As we emit opcodes to record matched values in
7777
/// the RecordedNodes array, this keeps track of which slot will be next to
7878
/// record into.
79-
unsigned NextRecordedOperandNo;
79+
unsigned NextRecordedOperandNo = 0;
8080

8181
/// MatchedChainNodes - This maintains the position in the recorded nodes
8282
/// array of all of the recorded input nodes that have chains.
@@ -94,11 +94,11 @@ class MatcherGen {
9494
SmallVector<std::pair<const Record *, unsigned>, 2> PhysRegInputs;
9595

9696
/// Matcher - This is the top level of the generated matcher, the result.
97-
Matcher *TheMatcher;
97+
Matcher *TheMatcher = nullptr;
9898

9999
/// CurPredicate - As we emit matcher nodes, this points to the latest check
100100
/// which should have future checks stuck into its Next position.
101-
Matcher *CurPredicate;
101+
Matcher *CurPredicate = nullptr;
102102

103103
public:
104104
MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp);
@@ -147,8 +147,7 @@ class MatcherGen {
147147

148148
MatcherGen::MatcherGen(const PatternToMatch &pattern,
149149
const CodeGenDAGPatterns &cgp)
150-
: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), TheMatcher(nullptr),
151-
CurPredicate(nullptr) {
150+
: Pattern(pattern), CGP(cgp) {
152151
// We need to produce the matcher tree for the patterns source pattern. To
153152
// do this we need to match the structure as well as the types. To do the
154153
// type matching, we want to figure out the fewest number of type checks we

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ struct OperandInfo {
104104
std::vector<EncodingField> Fields;
105105
std::string Decoder;
106106
bool HasCompleteDecoder;
107-
uint64_t InitValue;
107+
uint64_t InitValue = 0;
108108

109-
OperandInfo(std::string D, bool HCD)
110-
: Decoder(D), HasCompleteDecoder(HCD), InitValue(0) {}
109+
OperandInfo(std::string D, bool HCD) : Decoder(D), HasCompleteDecoder(HCD) {}
111110

112111
void addField(unsigned Base, unsigned Width, unsigned Offset) {
113112
Fields.push_back(EncodingField(Base, Width, Offset));

llvm/utils/TableGen/FastISelEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ namespace {
8686
struct OperandsSignature {
8787
class OpKind {
8888
enum { OK_Reg, OK_FP, OK_Imm, OK_Invalid = -1 };
89-
char Repr;
89+
char Repr = OK_Invalid;
9090

9191
public:
92-
OpKind() : Repr(OK_Invalid) {}
92+
OpKind() {}
9393

9494
bool operator<(OpKind RHS) const { return Repr < RHS.Repr; }
9595
bool operator==(OpKind RHS) const { return Repr == RHS.Repr; }

0 commit comments

Comments
 (0)