#include "HexagonSubtarget.h"
#include "Hexagon.h"
#include "HexagonInstrInfo.h"
#include "HexagonRegisterInfo.h"
#include "MCTargetDesc/HexagonMCTargetDesc.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
#include "llvm/IR/IntrinsicsHexagon.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetMachine.h"
#include <algorithm>
#include <cassert>
#include <map>
#include <optional>
usingnamespacellvm;
#define DEBUG_TYPE …
#define GET_SUBTARGETINFO_CTOR
#define GET_SUBTARGETINFO_TARGET_DESC
#include "HexagonGenSubtargetInfo.inc"
static cl::opt<bool> EnableBSBSched("enable-bsb-sched", cl::Hidden,
cl::init(true));
static cl::opt<bool> EnableTCLatencySched("enable-tc-latency-sched", cl::Hidden,
cl::init(false));
static cl::opt<bool>
EnableDotCurSched("enable-cur-sched", cl::Hidden, cl::init(true),
cl::desc("Enable the scheduler to generate .cur"));
static cl::opt<bool>
DisableHexagonMISched("disable-hexagon-misched", cl::Hidden,
cl::desc("Disable Hexagon MI Scheduling"));
static cl::opt<bool> OverrideLongCalls(
"hexagon-long-calls", cl::Hidden,
cl::desc("If present, forces/disables the use of long calls"));
static cl::opt<bool>
EnablePredicatedCalls("hexagon-pred-calls", cl::Hidden,
cl::desc("Consider calls to be predicable"));
static cl::opt<bool> SchedPredsCloser("sched-preds-closer", cl::Hidden,
cl::init(true));
static cl::opt<bool> SchedRetvalOptimization("sched-retval-optimization",
cl::Hidden, cl::init(true));
static cl::opt<bool> EnableCheckBankConflict(
"hexagon-check-bank-conflict", cl::Hidden, cl::init(true),
cl::desc("Enable checking for cache bank conflicts"));
HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
StringRef FS, const TargetMachine &TM)
: … { … }
HexagonSubtarget &
HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { … }
bool HexagonSubtarget::isHVXElementType(MVT Ty, bool IncludeBool) const { … }
bool HexagonSubtarget::isHVXVectorType(EVT VecTy, bool IncludeBool) const { … }
bool HexagonSubtarget::isTypeForHVX(Type *VecTy, bool IncludeBool) const { … }
void HexagonSubtarget::UsrOverflowMutation::apply(ScheduleDAGInstrs *DAG) { … }
void HexagonSubtarget::HVXMemLatencyMutation::apply(ScheduleDAGInstrs *DAG) { … }
bool HexagonSubtarget::CallMutation::shouldTFRICallBind(
const HexagonInstrInfo &HII, const SUnit &Inst1,
const SUnit &Inst2) const { … }
void HexagonSubtarget::CallMutation::apply(ScheduleDAGInstrs *DAGInstrs) { … }
void HexagonSubtarget::BankConflictMutation::apply(ScheduleDAGInstrs *DAG) { … }
bool HexagonSubtarget::useAA() const { … }
void HexagonSubtarget::adjustSchedDependency(
SUnit *Src, int SrcOpIdx, SUnit *Dst, int DstOpIdx, SDep &Dep,
const TargetSchedModel *SchedModel) const { … }
void HexagonSubtarget::getPostRAMutations(
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const { … }
void HexagonSubtarget::getSMSMutations(
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const { … }
void HexagonSubtarget::anchor() { … }
bool HexagonSubtarget::enableMachineScheduler() const { … }
bool HexagonSubtarget::usePredicatedCalls() const { … }
int HexagonSubtarget::updateLatency(MachineInstr &SrcInst,
MachineInstr &DstInst, bool IsArtificial,
int Latency) const { … }
void HexagonSubtarget::restoreLatency(SUnit *Src, SUnit *Dst) const { … }
void HexagonSubtarget::changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat)
const { … }
static SUnit *getZeroLatency(SUnit *N, SmallVector<SDep, 4> &Deps) { … }
bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst,
const HexagonInstrInfo *TII, SmallSet<SUnit*, 4> &ExclSrc,
SmallSet<SUnit*, 4> &ExclDst) const { … }
unsigned HexagonSubtarget::getL1CacheLineSize() const { … }
unsigned HexagonSubtarget::getL1PrefetchDistance() const { … }
bool HexagonSubtarget::enableSubRegLiveness() const { … }
Intrinsic::ID HexagonSubtarget::getIntrinsicId(unsigned Opc) const { … }