[llvm] [Exegesis][RISCV] Add RISCV support for llvm-exegesis (PR #89047)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 10:18:59 PDT 2024
================
@@ -296,6 +312,43 @@ T ExitOnFileError(const Twine &FileName, Expected<T> &&E) {
return std::move(*E);
}
+static const char *getIgnoredOpcodeReasonOrNull(const LLVMState &State,
+ unsigned Opcode) {
+ const MCInstrDesc &InstrDesc = State.getIC().getInstr(Opcode).Description;
+ if (InstrDesc.isPseudo() || InstrDesc.usesCustomInsertionHook())
+ return "Unsupported opcode: isPseudo/usesCustomInserter";
+ if (InstrDesc.isBranch() || InstrDesc.isIndirectBranch())
+ return "Unsupported opcode: isBranch/isIndirectBranch";
+ if (InstrDesc.isCall() || InstrDesc.isReturn())
+ return "Unsupported opcode: isCall/isReturn";
+ return nullptr;
+}
+
+static bool isIgnoredOpcode(const LLVMState &State, unsigned Opcode) {
+ return getIgnoredOpcodeReasonOrNull(State, Opcode) != nullptr;
+}
+
+bool OpcodeNameParser::parse(
+ cl::Option &O, StringRef ArgName, const StringRef OpcodeNames,
+ std::vector<std::pair<StringRef, StringRef>> &Val) {
+ SmallVector<StringRef, 2> Pieces;
+ StringRef(OpcodeNames)
+ .split(Pieces, ",", /* MaxSplit */ -1, /* KeepEmpty */ false);
+ for (const StringRef &OpcodeName : Pieces) {
+ size_t DotDotPos = OpcodeName.find("..");
+ if (DotDotPos == StringRef::npos) {
+ Val.push_back(std::make_pair(OpcodeName, OpcodeName));
+ continue;
+ }
+ StringRef BeginOpcodeName = OpcodeName.substr(0, DotDotPos);
+ StringRef EndOpcodeName = OpcodeName.substr(DotDotPos + 2);
+ Val.push_back(std::make_pair(BeginOpcodeName, EndOpcodeName));
----------------
mshockwave wrote:
I actually meant `emplace_back(BeginOpcodeName, EndOpcodeName)`
https://github.com/llvm/llvm-project/pull/89047
More information about the llvm-commits
mailing list