[PATCH] D151930: [X86][MC] Use MCInstrDesc to access CondCode operand
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 13:48:36 PDT 2023
Amir created this revision.
Amir added a reviewer: skan.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
Amir requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
BOLT may add an extra MCOperand as annotation, making the number of operands in
MCInst different from MCInstrDesc information. A recent change broke our use as
the last operand is no longer a cond code.
Partially revert 287dd0142c08caad5b32628f3842dfd5d5c59d03 <https://reviews.llvm.org/rG287dd0142c08caad5b32628f3842dfd5d5c59d03> to rely on MCInstrDesc
to access CondCode operand.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151930
Files:
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===================================================================
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -231,20 +231,23 @@
: X86::getOpcodeForLongImmediateForm(Opcode);
}
-static X86::CondCode getCondFromBranch(const MCInst &MI) {
+static X86::CondCode getCondFromBranch(const MCInst &MI,
+ const MCInstrInfo &MCII) {
unsigned Opcode = MI.getOpcode();
switch (Opcode) {
default:
return X86::COND_INVALID;
- case X86::JCC_1:
+ case X86::JCC_1: {
+ const MCInstrDesc &Desc = MCII.get(Opcode);
return static_cast<X86::CondCode>(
- MI.getOperand(MI.getNumOperands() - 1).getImm());
+ MI.getOperand(Desc.getNumOperands() - 1).getImm());
+ }
}
}
static X86::SecondMacroFusionInstKind
-classifySecondInstInMacroFusion(const MCInst &MI) {
- X86::CondCode CC = getCondFromBranch(MI);
+classifySecondInstInMacroFusion(const MCInst &MI, const MCInstrInfo &MCII) {
+ X86::CondCode CC = getCondFromBranch(MI, MCII);
return classifySecondCondCodeInMacroFusion(CC);
}
@@ -351,7 +354,7 @@
const X86::FirstMacroFusionInstKind CmpKind =
X86::classifyFirstOpcodeInMacroFusion(Cmp.getOpcode());
const X86::SecondMacroFusionInstKind BranchKind =
- classifySecondInstInMacroFusion(Jcc);
+ classifySecondInstInMacroFusion(Jcc, *MCII);
return X86::isMacroFused(CmpKind, BranchKind);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151930.527597.patch
Type: text/x-patch
Size: 1556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230601/53a1590c/attachment.bin>
More information about the llvm-commits
mailing list