mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
Reapply "[MCA] Adding the CustomBehaviour class to llvm-mca".
The original change was pushed in main as commit f7a23ecece52. It was then reverted by commit a04f01bab2 because it caused linker failures on buildbots that don't build the AMDGPU target. -- Some instructions are not defined well enough within the target’s scheduling model for llvm-mca to be able to properly simulate its behaviour. The ideal solution to this situation is to modify the scheduling model, but that’s not always a viable strategy. Maybe other parts of the backend depend on that instruction being modelled the way that it is. Or maybe the instruction is quite complex and it’s difficult to fully capture its behaviour with tablegen. The CustomBehaviour class (which I will refer to as CB frequently) is designed to provide intuitive scaffolding for developers to implement the correct modelling for these instructions. More details are available in the original commit log message (f7a23ecece52). Differential Revision: https://reviews.llvm.org/D104149
This commit is contained in:
parent
31ec72a21f
commit
449e2cbd5e
@ -213,6 +213,11 @@ option specifies "``-``", then the output will also be sent to standard output.
|
|||||||
resources are printed as members of special top level JSON objects. The
|
resources are printed as members of special top level JSON objects. The
|
||||||
individual views refer to them by index.
|
individual views refer to them by index.
|
||||||
|
|
||||||
|
.. option:: -disable-cb
|
||||||
|
|
||||||
|
Force usage of the generic CustomBehaviour class rather than using the target
|
||||||
|
specific class. The generic class never detects any custom hazards.
|
||||||
|
|
||||||
|
|
||||||
EXIT STATUS
|
EXIT STATUS
|
||||||
-----------
|
-----------
|
||||||
@ -978,3 +983,32 @@ Once issued, an instruction is moved to ``IssuedInst`` set until it is ready to
|
|||||||
retire. :program:`llvm-mca` ensures that writes are committed in-order. However,
|
retire. :program:`llvm-mca` ensures that writes are committed in-order. However,
|
||||||
an instruction is allowed to commit writes and retire out-of-order if
|
an instruction is allowed to commit writes and retire out-of-order if
|
||||||
``RetireOOO`` property is true for at least one of its writes.
|
``RetireOOO`` property is true for at least one of its writes.
|
||||||
|
|
||||||
|
Custom Behaviour
|
||||||
|
""""""""""""""""""""""""""""""""""""
|
||||||
|
Due to certain instructions not being expressed perfectly within their
|
||||||
|
scheduling model, :program:`llvm-ma` isn't always able to simulate them
|
||||||
|
perfectly. Modifying the scheduling model isn't always a viable
|
||||||
|
option though (maybe because the instruction is modeled incorrectly on
|
||||||
|
purpose or the instruction's behaviour is quite complex). The
|
||||||
|
CustomBehaviour class can be used in these cases to enforce proper
|
||||||
|
instruction modeling (often by customizing data dependencies and detecting
|
||||||
|
hazards that :program:`llvm-ma` has no way of knowing about).
|
||||||
|
|
||||||
|
:program:`llvm-mca` comes with one generic and multiple target specific
|
||||||
|
CustomBehaviour classes. The generic class will be used if the ``-disable-cb``
|
||||||
|
flag is used or if a target specific CustomBehaviour class doesn't exist for
|
||||||
|
that target. (The generic class does nothing.) Currently, the CustomBehaviour
|
||||||
|
class is only a part of the in-order pipeline, but there are plans to add it
|
||||||
|
to the out-of-order pipeline in the future.
|
||||||
|
|
||||||
|
CustomBehaviour's main method is `checkCustomHazard()` which uses the
|
||||||
|
current instruction and a list of all instructions still executing within
|
||||||
|
the pipeline to determine if the current instruction should be dispatched.
|
||||||
|
As output, the method returns an integer representing the number of cycles
|
||||||
|
that the current instruction must stall for (this can be an underestimate
|
||||||
|
if you don't know the exact number and a value of 0 represents no stall).
|
||||||
|
|
||||||
|
If you'd like to add a CustomBehaviour class for a target that doesn't
|
||||||
|
already have one, refer to an existing implementation to see how to set it
|
||||||
|
up. Remember to look at (and add to) `/llvm-mca/lib/CMakeLists.txt`.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/MC/MCSubtargetInfo.h"
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
|
#include "llvm/MCA/CustomBehaviour.h"
|
||||||
#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
|
#include "llvm/MCA/HardwareUnits/HardwareUnit.h"
|
||||||
#include "llvm/MCA/Pipeline.h"
|
#include "llvm/MCA/Pipeline.h"
|
||||||
#include "llvm/MCA/SourceMgr.h"
|
#include "llvm/MCA/SourceMgr.h"
|
||||||
@ -67,12 +68,14 @@ public:
|
|||||||
/// Construct a basic pipeline for simulating an out-of-order pipeline.
|
/// Construct a basic pipeline for simulating an out-of-order pipeline.
|
||||||
/// This pipeline consists of Fetch, Dispatch, Execute, and Retire stages.
|
/// This pipeline consists of Fetch, Dispatch, Execute, and Retire stages.
|
||||||
std::unique_ptr<Pipeline> createDefaultPipeline(const PipelineOptions &Opts,
|
std::unique_ptr<Pipeline> createDefaultPipeline(const PipelineOptions &Opts,
|
||||||
SourceMgr &SrcMgr);
|
SourceMgr &SrcMgr,
|
||||||
|
CustomBehaviour &CB);
|
||||||
|
|
||||||
/// Construct a basic pipeline for simulating an in-order pipeline.
|
/// Construct a basic pipeline for simulating an in-order pipeline.
|
||||||
/// This pipeline consists of Fetch, InOrderIssue, and Retire stages.
|
/// This pipeline consists of Fetch, InOrderIssue, and Retire stages.
|
||||||
std::unique_ptr<Pipeline> createInOrderPipeline(const PipelineOptions &Opts,
|
std::unique_ptr<Pipeline> createInOrderPipeline(const PipelineOptions &Opts,
|
||||||
SourceMgr &SrcMgr);
|
SourceMgr &SrcMgr,
|
||||||
|
CustomBehaviour &CB);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mca
|
} // namespace mca
|
||||||
|
86
include/llvm/MCA/CustomBehaviour.h
Normal file
86
include/llvm/MCA/CustomBehaviour.h
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
//===---------------------- CustomBehaviour.h -------------------*- 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 base class CustomBehaviour which can be inherited from
|
||||||
|
/// by specific targets (ex. llvm/tools/llvm-mca/lib/X86CustomBehaviour.h).
|
||||||
|
/// CustomBehaviour is designed to enforce custom behaviour and dependencies
|
||||||
|
/// within the llvm-mca pipeline simulation that llvm-mca isn't already capable
|
||||||
|
/// of extracting from the Scheduling Models.
|
||||||
|
///
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_MCA_CUSTOMBEHAVIOUR_H
|
||||||
|
#define LLVM_MCA_CUSTOMBEHAVIOUR_H
|
||||||
|
|
||||||
|
#include "llvm/MC/MCInst.h"
|
||||||
|
#include "llvm/MC/MCInstrInfo.h"
|
||||||
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
|
#include "llvm/MCA/SourceMgr.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace mca {
|
||||||
|
|
||||||
|
/// Class which can be overriden by targets to modify the
|
||||||
|
/// mca::Instruction objects before the pipeline starts.
|
||||||
|
/// A common usage of this class is to add immediate operands to certain
|
||||||
|
/// instructions or to remove Defs/Uses from an instruction where the
|
||||||
|
/// schedulinng model is incorrect.
|
||||||
|
class InstrPostProcess {
|
||||||
|
protected:
|
||||||
|
const MCSubtargetInfo &STI;
|
||||||
|
const MCInstrInfo &MCII;
|
||||||
|
|
||||||
|
public:
|
||||||
|
InstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
|
||||||
|
: STI(STI), MCII(MCII) {}
|
||||||
|
|
||||||
|
virtual ~InstrPostProcess() {}
|
||||||
|
|
||||||
|
virtual void postProcessInstruction(std::unique_ptr<Instruction> &Inst,
|
||||||
|
const MCInst &MCI) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Class which can be overriden by targets to enforce instruction
|
||||||
|
/// dependencies and behaviours that aren't expressed well enough
|
||||||
|
/// within the scheduling model for mca to automatically simulate
|
||||||
|
/// them properly.
|
||||||
|
/// If you implement this class for your target, make sure to also implement
|
||||||
|
/// a target specific InstrPostProcess class as well.
|
||||||
|
class CustomBehaviour {
|
||||||
|
protected:
|
||||||
|
const MCSubtargetInfo &STI;
|
||||||
|
const SourceMgr &SrcMgr;
|
||||||
|
const MCInstrInfo &MCII;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CustomBehaviour(const MCSubtargetInfo &STI, const SourceMgr &SrcMgr,
|
||||||
|
const MCInstrInfo &MCII)
|
||||||
|
: STI(STI), SrcMgr(SrcMgr), MCII(MCII) {}
|
||||||
|
|
||||||
|
virtual ~CustomBehaviour() {}
|
||||||
|
|
||||||
|
// Before the llvm-mca pipeline dispatches an instruction, it first checks
|
||||||
|
// for any register or resource dependencies / hazards. If it doesn't find
|
||||||
|
// any, this method will be invoked to determine if there are any custom
|
||||||
|
// hazards that the instruction needs to wait for.
|
||||||
|
// The return value of this method is the number of cycles that the
|
||||||
|
// instruction needs to wait for.
|
||||||
|
// It's safe to underestimate the number of cycles to wait for since these
|
||||||
|
// checks will be invoked again before the intruction gets dispatched.
|
||||||
|
// However, it's not safe (accurate) to overestimate the number of cycles
|
||||||
|
// to wait for since the instruction will wait for AT LEAST that number of
|
||||||
|
// cycles before attempting to be dispatched again.
|
||||||
|
virtual unsigned checkCustomHazard(ArrayRef<InstRef> IssuedInst,
|
||||||
|
const InstRef &IR);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mca
|
||||||
|
} // namespace llvm
|
||||||
|
|
||||||
|
#endif /* LLVM_MCA_CUSTOMBEHAVIOUR_H */
|
@ -115,6 +115,7 @@ public:
|
|||||||
SchedulerQueueFull,
|
SchedulerQueueFull,
|
||||||
LoadQueueFull,
|
LoadQueueFull,
|
||||||
StoreQueueFull,
|
StoreQueueFull,
|
||||||
|
CustomBehaviourStall,
|
||||||
LastGenericEvent
|
LastGenericEvent
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +33,104 @@ namespace mca {
|
|||||||
|
|
||||||
constexpr int UNKNOWN_CYCLES = -512;
|
constexpr int UNKNOWN_CYCLES = -512;
|
||||||
|
|
||||||
|
/// A representation of an mca::Instruction operand
|
||||||
|
/// for use in mca::CustomBehaviour.
|
||||||
|
class MCAOperand {
|
||||||
|
// This class is mostly copied from MCOperand within
|
||||||
|
// MCInst.h except that we don't keep track of
|
||||||
|
// expressions or sub-instructions.
|
||||||
|
enum MCAOperandType : unsigned char {
|
||||||
|
kInvalid, ///< Uninitialized, Relocatable immediate, or Sub-instruction.
|
||||||
|
kRegister, ///< Register operand.
|
||||||
|
kImmediate, ///< Immediate operand.
|
||||||
|
kSFPImmediate, ///< Single-floating-point immediate operand.
|
||||||
|
kDFPImmediate, ///< Double-Floating-point immediate operand.
|
||||||
|
};
|
||||||
|
MCAOperandType Kind = kInvalid;
|
||||||
|
|
||||||
|
union {
|
||||||
|
unsigned RegVal;
|
||||||
|
int64_t ImmVal;
|
||||||
|
uint32_t SFPImmVal;
|
||||||
|
uint64_t FPImmVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
// We only store specific operands for specific instructions
|
||||||
|
// so an instruction's operand 3 may be stored within the list
|
||||||
|
// of MCAOperand as element 0. This Index attribute keeps track
|
||||||
|
// of the original index (3 for this example).
|
||||||
|
unsigned Index;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MCAOperand() : FPImmVal(0) {}
|
||||||
|
|
||||||
|
bool isValid() const { return Kind != kInvalid; }
|
||||||
|
bool isReg() const { return Kind == kRegister; }
|
||||||
|
bool isImm() const { return Kind == kImmediate; }
|
||||||
|
bool isSFPImm() const { return Kind == kSFPImmediate; }
|
||||||
|
bool isDFPImm() const { return Kind == kDFPImmediate; }
|
||||||
|
|
||||||
|
/// Returns the register number.
|
||||||
|
unsigned getReg() const {
|
||||||
|
assert(isReg() && "This is not a register operand!");
|
||||||
|
return RegVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t getImm() const {
|
||||||
|
assert(isImm() && "This is not an immediate");
|
||||||
|
return ImmVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getSFPImm() const {
|
||||||
|
assert(isSFPImm() && "This is not an SFP immediate");
|
||||||
|
return SFPImmVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t getDFPImm() const {
|
||||||
|
assert(isDFPImm() && "This is not an FP immediate");
|
||||||
|
return FPImmVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setIndex(const unsigned Idx) { Index = Idx; }
|
||||||
|
|
||||||
|
unsigned getIndex() const { return Index; }
|
||||||
|
|
||||||
|
static MCAOperand createReg(unsigned Reg) {
|
||||||
|
MCAOperand Op;
|
||||||
|
Op.Kind = kRegister;
|
||||||
|
Op.RegVal = Reg;
|
||||||
|
return Op;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MCAOperand createImm(int64_t Val) {
|
||||||
|
MCAOperand Op;
|
||||||
|
Op.Kind = kImmediate;
|
||||||
|
Op.ImmVal = Val;
|
||||||
|
return Op;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MCAOperand createSFPImm(uint32_t Val) {
|
||||||
|
MCAOperand Op;
|
||||||
|
Op.Kind = kSFPImmediate;
|
||||||
|
Op.SFPImmVal = Val;
|
||||||
|
return Op;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MCAOperand createDFPImm(uint64_t Val) {
|
||||||
|
MCAOperand Op;
|
||||||
|
Op.Kind = kDFPImmediate;
|
||||||
|
Op.FPImmVal = Val;
|
||||||
|
return Op;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MCAOperand createInvalid() {
|
||||||
|
MCAOperand Op;
|
||||||
|
Op.Kind = kInvalid;
|
||||||
|
Op.FPImmVal = 0;
|
||||||
|
return Op;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// A register write descriptor.
|
/// A register write descriptor.
|
||||||
struct WriteDescriptor {
|
struct WriteDescriptor {
|
||||||
// Operand index. The index is negative for implicit writes only.
|
// Operand index. The index is negative for implicit writes only.
|
||||||
@ -160,6 +258,7 @@ public:
|
|||||||
int getCyclesLeft() const { return CyclesLeft; }
|
int getCyclesLeft() const { return CyclesLeft; }
|
||||||
unsigned getWriteResourceID() const { return WD->SClassOrWriteResourceID; }
|
unsigned getWriteResourceID() const { return WD->SClassOrWriteResourceID; }
|
||||||
MCPhysReg getRegisterID() const { return RegisterID; }
|
MCPhysReg getRegisterID() const { return RegisterID; }
|
||||||
|
void setRegisterID(const MCPhysReg RegID) { RegisterID = RegID; }
|
||||||
unsigned getRegisterFileID() const { return PRFID; }
|
unsigned getRegisterFileID() const { return PRFID; }
|
||||||
unsigned getLatency() const { return WD->Latency; }
|
unsigned getLatency() const { return WD->Latency; }
|
||||||
unsigned getDependentWriteCyclesLeft() const {
|
unsigned getDependentWriteCyclesLeft() const {
|
||||||
@ -412,8 +511,15 @@ class InstructionBase {
|
|||||||
// One entry per each implicit and explicit register use.
|
// One entry per each implicit and explicit register use.
|
||||||
SmallVector<ReadState, 4> Uses;
|
SmallVector<ReadState, 4> Uses;
|
||||||
|
|
||||||
|
// List of operands which can be used by mca::CustomBehaviour
|
||||||
|
std::vector<MCAOperand> Operands;
|
||||||
|
|
||||||
|
// Instruction opcode which can be used by mca::CustomBehaviour
|
||||||
|
unsigned Opcode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InstructionBase(const InstrDesc &D) : Desc(D), IsOptimizableMove(false) {}
|
InstructionBase(const InstrDesc &D, const unsigned Opcode)
|
||||||
|
: Desc(D), IsOptimizableMove(false), Operands(0), Opcode(Opcode) {}
|
||||||
|
|
||||||
SmallVectorImpl<WriteState> &getDefs() { return Defs; }
|
SmallVectorImpl<WriteState> &getDefs() { return Defs; }
|
||||||
ArrayRef<WriteState> getDefs() const { return Defs; }
|
ArrayRef<WriteState> getDefs() const { return Defs; }
|
||||||
@ -423,6 +529,20 @@ public:
|
|||||||
|
|
||||||
unsigned getLatency() const { return Desc.MaxLatency; }
|
unsigned getLatency() const { return Desc.MaxLatency; }
|
||||||
unsigned getNumMicroOps() const { return Desc.NumMicroOps; }
|
unsigned getNumMicroOps() const { return Desc.NumMicroOps; }
|
||||||
|
unsigned getOpcode() const { return Opcode; }
|
||||||
|
|
||||||
|
/// Return the MCAOperand which corresponds to index Idx within the original
|
||||||
|
/// MCInst.
|
||||||
|
const MCAOperand *getOperand(const unsigned Idx) const {
|
||||||
|
auto It = std::find_if(
|
||||||
|
Operands.begin(), Operands.end(),
|
||||||
|
[&Idx](const MCAOperand &Op) { return Op.getIndex() == Idx; });
|
||||||
|
if (It == Operands.end())
|
||||||
|
return nullptr;
|
||||||
|
return &(*It);
|
||||||
|
}
|
||||||
|
unsigned getNumOperands() const { return Operands.size(); }
|
||||||
|
void addOperand(const MCAOperand Op) { Operands.push_back(Op); }
|
||||||
|
|
||||||
bool hasDependentUsers() const {
|
bool hasDependentUsers() const {
|
||||||
return any_of(Defs,
|
return any_of(Defs,
|
||||||
@ -493,11 +613,11 @@ class Instruction : public InstructionBase {
|
|||||||
bool IsEliminated;
|
bool IsEliminated;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Instruction(const InstrDesc &D)
|
Instruction(const InstrDesc &D, const unsigned Opcode)
|
||||||
: InstructionBase(D), Stage(IS_INVALID), CyclesLeft(UNKNOWN_CYCLES),
|
: InstructionBase(D, Opcode), Stage(IS_INVALID),
|
||||||
RCUTokenID(0), LSUTokenID(0), UsedBuffers(D.UsedBuffers),
|
CyclesLeft(UNKNOWN_CYCLES), RCUTokenID(0), LSUTokenID(0),
|
||||||
CriticalRegDep(), CriticalMemDep(), CriticalResourceMask(0),
|
UsedBuffers(D.UsedBuffers), CriticalRegDep(), CriticalMemDep(),
|
||||||
IsEliminated(false) {}
|
CriticalResourceMask(0), IsEliminated(false) {}
|
||||||
|
|
||||||
unsigned getRCUTokenID() const { return RCUTokenID; }
|
unsigned getRCUTokenID() const { return RCUTokenID; }
|
||||||
unsigned getLSUTokenID() const { return LSUTokenID; }
|
unsigned getLSUTokenID() const { return LSUTokenID; }
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef LLVM_MCA_STAGES_INORDERISSUESTAGE_H
|
#ifndef LLVM_MCA_STAGES_INORDERISSUESTAGE_H
|
||||||
#define LLVM_MCA_STAGES_INORDERISSUESTAGE_H
|
#define LLVM_MCA_STAGES_INORDERISSUESTAGE_H
|
||||||
|
|
||||||
|
#include "llvm/MCA/CustomBehaviour.h"
|
||||||
#include "llvm/MCA/HardwareUnits/ResourceManager.h"
|
#include "llvm/MCA/HardwareUnits/ResourceManager.h"
|
||||||
#include "llvm/MCA/SourceMgr.h"
|
#include "llvm/MCA/SourceMgr.h"
|
||||||
#include "llvm/MCA/Stages/Stage.h"
|
#include "llvm/MCA/Stages/Stage.h"
|
||||||
@ -23,7 +24,13 @@ namespace mca {
|
|||||||
class RegisterFile;
|
class RegisterFile;
|
||||||
|
|
||||||
struct StallInfo {
|
struct StallInfo {
|
||||||
enum class StallKind { DEFAULT, REGISTER_DEPS, DISPATCH, DELAY };
|
enum class StallKind {
|
||||||
|
DEFAULT,
|
||||||
|
REGISTER_DEPS,
|
||||||
|
DISPATCH,
|
||||||
|
DELAY,
|
||||||
|
CUSTOM_STALL
|
||||||
|
};
|
||||||
|
|
||||||
InstRef IR;
|
InstRef IR;
|
||||||
unsigned CyclesLeft;
|
unsigned CyclesLeft;
|
||||||
@ -46,6 +53,7 @@ class InOrderIssueStage final : public Stage {
|
|||||||
const MCSubtargetInfo &STI;
|
const MCSubtargetInfo &STI;
|
||||||
RegisterFile &PRF;
|
RegisterFile &PRF;
|
||||||
ResourceManager RM;
|
ResourceManager RM;
|
||||||
|
CustomBehaviour &CB;
|
||||||
|
|
||||||
/// Instructions that were issued, but not executed yet.
|
/// Instructions that were issued, but not executed yet.
|
||||||
SmallVector<InstRef, 4> IssuedInst;
|
SmallVector<InstRef, 4> IssuedInst;
|
||||||
@ -101,7 +109,8 @@ class InOrderIssueStage final : public Stage {
|
|||||||
void retireInstruction(InstRef &IR);
|
void retireInstruction(InstRef &IR);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InOrderIssueStage(const MCSubtargetInfo &STI, RegisterFile &PRF);
|
InOrderIssueStage(const MCSubtargetInfo &STI, RegisterFile &PRF,
|
||||||
|
CustomBehaviour &CB);
|
||||||
|
|
||||||
unsigned getIssueWidth() const;
|
unsigned getIssueWidth() const;
|
||||||
bool isAvailable(const InstRef &) const override;
|
bool isAvailable(const InstRef &) const override;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
add_llvm_component_library(LLVMMCA
|
add_llvm_component_library(LLVMMCA
|
||||||
CodeEmitter.cpp
|
CodeEmitter.cpp
|
||||||
Context.cpp
|
Context.cpp
|
||||||
|
CustomBehaviour.cpp
|
||||||
HWEventListener.cpp
|
HWEventListener.cpp
|
||||||
HardwareUnits/HardwareUnit.cpp
|
HardwareUnits/HardwareUnit.cpp
|
||||||
HardwareUnits/LSUnit.cpp
|
HardwareUnits/LSUnit.cpp
|
||||||
|
@ -29,11 +29,12 @@ namespace llvm {
|
|||||||
namespace mca {
|
namespace mca {
|
||||||
|
|
||||||
std::unique_ptr<Pipeline>
|
std::unique_ptr<Pipeline>
|
||||||
Context::createDefaultPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr) {
|
Context::createDefaultPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr,
|
||||||
|
CustomBehaviour &CB) {
|
||||||
const MCSchedModel &SM = STI.getSchedModel();
|
const MCSchedModel &SM = STI.getSchedModel();
|
||||||
|
|
||||||
if (!SM.isOutOfOrder())
|
if (!SM.isOutOfOrder())
|
||||||
return createInOrderPipeline(Opts, SrcMgr);
|
return createInOrderPipeline(Opts, SrcMgr, CB);
|
||||||
|
|
||||||
// Create the hardware units defining the backend.
|
// Create the hardware units defining the backend.
|
||||||
auto RCU = std::make_unique<RetireControlUnit>(SM);
|
auto RCU = std::make_unique<RetireControlUnit>(SM);
|
||||||
@ -69,13 +70,14 @@ Context::createDefaultPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Pipeline>
|
std::unique_ptr<Pipeline>
|
||||||
Context::createInOrderPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr) {
|
Context::createInOrderPipeline(const PipelineOptions &Opts, SourceMgr &SrcMgr,
|
||||||
|
CustomBehaviour &CB) {
|
||||||
const MCSchedModel &SM = STI.getSchedModel();
|
const MCSchedModel &SM = STI.getSchedModel();
|
||||||
auto PRF = std::make_unique<RegisterFile>(SM, MRI, Opts.RegisterFileSize);
|
auto PRF = std::make_unique<RegisterFile>(SM, MRI, Opts.RegisterFileSize);
|
||||||
|
|
||||||
// Create the pipeline stages.
|
// Create the pipeline stages.
|
||||||
auto Entry = std::make_unique<EntryStage>(SrcMgr);
|
auto Entry = std::make_unique<EntryStage>(SrcMgr);
|
||||||
auto InOrderIssue = std::make_unique<InOrderIssueStage>(STI, *PRF);
|
auto InOrderIssue = std::make_unique<InOrderIssueStage>(STI, *PRF, CB);
|
||||||
auto StagePipeline = std::make_unique<Pipeline>();
|
auto StagePipeline = std::make_unique<Pipeline>();
|
||||||
|
|
||||||
// Pass the ownership of all the hardware units to this Context.
|
// Pass the ownership of all the hardware units to this Context.
|
||||||
|
26
lib/MCA/CustomBehaviour.cpp
Normal file
26
lib/MCA/CustomBehaviour.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//===--------------------- CustomBehaviour.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 implements methods from the CustomBehaviour interface.
|
||||||
|
///
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/MCA/CustomBehaviour.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace mca {
|
||||||
|
|
||||||
|
unsigned CustomBehaviour::checkCustomHazard(ArrayRef<InstRef> IssuedInst,
|
||||||
|
const InstRef &IR) {
|
||||||
|
// 0 signifies that there are no hazards that need to be waited on
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mca
|
||||||
|
} // namespace llvm
|
@ -644,7 +644,8 @@ InstrBuilder::createInstruction(const MCInst &MCI) {
|
|||||||
if (!DescOrErr)
|
if (!DescOrErr)
|
||||||
return DescOrErr.takeError();
|
return DescOrErr.takeError();
|
||||||
const InstrDesc &D = *DescOrErr;
|
const InstrDesc &D = *DescOrErr;
|
||||||
std::unique_ptr<Instruction> NewIS = std::make_unique<Instruction>(D);
|
std::unique_ptr<Instruction> NewIS =
|
||||||
|
std::make_unique<Instruction>(D, MCI.getOpcode());
|
||||||
|
|
||||||
// Check if this is a dependency breaking instruction.
|
// Check if this is a dependency breaking instruction.
|
||||||
APInt Mask;
|
APInt Mask;
|
||||||
|
@ -43,8 +43,8 @@ void StallInfo::cycleEnd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InOrderIssueStage::InOrderIssueStage(const MCSubtargetInfo &STI,
|
InOrderIssueStage::InOrderIssueStage(const MCSubtargetInfo &STI,
|
||||||
RegisterFile &PRF)
|
RegisterFile &PRF, CustomBehaviour &CB)
|
||||||
: STI(STI), PRF(PRF), RM(STI.getSchedModel()), NumIssued(), SI(),
|
: STI(STI), PRF(PRF), RM(STI.getSchedModel()), CB(CB), NumIssued(), SI(),
|
||||||
CarryOver(), Bandwidth(), LastWriteBackCycle() {}
|
CarryOver(), Bandwidth(), LastWriteBackCycle() {}
|
||||||
|
|
||||||
unsigned InOrderIssueStage::getIssueWidth() const {
|
unsigned InOrderIssueStage::getIssueWidth() const {
|
||||||
@ -125,6 +125,11 @@ bool InOrderIssueStage::canExecute(const InstRef &IR) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unsigned CustomStallCycles = CB.checkCustomHazard(IssuedInst, IR)) {
|
||||||
|
SI.update(IR, CustomStallCycles, StallInfo::StallKind::CUSTOM_STALL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (LastWriteBackCycle) {
|
if (LastWriteBackCycle) {
|
||||||
if (!IR.getInstruction()->getDesc().RetireOOO) {
|
if (!IR.getInstruction()->getDesc().RetireOOO) {
|
||||||
unsigned NextWriteBackCycle = findFirstWriteBackCycle(IR);
|
unsigned NextWriteBackCycle = findFirstWriteBackCycle(IR);
|
||||||
@ -333,6 +338,11 @@ void InOrderIssueStage::notifyStallEvent() {
|
|||||||
HWPressureEvent(HWPressureEvent::RESOURCES, IR));
|
HWPressureEvent(HWPressureEvent::RESOURCES, IR));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StallInfo::StallKind::CUSTOM_STALL: {
|
||||||
|
notifyEvent<HWStallEvent>(
|
||||||
|
HWStallEvent(HWStallEvent::CustomBehaviourStall, IR));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
|
add_subdirectory(lib)
|
||||||
|
|
||||||
set(LLVM_LINK_COMPONENTS
|
set(LLVM_LINK_COMPONENTS
|
||||||
AllTargetsAsmParsers
|
AllTargetsAsmParsers
|
||||||
AllTargetsDescs
|
AllTargetsDescs
|
||||||
@ -30,3 +32,9 @@ add_llvm_tool(llvm-mca
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(LLVM_MCA_SOURCE_DIR ${CURRENT_SOURCE_DIR})
|
set(LLVM_MCA_SOURCE_DIR ${CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
target_link_libraries(llvm-mca PRIVATE
|
||||||
|
${LLVM_MCA_CUSTOMBEHAVIOUR_TARGETS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(${LLVM_MCA_MACROS_TO_DEFINE})
|
||||||
|
@ -77,6 +77,8 @@ void DispatchStatistics::printDispatchStalls(raw_ostream &OS) const {
|
|||||||
printStalls(SS, HWStalls[HWStallEvent::StoreQueueFull], NumCycles);
|
printStalls(SS, HWStalls[HWStallEvent::StoreQueueFull], NumCycles);
|
||||||
SS << "\nGROUP - Static restrictions on the dispatch group: ";
|
SS << "\nGROUP - Static restrictions on the dispatch group: ";
|
||||||
printStalls(SS, HWStalls[HWStallEvent::DispatchGroupStall], NumCycles);
|
printStalls(SS, HWStalls[HWStallEvent::DispatchGroupStall], NumCycles);
|
||||||
|
SS << "\nUSH - Uncategorised Structural Hazard: ";
|
||||||
|
printStalls(SS, HWStalls[HWStallEvent::CustomBehaviourStall], NumCycles);
|
||||||
SS << '\n';
|
SS << '\n';
|
||||||
SS.flush();
|
SS.flush();
|
||||||
OS << Buffer;
|
OS << Buffer;
|
||||||
|
33
tools/llvm-mca/lib/AMDGPU/AMDGPUCustomBehaviour.cpp
Normal file
33
tools/llvm-mca/lib/AMDGPU/AMDGPUCustomBehaviour.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//===------------------ AMDGPUCustomBehaviour.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 implements methods from the AMDGPUCustomBehaviour class.
|
||||||
|
///
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "AMDGPUCustomBehaviour.h"
|
||||||
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
||||||
|
#include "SIInstrInfo.h"
|
||||||
|
#include "llvm/Support/WithColor.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace mca {
|
||||||
|
|
||||||
|
AMDGPUCustomBehaviour::AMDGPUCustomBehaviour(const MCSubtargetInfo &STI,
|
||||||
|
const SourceMgr &SrcMgr,
|
||||||
|
const MCInstrInfo &MCII)
|
||||||
|
: CustomBehaviour(STI, SrcMgr, MCII) {}
|
||||||
|
|
||||||
|
unsigned AMDGPUCustomBehaviour::checkCustomHazard(ArrayRef<InstRef> IssuedInst,
|
||||||
|
const InstRef &IR) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mca
|
||||||
|
} // namespace llvm
|
57
tools/llvm-mca/lib/AMDGPU/AMDGPUCustomBehaviour.h
Normal file
57
tools/llvm-mca/lib/AMDGPU/AMDGPUCustomBehaviour.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
//===------------------- AMDGPUCustomBehaviour.h ----------------*-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 AMDGPUCustomBehaviour class which inherits from
|
||||||
|
/// CustomBehaviour.
|
||||||
|
///
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_TOOLS_LLVM_MCA_LIB_AMDGPU_AMDGPUCUSTOMBEHAVIOUR_H
|
||||||
|
#define LLVM_TOOLS_LLVM_MCA_LIB_AMDGPU_AMDGPUCUSTOMBEHAVIOUR_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/MCA/CustomBehaviour.h"
|
||||||
|
#include "llvm/Support/TargetParser.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace mca {
|
||||||
|
|
||||||
|
class AMDGPUInstrPostProcess : public InstrPostProcess {
|
||||||
|
public:
|
||||||
|
AMDGPUInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
|
||||||
|
: InstrPostProcess(STI, MCII) {}
|
||||||
|
|
||||||
|
~AMDGPUInstrPostProcess() {}
|
||||||
|
|
||||||
|
void postProcessInstruction(std::unique_ptr<Instruction> &Inst,
|
||||||
|
const MCInst &MCI) override {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class AMDGPUCustomBehaviour : public CustomBehaviour {
|
||||||
|
public:
|
||||||
|
AMDGPUCustomBehaviour(const MCSubtargetInfo &STI, const SourceMgr &SrcMgr,
|
||||||
|
const MCInstrInfo &MCII);
|
||||||
|
|
||||||
|
~AMDGPUCustomBehaviour() {}
|
||||||
|
|
||||||
|
/// This method is used to determine if an instruction
|
||||||
|
/// should be allowed to be dispatched. The return value is
|
||||||
|
/// how many cycles until the instruction can be dispatched.
|
||||||
|
/// This method is called after MCA has already checked for
|
||||||
|
/// register and hardware dependencies so this method should only
|
||||||
|
/// implement custom behaviour and dependencies that are not picked up
|
||||||
|
/// by MCA naturally.
|
||||||
|
unsigned checkCustomHazard(ArrayRef<InstRef> IssuedInst,
|
||||||
|
const InstRef &IR) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mca
|
||||||
|
} // namespace llvm
|
||||||
|
|
||||||
|
#endif /* LLVM_TOOLS_LLVM_MCA_LIB_AMDGPU_AMDGPUCUSTOMBEHAVIOUR_H */
|
17
tools/llvm-mca/lib/AMDGPU/CMakeLists.txt
Normal file
17
tools/llvm-mca/lib/AMDGPU/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
include_directories(
|
||||||
|
${LLVM_MAIN_SRC_DIR}/lib/Target/AMDGPU
|
||||||
|
${LLVM_BINARY_DIR}/lib/Target/AMDGPU
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LLVM_LINK_COMPONENTS
|
||||||
|
AMDGPU
|
||||||
|
Core
|
||||||
|
Support
|
||||||
|
)
|
||||||
|
|
||||||
|
add_llvm_library(LLVMMCACustomBehaviourAMDGPU
|
||||||
|
AMDGPUCustomBehaviour.cpp
|
||||||
|
|
||||||
|
DEPENDS
|
||||||
|
AMDGPUCommonTableGen
|
||||||
|
)
|
11
tools/llvm-mca/lib/CMakeLists.txt
Normal file
11
tools/llvm-mca/lib/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
set(TARGETS_TO_APPEND "")
|
||||||
|
set(MACROS_TO_APPEND "")
|
||||||
|
|
||||||
|
if (LLVM_TARGETS_TO_BUILD MATCHES "AMDGPU")
|
||||||
|
add_subdirectory(AMDGPU)
|
||||||
|
list(APPEND TARGETS_TO_APPEND LLVMMCACustomBehaviourAMDGPU)
|
||||||
|
list(APPEND MACROS_TO_APPEND -DHAS_AMDGPU)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LLVM_MCA_CUSTOMBEHAVIOUR_TARGETS ${TARGETS_TO_APPEND} PARENT_SCOPE)
|
||||||
|
set(LLVM_MCA_MACROS_TO_DEFINE ${MACROS_TO_APPEND} PARENT_SCOPE)
|
@ -32,6 +32,9 @@
|
|||||||
#include "Views/SchedulerStatistics.h"
|
#include "Views/SchedulerStatistics.h"
|
||||||
#include "Views/SummaryView.h"
|
#include "Views/SummaryView.h"
|
||||||
#include "Views/TimelineView.h"
|
#include "Views/TimelineView.h"
|
||||||
|
#ifdef HAS_AMDGPU
|
||||||
|
#include "lib/AMDGPU/AMDGPUCustomBehaviour.h"
|
||||||
|
#endif
|
||||||
#include "llvm/MC/MCAsmBackend.h"
|
#include "llvm/MC/MCAsmBackend.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCCodeEmitter.h"
|
#include "llvm/MC/MCCodeEmitter.h"
|
||||||
@ -42,6 +45,7 @@
|
|||||||
#include "llvm/MC/MCTargetOptionsCommandFlags.h"
|
#include "llvm/MC/MCTargetOptionsCommandFlags.h"
|
||||||
#include "llvm/MCA/CodeEmitter.h"
|
#include "llvm/MCA/CodeEmitter.h"
|
||||||
#include "llvm/MCA/Context.h"
|
#include "llvm/MCA/Context.h"
|
||||||
|
#include "llvm/MCA/CustomBehaviour.h"
|
||||||
#include "llvm/MCA/InstrBuilder.h"
|
#include "llvm/MCA/InstrBuilder.h"
|
||||||
#include "llvm/MCA/Pipeline.h"
|
#include "llvm/MCA/Pipeline.h"
|
||||||
#include "llvm/MCA/Stages/EntryStage.h"
|
#include "llvm/MCA/Stages/EntryStage.h"
|
||||||
@ -220,6 +224,12 @@ static cl::opt<bool> ShowEncoding(
|
|||||||
cl::desc("Print encoding information in the instruction info view"),
|
cl::desc("Print encoding information in the instruction info view"),
|
||||||
cl::cat(ViewOptions), cl::init(false));
|
cl::cat(ViewOptions), cl::init(false));
|
||||||
|
|
||||||
|
static cl::opt<bool> DisableCustomBehaviour(
|
||||||
|
"disable-cb",
|
||||||
|
cl::desc(
|
||||||
|
"Disable custom behaviour (use the default class which does nothing)."),
|
||||||
|
cl::cat(ViewOptions), cl::init(false));
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const Target *getTarget(const char *ProgName) {
|
const Target *getTarget(const char *ProgName) {
|
||||||
@ -285,6 +295,39 @@ static void processViewOptions(bool IsOutOfOrder) {
|
|||||||
processOptionImpl(PrintRetireStats, Default);
|
processOptionImpl(PrintRetireStats, Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<mca::InstrPostProcess>
|
||||||
|
createInstrPostProcess(const Triple &TheTriple, const MCSubtargetInfo &STI,
|
||||||
|
const MCInstrInfo &MCII) {
|
||||||
|
// Might be a good idea to have a separate flag so that InstrPostProcess
|
||||||
|
// can be used with or without CustomBehaviour
|
||||||
|
if (DisableCustomBehaviour)
|
||||||
|
return std::make_unique<mca::InstrPostProcess>(STI, MCII);
|
||||||
|
#ifdef HAS_AMDGPU
|
||||||
|
if (TheTriple.isAMDGPU())
|
||||||
|
return std::make_unique<mca::AMDGPUInstrPostProcess>(STI, MCII);
|
||||||
|
#endif
|
||||||
|
return std::make_unique<mca::InstrPostProcess>(STI, MCII);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<mca::CustomBehaviour>
|
||||||
|
createCustomBehaviour(const Triple &TheTriple, const MCSubtargetInfo &STI,
|
||||||
|
const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) {
|
||||||
|
// Build the appropriate CustomBehaviour object for the current target.
|
||||||
|
// The CustomBehaviour class should never depend on the source code,
|
||||||
|
// but it can depend on the list of mca::Instruction and any classes
|
||||||
|
// that can be built using just the target info. If you need extra
|
||||||
|
// information from the source code or the list of MCInst, consider
|
||||||
|
// adding that information to the mca::Instruction class and setting
|
||||||
|
// it during InstrBuilder::createInstruction().
|
||||||
|
if (DisableCustomBehaviour)
|
||||||
|
return std::make_unique<mca::CustomBehaviour>(STI, SrcMgr, MCII);
|
||||||
|
#ifdef HAS_AMDGPU
|
||||||
|
if (TheTriple.isAMDGPU())
|
||||||
|
return std::make_unique<mca::AMDGPUCustomBehaviour>(STI, SrcMgr, MCII);
|
||||||
|
#endif
|
||||||
|
return std::make_unique<mca::CustomBehaviour>(STI, SrcMgr, MCII);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true on success.
|
// Returns true on success.
|
||||||
static bool runPipeline(mca::Pipeline &P) {
|
static bool runPipeline(mca::Pipeline &P) {
|
||||||
// Handle pipeline errors here.
|
// Handle pipeline errors here.
|
||||||
@ -498,6 +541,8 @@ int main(int argc, char **argv) {
|
|||||||
// Lower the MCInst sequence into an mca::Instruction sequence.
|
// Lower the MCInst sequence into an mca::Instruction sequence.
|
||||||
ArrayRef<MCInst> Insts = Region->getInstructions();
|
ArrayRef<MCInst> Insts = Region->getInstructions();
|
||||||
mca::CodeEmitter CE(*STI, *MAB, *MCE, Insts);
|
mca::CodeEmitter CE(*STI, *MAB, *MCE, Insts);
|
||||||
|
std::unique_ptr<mca::InstrPostProcess> IPP =
|
||||||
|
createInstrPostProcess(TheTriple, *STI, *MCII);
|
||||||
std::vector<std::unique_ptr<mca::Instruction>> LoweredSequence;
|
std::vector<std::unique_ptr<mca::Instruction>> LoweredSequence;
|
||||||
for (const MCInst &MCI : Insts) {
|
for (const MCInst &MCI : Insts) {
|
||||||
Expected<std::unique_ptr<mca::Instruction>> Inst =
|
Expected<std::unique_ptr<mca::Instruction>> Inst =
|
||||||
@ -520,6 +565,8 @@ int main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPP->postProcessInstruction(Inst.get(), MCI);
|
||||||
|
|
||||||
LoweredSequence.emplace_back(std::move(Inst.get()));
|
LoweredSequence.emplace_back(std::move(Inst.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,8 +594,17 @@ int main(int argc, char **argv) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the CustomBehaviour object for enforcing Target Specific
|
||||||
|
// behaviours and dependencies that aren't expressed well enough
|
||||||
|
// in the tablegen. CB cannot depend on the list of MCInst or
|
||||||
|
// the source code (but it can depend on the list of
|
||||||
|
// mca::Instruction or any objects that can be reconstructed
|
||||||
|
// from the target information).
|
||||||
|
std::unique_ptr<mca::CustomBehaviour> CB =
|
||||||
|
createCustomBehaviour(TheTriple, *STI, S, *MCII);
|
||||||
|
|
||||||
// Create a basic pipeline simulating an out-of-order backend.
|
// Create a basic pipeline simulating an out-of-order backend.
|
||||||
auto P = MCA.createDefaultPipeline(PO, S);
|
auto P = MCA.createDefaultPipeline(PO, S, *CB);
|
||||||
mca::PipelinePrinter Printer(*P, PrintJson ? mca::View::OK_JSON
|
mca::PipelinePrinter Printer(*P, PrintJson ? mca::View::OK_JSON
|
||||||
: mca::View::OK_READABLE);
|
: mca::View::OK_READABLE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user