2011-07-01 20:45:01 +00:00
|
|
|
//==-- llvm/MC/MCSubtargetInfo.h - Subtarget Information ---------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file describes the subtarget options of a Target machine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSUBTARGET_H
|
|
|
|
#define LLVM_MC_MCSUBTARGET_H
|
|
|
|
|
|
|
|
#include "llvm/MC/MCInstrItineraries.h"
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/MC/SubtargetFeature.h"
|
2011-07-11 03:57:24 +00:00
|
|
|
#include <string>
|
2011-07-01 20:45:01 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class StringRef;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// MCSubtargetInfo - Generic base class for all target subtargets.
|
|
|
|
///
|
|
|
|
class MCSubtargetInfo {
|
2011-07-11 03:57:24 +00:00
|
|
|
std::string TargetTriple; // Target triple
|
2011-07-01 20:45:01 +00:00
|
|
|
const SubtargetFeatureKV *ProcFeatures; // Processor feature list
|
|
|
|
const SubtargetFeatureKV *ProcDesc; // Processor descriptions
|
2012-09-14 20:26:41 +00:00
|
|
|
|
|
|
|
// Scheduler machine model
|
|
|
|
const SubtargetInfoKV *ProcSchedModels;
|
|
|
|
const MCWriteProcResEntry *WriteProcResTable;
|
|
|
|
const MCWriteLatencyEntry *WriteLatencyTable;
|
|
|
|
const MCReadAdvanceEntry *ReadAdvanceTable;
|
2012-09-18 03:18:56 +00:00
|
|
|
const MCSchedModel *CPUSchedModel;
|
2012-09-14 20:26:41 +00:00
|
|
|
|
2012-07-07 04:00:00 +00:00
|
|
|
const InstrStage *Stages; // Instruction itinerary stages
|
|
|
|
const unsigned *OperandCycles; // Itinerary operand cycles
|
2012-07-07 03:59:48 +00:00
|
|
|
const unsigned *ForwardingPaths; // Forwarding paths
|
2011-07-01 20:45:01 +00:00
|
|
|
unsigned NumFeatures; // Number of processor features
|
|
|
|
unsigned NumProcs; // Number of processors
|
2011-07-09 05:47:46 +00:00
|
|
|
uint64_t FeatureBits; // Feature bits for current CPU + FS
|
2011-07-07 07:07:08 +00:00
|
|
|
|
2011-07-01 20:45:01 +00:00
|
|
|
public:
|
2011-07-11 03:57:24 +00:00
|
|
|
void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS,
|
2011-07-07 07:07:08 +00:00
|
|
|
const SubtargetFeatureKV *PF,
|
2011-07-01 20:45:01 +00:00
|
|
|
const SubtargetFeatureKV *PD,
|
2012-07-07 04:00:00 +00:00
|
|
|
const SubtargetInfoKV *ProcSched,
|
2012-09-18 03:18:56 +00:00
|
|
|
const MCWriteProcResEntry *WPR,
|
|
|
|
const MCWriteLatencyEntry *WL,
|
|
|
|
const MCReadAdvanceEntry *RA,
|
2012-07-07 04:00:00 +00:00
|
|
|
const InstrStage *IS,
|
2011-07-01 20:45:01 +00:00
|
|
|
const unsigned *OC, const unsigned *FP,
|
2011-07-07 07:07:08 +00:00
|
|
|
unsigned NF, unsigned NP);
|
|
|
|
|
2011-07-11 03:57:24 +00:00
|
|
|
/// getTargetTriple - Return the target triple string.
|
|
|
|
StringRef getTargetTriple() const {
|
|
|
|
return TargetTriple;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getFeatureBits - Return the feature bits.
|
2011-07-07 07:07:08 +00:00
|
|
|
///
|
|
|
|
uint64_t getFeatureBits() const {
|
|
|
|
return FeatureBits;
|
2011-07-01 20:45:01 +00:00
|
|
|
}
|
|
|
|
|
2012-09-18 05:33:15 +00:00
|
|
|
/// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with
|
|
|
|
/// feature string). Recompute feature bits and scheduling model.
|
|
|
|
void InitMCProcessorInfo(StringRef CPU, StringRef FS);
|
2011-07-07 07:07:08 +00:00
|
|
|
|
2011-07-09 05:47:46 +00:00
|
|
|
/// ToggleFeature - Toggle a feature and returns the re-computed feature
|
|
|
|
/// bits. This version does not change the implied bits.
|
|
|
|
uint64_t ToggleFeature(uint64_t FB);
|
|
|
|
|
|
|
|
/// ToggleFeature - Toggle a feature and returns the re-computed feature
|
|
|
|
/// bits. This version will also change all implied bits.
|
|
|
|
uint64_t ToggleFeature(StringRef FS);
|
|
|
|
|
2012-07-07 04:00:00 +00:00
|
|
|
/// getSchedModelForCPU - Get the machine model of a CPU.
|
|
|
|
///
|
2012-09-05 21:43:57 +00:00
|
|
|
const MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
|
2012-07-07 04:00:00 +00:00
|
|
|
|
2012-09-18 03:18:56 +00:00
|
|
|
/// getSchedModel - Get the machine model for this subtarget's CPU.
|
|
|
|
///
|
|
|
|
const MCSchedModel *getSchedModel() const { return CPUSchedModel; }
|
|
|
|
|
2012-09-14 20:26:41 +00:00
|
|
|
/// Return an iterator at the first process resource consumed by the given
|
|
|
|
/// scheduling class.
|
|
|
|
const MCWriteProcResEntry *getWriteProcResBegin(
|
|
|
|
const MCSchedClassDesc *SC) const {
|
|
|
|
return &WriteProcResTable[SC->WriteProcResIdx];
|
|
|
|
}
|
|
|
|
const MCWriteProcResEntry *getWriteProcResEnd(
|
|
|
|
const MCSchedClassDesc *SC) const {
|
|
|
|
return getWriteProcResBegin(SC) + SC->NumWriteProcResEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
const MCWriteLatencyEntry *getWriteLatencyEntry(const MCSchedClassDesc *SC,
|
|
|
|
unsigned DefIdx) const {
|
|
|
|
assert(DefIdx < SC->NumWriteLatencyEntries &&
|
|
|
|
"MachineModel does not specify a WriteResource for DefIdx");
|
|
|
|
|
|
|
|
return &WriteLatencyTable[SC->WriteLatencyIdx + DefIdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
int getReadAdvanceCycles(const MCSchedClassDesc *SC, unsigned UseIdx,
|
|
|
|
unsigned WriteResID) const {
|
2012-10-10 05:43:16 +00:00
|
|
|
// TODO: The number of read advance entries in a class can be significant
|
|
|
|
// (~50). Consider compressing the WriteID into a dense ID of those that are
|
|
|
|
// used by ReadAdvance and representing them as a bitset.
|
2012-09-14 20:26:41 +00:00
|
|
|
for (const MCReadAdvanceEntry *I = &ReadAdvanceTable[SC->ReadAdvanceIdx],
|
|
|
|
*E = I + SC->NumReadAdvanceEntries; I != E; ++I) {
|
|
|
|
if (I->UseIdx < UseIdx)
|
|
|
|
continue;
|
|
|
|
if (I->UseIdx > UseIdx)
|
|
|
|
break;
|
|
|
|
// Find the first WriteResIdx match, which has the highest cycle count.
|
|
|
|
if (!I->WriteResourceID || I->WriteResourceID == WriteResID) {
|
|
|
|
return I->Cycles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-01 20:45:01 +00:00
|
|
|
/// getInstrItineraryForCPU - Get scheduling itinerary of a CPU.
|
|
|
|
///
|
|
|
|
InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const;
|
2012-09-14 20:26:46 +00:00
|
|
|
|
|
|
|
/// Initialize an InstrItineraryData instance.
|
|
|
|
void initInstrItins(InstrItineraryData &InstrItins) const;
|
2011-07-01 20:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|