mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
8b4cab0d54
This patch is the last of a sequence of three patches related to LLVM-dev RFC "MC support for variant scheduling classes". http://lists.llvm.org/pipermail/llvm-dev/2018-May/123181.html This fixes PR36672. The main goal of this patch is to teach llvm-mca how to solve variant scheduling classes. This patch does that, plus it adds new variant scheduling classes to the BtVer2 scheduling model to identify so-called zero-idioms (i.e. so-called dependency breaking instructions that are known to generate zero, and that are optimized out in hardware at register renaming stage). Without the BtVer2 change, this patch would not have had any meaningful tests. This patch is effectively the union of two changes: 1) a change that teaches llvm-mca how to resolve variant scheduling classes. 2) a change to the BtVer2 scheduling model that allows us to special-case packed XOR zero-idioms (this partially fixes PR36671). Differential Revision: https://reviews.llvm.org/D47374 llvm-svn: 333909
71 lines
2.5 KiB
C++
71 lines
2.5 KiB
C++
//===--------------------- InstrBuilder.h -----------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
/// \file
|
|
///
|
|
/// A builder class for instructions that are statically analyzed by llvm-mca.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TOOLS_LLVM_MCA_INSTRBUILDER_H
|
|
#define LLVM_TOOLS_LLVM_MCA_INSTRBUILDER_H
|
|
|
|
#include "Instruction.h"
|
|
#include "Support.h"
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
|
|
|
namespace mca {
|
|
|
|
class DispatchUnit;
|
|
|
|
/// A builder class that knows how to construct Instruction objects.
|
|
///
|
|
/// Every llvm-mca Instruction is described by an object of class InstrDesc.
|
|
/// An InstrDesc describes which registers are read/written by the instruction,
|
|
/// as well as the instruction latency and hardware resources consumed.
|
|
///
|
|
/// This class is used by the tool to construct Instructions and instruction
|
|
/// descriptors (i.e. InstrDesc objects).
|
|
/// Information from the machine scheduling model is used to identify processor
|
|
/// resources that are consumed by an instruction.
|
|
class InstrBuilder {
|
|
const llvm::MCSubtargetInfo &STI;
|
|
const llvm::MCInstrInfo &MCII;
|
|
llvm::SmallVector<uint64_t, 8> ProcResourceMasks;
|
|
|
|
llvm::DenseMap<unsigned short, std::unique_ptr<const InstrDesc>> Descriptors;
|
|
llvm::DenseMap<const llvm::MCInst *, std::unique_ptr<const InstrDesc>>
|
|
VariantDescriptors;
|
|
|
|
const InstrDesc &createInstrDescImpl(const llvm::MCInst &MCI);
|
|
InstrBuilder(const InstrBuilder &) = delete;
|
|
InstrBuilder &operator=(const InstrBuilder &) = delete;
|
|
|
|
public:
|
|
InstrBuilder(const llvm::MCSubtargetInfo &sti, const llvm::MCInstrInfo &mcii)
|
|
: STI(sti), MCII(mcii),
|
|
ProcResourceMasks(STI.getSchedModel().getNumProcResourceKinds()) {
|
|
computeProcResourceMasks(STI.getSchedModel(), ProcResourceMasks);
|
|
}
|
|
|
|
const InstrDesc &getOrCreateInstrDesc(const llvm::MCInst &MCI);
|
|
// Returns an array of processor resource masks.
|
|
// Masks are computed by function mca::computeProcResourceMasks. see
|
|
// Support.h for a description of how masks are computed and how masks can be
|
|
// used to solve set membership problems.
|
|
llvm::ArrayRef<uint64_t> getProcResourceMasks() const {
|
|
return ProcResourceMasks;
|
|
}
|
|
|
|
std::unique_ptr<Instruction> createInstruction(const llvm::MCInst &MCI);
|
|
};
|
|
} // namespace mca
|
|
|
|
#endif
|