-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes a couple of style issues, such as: - unused includes - variable naming - `else if` after `return`
@llvm/pr-subscribers-llvm-globalisel Author: Kai Nacke (redstar) ChangesFixes a couple of style issues, such as:
Full diff: https://github.com/llvm/llvm-project/pull/90492.diff 1 Files Affected:
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 0eb258ff89a288..cf7e4398741ca5 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -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;
@@ -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;
@@ -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
@@ -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);
@@ -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 =
@@ -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;
}
@@ -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;
}
@@ -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;
@@ -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,
@@ -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"),
|
arsenm
approved these changes
Apr 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a couple of style issues, such as:
else if
afterreturn