[Hexagon] Add HexagonMCInstrInfo::IsABranchingInst, NFC

This commit is contained in:
Brian Cain 2021-12-28 09:51:27 -08:00 committed by Krzysztof Parzyszek
parent c5327137df
commit 1e7bd93ff2
3 changed files with 13 additions and 6 deletions

View File

@ -317,8 +317,7 @@ bool HexagonMCChecker::checkAXOK() {
void HexagonMCChecker::reportBranchErrors() {
for (auto const &I : HexagonMCInstrInfo::bundleInstructions(MCII, MCB)) {
MCInstrDesc const &Desc = HexagonMCInstrInfo::getDesc(MCII, I);
if (Desc.isBranch() || Desc.isCall() || Desc.isReturn())
if (HexagonMCInstrInfo::IsABranchingInst(MCII, STI, I))
reportNote(I.getLoc(), "Branching instruction");
}
}
@ -328,8 +327,7 @@ bool HexagonMCChecker::checkHWLoop() {
!HexagonMCInstrInfo::isOuterLoop(MCB))
return true;
for (auto const &I : HexagonMCInstrInfo::bundleInstructions(MCII, MCB)) {
MCInstrDesc const &Desc = HexagonMCInstrInfo::getDesc(MCII, I);
if (Desc.isBranch() || Desc.isCall() || Desc.isReturn()) {
if (HexagonMCInstrInfo::IsABranchingInst(MCII, STI, I)) {
reportError(MCB.getLoc(),
"Branches cannot be in a packet with hardware loops");
reportBranchErrors();
@ -342,8 +340,7 @@ bool HexagonMCChecker::checkHWLoop() {
bool HexagonMCChecker::checkCOFMax1() {
SmallVector<MCInst const *, 2> BranchLocations;
for (auto const &I : HexagonMCInstrInfo::bundleInstructions(MCII, MCB)) {
MCInstrDesc const &Desc = HexagonMCInstrInfo::getDesc(MCII, I);
if (Desc.isBranch() || Desc.isCall() || Desc.isReturn())
if (HexagonMCInstrInfo::IsABranchingInst(MCII, STI, I))
BranchLocations.push_back(&I);
}
for (unsigned J = 0, N = BranchLocations.size(); J < N; ++J) {

View File

@ -1030,3 +1030,11 @@ unsigned HexagonMCInstrInfo::SubregisterBit(unsigned Consumer,
return Consumer == Producer;
return 0;
}
bool HexagonMCInstrInfo::IsABranchingInst(MCInstrInfo const &MCII,
MCSubtargetInfo const &STI,
MCInst const &I) {
assert(!HexagonMCInstrInfo::isBundle(I));
MCInstrDesc const &Desc = HexagonMCInstrInfo::getDesc(MCII, I);
return (Desc.isBranch() || Desc.isCall() || Desc.isReturn());
}

View File

@ -95,6 +95,8 @@ bool canonicalizePacket(MCInstrInfo const &MCII, MCSubtargetInfo const &STI,
MCContext &Context, MCInst &MCB,
HexagonMCChecker *Checker,
bool AttemptCompatibility = false);
bool IsABranchingInst(MCInstrInfo const &MCII, MCSubtargetInfo const &STI,
MCInst const &I);
// Create a duplex instruction given the two subinsts
MCInst *deriveDuplex(MCContext &Context, unsigned iClass, MCInst const &inst0,