[PATCH] D122853: [BOLT][NFC] Use X86 mnemonic checks
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 31 16:02:18 PDT 2022
Amir created this revision.
Herald added subscribers: ayermolo, pengfei.
Herald added a reviewer: rafauler.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Remove switches in X86MCPlusBuilder.cpp, use mnemonic checks instead
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122853
Files:
bolt/lib/Target/X86/X86MCPlusBuilder.cpp
Index: bolt/lib/Target/X86/X86MCPlusBuilder.cpp
===================================================================
--- bolt/lib/Target/X86/X86MCPlusBuilder.cpp
+++ bolt/lib/Target/X86/X86MCPlusBuilder.cpp
@@ -87,15 +87,10 @@
}
unsigned getCondCode(const MCInst &Inst) const override {
- switch (Inst.getOpcode()) {
- default:
- return X86::COND_INVALID;
- case X86::JCC_1:
- case X86::JCC_2:
- case X86::JCC_4:
- return Inst.getOperand(Info->get(Inst.getOpcode()).NumOperands - 1)
- .getImm();
- }
+ unsigned Opcode = Inst.getOpcode();
+ if (X86::isJCC(Opcode))
+ return Inst.getOperand(Info->get(Opcode).NumOperands - 1).getImm();
+ return X86::COND_INVALID;
}
unsigned getInvertedCondCode(unsigned CC) const override {
@@ -206,21 +201,9 @@
// FIXME: For compatibility with old LLVM only!
bool isTerminator(const MCInst &Inst) const override {
- if (Info->get(Inst.getOpcode()).isTerminator())
- return true;
- switch (Inst.getOpcode()) {
- default:
- return false;
- case X86::TRAP:
- // Opcodes previously known as X86::UD2B
- case X86::UD1Wm:
- case X86::UD1Lm:
- case X86::UD1Qm:
- case X86::UD1Wr:
- case X86::UD1Lr:
- case X86::UD1Qr:
- return true;
- }
+ unsigned Opcode = Inst.getOpcode();
+ return Info->get(Opcode).isTerminator() || X86::isUD1(Opcode) ||
+ X86::isUD2(Opcode);
}
bool isIndirectCall(const MCInst &Inst) const override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122853.419582.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220331/6690ad7d/attachment.bin>
More information about the llvm-commits
mailing list