Skip to content

[TableGen][GISel][NFC] clang-tidy GlobalISelEmitter.cpp #90492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@
#include "llvm/Support/CodeGenCoverage.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenBackend.h"
#include <numeric>
#include <string>

using namespace llvm;
Expand Down Expand Up @@ -792,8 +790,8 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
"nested predicate that uses operands");
TreePattern *TP = Predicate.getOrigPatFragRecord();
WaitingForNamedOperands = TP->getNumArgs();
for (unsigned i = 0; i < WaitingForNamedOperands; ++i)
StoreIdxForName[getScopedName(Call.Scope, TP->getArgName(i))] = i;
for (unsigned I = 0; I < WaitingForNamedOperands; ++I)
StoreIdxForName[getScopedName(Call.Scope, TP->getArgName(I))] = I;
}
InsnMatcher.addPredicate<GenericInstructionPredicateMatcher>(Predicate);
continue;
Expand Down Expand Up @@ -878,8 +876,8 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
if (IsIntrinsic && !II)
return failedImport("Expected IntInit containing intrinsic ID)");

for (unsigned i = 0; i != NumChildren; ++i) {
const TreePatternNode &SrcChild = Src.getChild(i);
for (unsigned I = 0; I != NumChildren; ++I) {
const TreePatternNode &SrcChild = Src.getChild(I);

// We need to determine the meaning of a literal integer based on the
// context. If this is a field required to be an immediate (such as an
Expand All @@ -888,19 +886,19 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
// argument that is required to be an immediate, we should not emit an LLT
// type check, and should not be looking for a G_CONSTANT defined
// register.
bool OperandIsImmArg = SrcGIOrNull->isInOperandImmArg(i);
bool OperandIsImmArg = SrcGIOrNull->isInOperandImmArg(I);

// SelectionDAG allows pointers to be represented with iN since it doesn't
// distinguish between pointers and integers but they are different types
// in GlobalISel. Coerce integers to pointers to address space 0 if the
// context indicates a pointer.
//
bool OperandIsAPointer = SrcGIOrNull->isInOperandAPointer(i);
bool OperandIsAPointer = SrcGIOrNull->isInOperandAPointer(I);

if (IsIntrinsic) {
// For G_INTRINSIC/G_INTRINSIC_W_SIDE_EFFECTS, the operand immediately
// following the defs is an intrinsic ID.
if (i == 0) {
if (I == 0) {
OperandMatcher &OM =
InsnMatcher.addOperand(OpIdx++, SrcChild.getName(), TempOpIdx);
OM.addPredicate<IntrinsicIDOperandMatcher>(II);
Expand All @@ -911,8 +909,8 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
//
// Note that we have to look at the i-1th parameter, because we don't
// have the intrinsic ID in the intrinsic's parameter list.
OperandIsAPointer |= II->isParamAPointer(i - 1);
OperandIsImmArg |= II->isParamImmArg(i - 1);
OperandIsAPointer |= II->isParamAPointer(I - 1);
OperandIsImmArg |= II->isParamImmArg(I - 1);
}

if (auto Error =
Expand Down Expand Up @@ -967,9 +965,9 @@ Error GlobalISelEmitter::importChildMatcher(
// The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is
// "MY_PAT:op1:op2" and the ones with same "name" represent same operand.
std::string PatternName = std::string(SrcChild.getOperator()->getName());
for (unsigned i = 0; i < SrcChild.getNumChildren(); ++i) {
for (unsigned I = 0; I < SrcChild.getNumChildren(); ++I) {
PatternName += ":";
PatternName += SrcChild.getChild(i).getName();
PatternName += SrcChild.getChild(I).getName();
}
SrcChildName = PatternName;
}
Expand Down Expand Up @@ -1042,11 +1040,11 @@ Error GlobalISelEmitter::importChildMatcher(
OM, SrcChild.getOperator(), TempOpIdx))
return Error;

for (unsigned i = 0, e = SrcChild.getNumChildren(); i != e; ++i) {
auto &SubOperand = SrcChild.getChild(i);
for (unsigned I = 0, E = SrcChild.getNumChildren(); I != E; ++I) {
auto &SubOperand = SrcChild.getChild(I);
if (!SubOperand.getName().empty()) {
if (auto Error = Rule.defineComplexSubOperand(
SubOperand.getName(), SrcChild.getOperator(), RendererID, i,
SubOperand.getName(), SrcChild.getOperator(), RendererID, I,
SrcChildName))
return Error;
}
Expand Down Expand Up @@ -1232,10 +1230,12 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderer(
if (DstChild.getOperator()->getName() == "tframeindex") {
DstMIBuilder.addRenderer<CopyRenderer>(DstChild.getName());
return InsertPt;
} else if (DstChild.getOperator()->getName() == "imm") {
}
if (DstChild.getOperator()->getName() == "imm") {
DstMIBuilder.addRenderer<CopyConstantAsImmRenderer>(DstChild.getName());
return InsertPt;
} else if (DstChild.getOperator()->getName() == "fpimm") {
}
if (DstChild.getOperator()->getName() == "fpimm") {
DstMIBuilder.addRenderer<CopyFConstantAsFPImmRenderer>(
DstChild.getName());
return InsertPt;
Expand Down Expand Up @@ -1748,7 +1748,7 @@ Error GlobalISelEmitter::importDefaultOperandRenderers(

if (const DefInit *DefaultDefOp = dyn_cast<DefInit>(DefaultOp)) {
std::optional<LLTCodeGen> OpTyOrNone = MVTToLLT(N.getSimpleType(0));
auto Def = DefaultDefOp->getDef();
auto *Def = DefaultDefOp->getDef();
if (Def->getName() == "undef_tied_input") {
unsigned TempRegID = M.allocateTempRegID();
M.insertAction<MakeTempRegisterAction>(InsertPt, *OpTyOrNone,
Expand Down Expand Up @@ -2449,13 +2449,13 @@ void GlobalISelEmitter::run(raw_ostream &OS) {
}

// Comparison function to order records by name.
auto orderByName = [](const Record *A, const Record *B) {
auto OrderByName = [](const Record *A, const Record *B) {
return A->getName() < B->getName();
};

std::vector<Record *> ComplexPredicates =
RK.getAllDerivedDefinitions("GIComplexOperandMatcher");
llvm::sort(ComplexPredicates, orderByName);
llvm::sort(ComplexPredicates, OrderByName);

std::vector<StringRef> CustomRendererFns;
transform(RK.getAllDerivedDefinitions("GICustomOperandRenderer"),
Expand Down