-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Hexagon] Remove implicit conversions of MCRegister to unsigned. NFC #167571
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
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
Member
|
@llvm/pr-subscribers-backend-hexagon Author: Craig Topper (topperc) ChangesUse MCRegister instead of unsigned or use MCRegister::id() Full diff: https://github.com/llvm/llvm-project/pull/167571.diff 3 Files Affected:
diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
index b94b1484205ae..c18db982bfd97 100644
--- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
+++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
@@ -463,7 +463,7 @@ void HexagonOperand::print(raw_ostream &OS, const MCAsmInfo &MAI) const {
break;
case Register:
OS << "<register R";
- OS << getReg() << ">";
+ OS << getReg().id() << ">";
break;
case Token:
OS << "'" << getToken() << "'";
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
index 9b6bc5ade379d..0b2279bb2cfe6 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
@@ -385,7 +385,7 @@ bool HexagonMCChecker::checkSlots() {
bool HexagonMCChecker::checkPredicates() {
// Check for proper use of new predicate registers.
for (const auto &I : NewPreds) {
- unsigned P = I;
+ MCRegister P = I;
if (!Defs.count(P) || LatePreds.count(P) || Defs.count(Hexagon::P3_0)) {
// Error out if the new predicate register is not defined,
@@ -398,7 +398,7 @@ bool HexagonMCChecker::checkPredicates() {
// Check for proper use of auto-anded of predicate registers.
for (const auto &I : LatePreds) {
- unsigned P = I;
+ MCRegister P = I;
if (LatePreds.count(P) > 1 || Defs.count(P)) {
// Error out if predicate register defined "late" multiple times or
@@ -607,7 +607,7 @@ void HexagonMCChecker::checkRegisterCurDefs() {
bool HexagonMCChecker::checkRegisters() {
// Check for proper register definitions.
for (const auto &I : Defs) {
- unsigned R = I.first;
+ MCRegister R = I.first;
if (isLoopRegister(R) && Defs.count(R) > 1 &&
(HexagonMCInstrInfo::isInnerLoop(MCB) ||
@@ -620,8 +620,8 @@ bool HexagonMCChecker::checkRegisters() {
if (SoftDefs.count(R)) {
// Error out for explicit changes to registers also weakly defined
// (e.g., "{ usr = r0; r0 = sfadd(...) }").
- unsigned UsrR = Hexagon::USR; // Silence warning about mixed types in ?:.
- unsigned BadR = RI.isSubRegister(Hexagon::USR, R) ? UsrR : R;
+ MCRegister UsrR = Hexagon::USR;
+ MCRegister BadR = RI.isSubRegister(Hexagon::USR, R) ? UsrR : R;
reportErrorRegisters(BadR);
return false;
}
@@ -633,8 +633,8 @@ bool HexagonMCChecker::checkRegisters() {
if (PM.count(Unconditional)) {
// Error out on an unconditional change when there are any other
// changes, conditional or not.
- unsigned UsrR = Hexagon::USR;
- unsigned BadR = RI.isSubRegister(Hexagon::USR, R) ? UsrR : R;
+ MCRegister UsrR = Hexagon::USR;
+ MCRegister BadR = RI.isSubRegister(Hexagon::USR, R) ? UsrR : R;
reportErrorRegisters(BadR);
return false;
}
@@ -664,7 +664,7 @@ bool HexagonMCChecker::checkRegisters() {
// Check for use of temporary definitions.
for (const auto &I : TmpDefs) {
- unsigned R = I;
+ MCRegister R = I;
if (!Uses.count(R)) {
// special case for vhist
@@ -765,12 +765,12 @@ void HexagonMCChecker::compoundRegisterMap(unsigned &Register) {
}
}
-void HexagonMCChecker::reportErrorRegisters(unsigned Register) {
+void HexagonMCChecker::reportErrorRegisters(MCRegister Register) {
reportError("register `" + Twine(RI.getName(Register)) +
"' modified more than once");
}
-void HexagonMCChecker::reportErrorNewValue(unsigned Register) {
+void HexagonMCChecker::reportErrorNewValue(MCRegister Register) {
reportError("register `" + Twine(RI.getName(Register)) +
"' used with `.new' "
"but not validly modified in the same packet");
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h
index e9b87c5315fe4..8beee8d7ec8eb 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.h
@@ -39,41 +39,41 @@ class HexagonMCChecker {
bool ReportErrors;
/// Set of definitions: register #, if predicated, if predicated true.
- using PredSense = std::pair<unsigned, bool>;
+ using PredSense = std::pair<MCRegister, bool>;
static const PredSense Unconditional;
using PredSet = std::multiset<PredSense>;
using PredSetIterator = std::multiset<PredSense>::iterator;
- using DefsIterator = DenseMap<unsigned, PredSet>::iterator;
- DenseMap<unsigned, PredSet> Defs;
+ using DefsIterator = DenseMap<MCRegister, PredSet>::iterator;
+ DenseMap<MCRegister, PredSet> Defs;
/// Set of weak definitions whose clashes should be enforced selectively.
- using SoftDefsIterator = std::set<unsigned>::iterator;
- std::set<unsigned> SoftDefs;
+ using SoftDefsIterator = std::set<MCRegister>::iterator;
+ std::set<MCRegister> SoftDefs;
/// Set of temporary definitions not committed to the register file.
- using TmpDefsIterator = std::set<unsigned>::iterator;
- std::set<unsigned> TmpDefs;
+ using TmpDefsIterator = std::set<MCRegister>::iterator;
+ std::set<MCRegister> TmpDefs;
/// Set of new predicates used.
- using NewPredsIterator = std::set<unsigned>::iterator;
- std::set<unsigned> NewPreds;
+ using NewPredsIterator = std::set<MCRegister>::iterator;
+ std::set<MCRegister> NewPreds;
/// Set of predicates defined late.
- using LatePredsIterator = std::multiset<unsigned>::iterator;
- std::multiset<unsigned> LatePreds;
+ using LatePredsIterator = std::multiset<MCRegister>::iterator;
+ std::multiset<MCRegister> LatePreds;
/// Set of uses.
- using UsesIterator = std::set<unsigned>::iterator;
- std::set<unsigned> Uses;
+ using UsesIterator = std::set<MCRegister>::iterator;
+ std::set<MCRegister> Uses;
/// Pre-defined set of read-only registers.
- using ReadOnlyIterator = std::set<unsigned>::iterator;
- std::set<unsigned> ReadOnly;
+ using ReadOnlyIterator = std::set<MCRegister>::iterator;
+ std::set<MCRegister> ReadOnly;
// Contains the vector-pair-registers with the even number
// first ("v0:1", e.g.) used/def'd in this packet.
- std::set<unsigned> ReversePairs;
+ std::set<MCRegister> ReversePairs;
void init();
void init(MCInst const &);
@@ -107,7 +107,7 @@ class HexagonMCChecker {
static void compoundRegisterMap(unsigned &);
- bool isLoopRegister(unsigned R) const {
+ bool isLoopRegister(MCRegister R) const {
return (Hexagon::SA0 == R || Hexagon::LC0 == R || Hexagon::SA1 == R ||
Hexagon::LC1 == R);
}
@@ -120,8 +120,8 @@ class HexagonMCChecker {
MCSubtargetInfo const &STI, bool CopyReportErrors);
bool check(bool FullCheck = true);
- void reportErrorRegisters(unsigned Register);
- void reportErrorNewValue(unsigned Register);
+ void reportErrorRegisters(MCRegister Register);
+ void reportErrorNewValue(MCRegister Register);
void reportError(SMLoc Loc, Twine const &Msg);
void reportNote(SMLoc Loc, Twine const &Msg);
void reportError(Twine const &Msg);
|
s-barannikov
approved these changes
Nov 11, 2025
Contributor
s-barannikov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
Use MCRegister instead of unsigned or use MCRegister::id()