Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 65b72a1

Browse files
committed
Merging r328944:
------------------------------------------------------------------------ r328944 | chandlerc | 2018-04-01 14:47:55 -0700 (Sun, 01 Apr 2018) | 4 lines [x86] Expose more of the condition conversion routines in the public API for X86's instruction information. I've now got a second patch under review that needs these same APIs. This bit is nicely orthogonal and obvious, so landing it. NFC. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@332564 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f642cae commit 65b72a1

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/Target/X86/X86InstrInfo.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5782,7 +5782,7 @@ bool X86InstrInfo::findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
57825782
return false;
57835783
}
57845784

5785-
static X86::CondCode getCondFromBranchOpc(unsigned BrOpc) {
5785+
X86::CondCode X86::getCondFromBranchOpc(unsigned BrOpc) {
57865786
switch (BrOpc) {
57875787
default: return X86::COND_INVALID;
57885788
case X86::JE_1: return X86::COND_E;
@@ -5805,7 +5805,7 @@ static X86::CondCode getCondFromBranchOpc(unsigned BrOpc) {
58055805
}
58065806

58075807
/// Return condition code of a SET opcode.
5808-
static X86::CondCode getCondFromSETOpc(unsigned Opc) {
5808+
X86::CondCode X86::getCondFromSETOpc(unsigned Opc) {
58095809
switch (Opc) {
58105810
default: return X86::COND_INVALID;
58115811
case X86::SETAr: case X86::SETAm: return X86::COND_A;
@@ -6130,7 +6130,7 @@ void X86InstrInfo::replaceBranchWithTailCall(
61306130
if (!I->isBranch())
61316131
assert(0 && "Can't find the branch to replace!");
61326132

6133-
X86::CondCode CC = getCondFromBranchOpc(I->getOpcode());
6133+
X86::CondCode CC = X86::getCondFromBranchOpc(I->getOpcode());
61346134
assert(BranchCond.size() == 1);
61356135
if (CC != BranchCond[0].getImm())
61366136
continue;
@@ -6237,7 +6237,7 @@ bool X86InstrInfo::AnalyzeBranchImpl(
62376237
}
62386238

62396239
// Handle conditional branches.
6240-
X86::CondCode BranchCode = getCondFromBranchOpc(I->getOpcode());
6240+
X86::CondCode BranchCode = X86::getCondFromBranchOpc(I->getOpcode());
62416241
if (BranchCode == X86::COND_INVALID)
62426242
return true; // Can't handle indirect branch.
62436243

@@ -6433,7 +6433,7 @@ unsigned X86InstrInfo::removeBranch(MachineBasicBlock &MBB,
64336433
if (I->isDebugValue())
64346434
continue;
64356435
if (I->getOpcode() != X86::JMP_1 &&
6436-
getCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID)
6436+
X86::getCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID)
64376437
break;
64386438
// Remove the branch.
64396439
I->eraseFromParent();
@@ -7465,9 +7465,9 @@ bool X86InstrInfo::optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg,
74657465
if (IsCmpZero || IsSwapped) {
74667466
// We decode the condition code from opcode.
74677467
if (Instr.isBranch())
7468-
OldCC = getCondFromBranchOpc(Instr.getOpcode());
7468+
OldCC = X86::getCondFromBranchOpc(Instr.getOpcode());
74697469
else {
7470-
OldCC = getCondFromSETOpc(Instr.getOpcode());
7470+
OldCC = X86::getCondFromSETOpc(Instr.getOpcode());
74717471
if (OldCC != X86::COND_INVALID)
74727472
OpcIsSET = true;
74737473
else

lib/Target/X86/X86InstrInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ unsigned getSETFromCond(CondCode CC, bool HasMemoryOperand = false);
7777
unsigned getCMovFromCond(CondCode CC, unsigned RegBytes,
7878
bool HasMemoryOperand = false);
7979

80+
// Turn jCC opcode into condition code.
81+
CondCode getCondFromBranchOpc(unsigned Opc);
82+
83+
// Turn setCC opcode into condition code.
84+
CondCode getCondFromSETOpc(unsigned Opc);
85+
8086
// Turn CMov opcode into condition code.
8187
CondCode getCondFromCMovOpc(unsigned Opc);
8288

0 commit comments

Comments
 (0)