diff options
author | vvvv <vvvv@ydb.tech> | 2024-02-06 20:01:22 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-02-09 19:18:27 +0300 |
commit | ee2b7fbda052aa09b6fdb83b8c6f0305fef3e193 (patch) | |
tree | 102765416c3866bde98a82facc7752d329ee0226 /contrib/libs/llvm16/tools/llvm-mca/Views/InstructionView.cpp | |
parent | 7494ca32d3a5aca00b7ac527b5f127989335102c (diff) | |
download | ydb-ee2b7fbda052aa09b6fdb83b8c6f0305fef3e193.tar.gz |
llvm16 targets
Diffstat (limited to 'contrib/libs/llvm16/tools/llvm-mca/Views/InstructionView.cpp')
-rw-r--r-- | contrib/libs/llvm16/tools/llvm-mca/Views/InstructionView.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/contrib/libs/llvm16/tools/llvm-mca/Views/InstructionView.cpp b/contrib/libs/llvm16/tools/llvm-mca/Views/InstructionView.cpp new file mode 100644 index 0000000000..3b174a0649 --- /dev/null +++ b/contrib/libs/llvm16/tools/llvm-mca/Views/InstructionView.cpp @@ -0,0 +1,43 @@ +//===----------------------- InstructionView.cpp ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This file defines the member functions of the class InstructionView. +/// +//===----------------------------------------------------------------------===// + +#include "Views/InstructionView.h" +#include "llvm/MC/MCInst.h" +#include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCSubtargetInfo.h" + +namespace llvm { +namespace mca { + +InstructionView::~InstructionView() = default; + +StringRef +InstructionView::printInstructionString(const llvm::MCInst &MCI) const { + InstructionString = ""; + MCIP.printInst(&MCI, 0, "", STI, InstrStream); + InstrStream.flush(); + // Remove any tabs or spaces at the beginning of the instruction. + return StringRef(InstructionString).ltrim(); +} + +json::Value InstructionView::toJSON() const { + json::Array SourceInfo; + for (const auto &MCI : getSource()) { + StringRef Instruction = printInstructionString(MCI); + SourceInfo.push_back(Instruction.str()); + } + return SourceInfo; +} + +} // namespace mca +} // namespace llvm |