Skip to content

Commit

Permalink
[TableGen][GISel][NFC] clang-tidy GlobalISelEmitter.cpp (#90492)
Browse files Browse the repository at this point in the history
Fixes a couple of style issues, such as:

- unused includes
- variable naming
- `else if` after `return`
  • Loading branch information
redstar committed Apr 29, 2024
1 parent c3598b1 commit 413f6b9
Showing 1 changed file with 21 additions and 21 deletions.
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

0 comments on commit 413f6b9

Please sign in to comment.