LLVM 22.0.0git
CustomBehaviour.cpp
Go to the documentation of this file.
1//===--------------------- CustomBehaviour.cpp ------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9///
10/// This file implements methods from the CustomBehaviour interface.
11///
12//===----------------------------------------------------------------------===//
13
16
17namespace llvm {
18namespace mca {
19
21
23 const InstRef &IR) {
24 // 0 signifies that there are no hazards that need to be waited on
25 return 0;
26}
27
28std::vector<std::unique_ptr<View>>
31 return std::vector<std::unique_ptr<View>>();
32}
33
34std::vector<std::unique_ptr<View>>
37 return std::vector<std::unique_ptr<View>>();
38}
39
40std::vector<std::unique_ptr<View>>
43 return std::vector<std::unique_ptr<View>>();
44}
45
47
51
53 for (const auto I : IVec) {
54 if (I->getDesc() == LatencyInstrument::DESC_NAME) {
55 auto LatInst = static_cast<LatencyInstrument *>(I);
56 return LatInst->hasValue();
57 }
58 }
59 return false;
60}
61
63 InstrDesc &ID) const {
64 for (const auto I : IVec) {
65 if (I->getDesc() == LatencyInstrument::DESC_NAME) {
66 auto LatInst = static_cast<LatencyInstrument *>(I);
67 if (LatInst->hasValue()) {
68 unsigned Latency = LatInst->getLatency();
69 // TODO Allow to customize a subset of ID.Writes
70 for (auto &W : ID.Writes)
71 W.Latency = Latency;
72 ID.MaxLatency = Latency;
73 }
74 }
75 }
76}
77
82 return std::make_unique<LatencyInstrument>(Data);
83 }
84 return std::make_unique<Instrument>(Desc, Data);
85}
86
91
93 const MCInstrInfo &MCII, const MCInst &MCI,
94 const llvm::SmallVector<Instrument *> &IVec) const {
95 return MCII.get(MCI.getOpcode()).getSchedClass();
96}
97
98} // namespace mca
99} // namespace llvm
This file defines the base class CustomBehaviour which can be inherited from by specific targets (ex.
Legalize the Machine IR a function s Machine IR
Definition Legalizer.cpp:80
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
#define I(x, y, z)
Definition MD5.cpp:58
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
unsigned getOpcode() const
Definition MCInst.h:202
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
virtual std::vector< std::unique_ptr< View > > getEndViews(llvm::MCInstPrinter &IP, llvm::ArrayRef< llvm::MCInst > Insts)
Return a vector of Views that will be added after all other Views.
virtual unsigned checkCustomHazard(ArrayRef< InstRef > IssuedInst, const InstRef &IR)
Before the llvm-mca pipeline dispatches an instruction, it first checks for any register or resource ...
virtual std::vector< std::unique_ptr< View > > getPostInstrInfoViews(llvm::MCInstPrinter &IP, llvm::ArrayRef< llvm::MCInst > Insts)
Return a vector of Views that will be added after the InstructionInfoView.
virtual std::vector< std::unique_ptr< View > > getStartViews(llvm::MCInstPrinter &IP, llvm::ArrayRef< llvm::MCInst > Insts)
Return a vector of Views that will be added before all other Views.
An InstRef contains both a SourceMgr index and Instruction pair.
virtual bool canCustomize(const ArrayRef< Instrument * > IVec) const
virtual unsigned getSchedClassID(const MCInstrInfo &MCII, const MCInst &MCI, const SmallVector< Instrument * > &IVec) const
Given an MCInst and a vector of Instrument, a target can return a SchedClassID.
virtual UniqueInstrument createInstrument(StringRef Desc, StringRef Data)
Allocate an Instrument, and return a unique pointer to it.
virtual SmallVector< UniqueInstrument > createInstruments(const MCInst &Inst)
Return a list of unique pointers to Instruments, where each Instrument is allocated by this function.
virtual bool supportsInstrumentType(StringRef Type) const
virtual void customize(const ArrayRef< Instrument * > IVec, llvm::mca::InstrDesc &Desc) const
static const StringRef DESC_NAME
std::unique_ptr< Instrument > UniqueInstrument
char InstructionError< T >::ID
Definition Support.h:44
This is an optimization pass for GlobalISel generic memory operations.
Op::Description Desc
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
An instruction descriptor.