From 9d2f06445ffaceb501abd9477d3b5ce7231af49d Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Fri, 19 Feb 2021 17:04:27 +0800 Subject: [PATCH] [llvm-exegesis] Ignore instructions using custom inserter Some instructions defined in table-gen files sets usesCustomInserter bit, which means it has to be lowered by target code and isn't actually valid instruction at MC level. So we should treat them like pseudo instructions. Reviewed By: gchatelet Differential Revision: https://reviews.llvm.org/D94898 --- llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s | 3 +++ llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp | 2 +- llvm/tools/llvm-exegesis/llvm-exegesis.cpp | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s diff --git a/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s b/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s new file mode 100644 index 0000000..67348ef --- /dev/null +++ b/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s @@ -0,0 +1,3 @@ +# RUN: llvm-exegesis -mode=latency -opcode-name=SELECT_I8 2>&1 | FileCheck %s + +CHECK: Unsupported opcode: isPseudo/usesCustomInserter diff --git a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp index 504e7bd..f5940bd 100644 --- a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp +++ b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp @@ -51,7 +51,7 @@ computeAliasingInstructions(const LLVMState &State, const Instruction *Instr, const Instruction &OtherInstr = State.getIC().getInstr(OtherOpcode); const MCInstrDesc &OtherInstrDesc = OtherInstr.Description; // Ignore instructions that we cannot run. - if (OtherInstrDesc.isPseudo() || + if (OtherInstrDesc.isPseudo() || OtherInstrDesc.usesCustomInsertionHook() || OtherInstrDesc.isBranch() || OtherInstrDesc.isIndirectBranch() || OtherInstrDesc.isCall() || OtherInstrDesc.isReturn()) { continue; diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp index 2d20d0e..9cbcc1b 100644 --- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -251,8 +251,9 @@ generateSnippets(const LLVMState &State, unsigned Opcode, const Instruction &Instr = State.getIC().getInstr(Opcode); const MCInstrDesc &InstrDesc = Instr.Description; // Ignore instructions that we cannot run. - if (InstrDesc.isPseudo()) - return make_error("Unsupported opcode: isPseudo"); + if (InstrDesc.isPseudo() || InstrDesc.usesCustomInsertionHook()) + return make_error( + "Unsupported opcode: isPseudo/usesCustomInserter"); if (InstrDesc.isBranch() || InstrDesc.isIndirectBranch()) return make_error("Unsupported opcode: isBranch/isIndirectBranch"); if (InstrDesc.isCall() || InstrDesc.isReturn()) -- 2.7.4