2017-06-20 06:43:19 +08:00
|
|
|
//===- HexagonSubtarget.h - Define Subtarget for the Hexagon ----*- C++ -*-===//
|
2011-12-13 05:14:40 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the Hexagon specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2014-06-27 08:27:40 +08:00
|
|
|
#include "HexagonFrameLowering.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "HexagonInstrInfo.h"
|
2017-06-20 06:43:19 +08:00
|
|
|
#include "HexagonISelLowering.h"
|
2014-06-27 08:27:40 +08:00
|
|
|
#include "HexagonSelectionDAGInfo.h"
|
2017-06-20 06:43:19 +08:00
|
|
|
#include "llvm/ADT/SmallSet.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/CodeGen/ScheduleDAGMutation.h"
|
|
|
|
#include "llvm/MC/MCInstrItineraries.h"
|
2012-12-04 15:12:27 +08:00
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
2017-06-20 06:43:19 +08:00
|
|
|
#include <memory>
|
2011-12-13 05:14:40 +08:00
|
|
|
#include <string>
|
2017-06-20 06:43:19 +08:00
|
|
|
#include <vector>
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
|
|
|
#include "HexagonGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
#define Hexagon_SMALL_DATA_THRESHOLD 8
|
2012-05-11 04:20:25 +08:00
|
|
|
#define Hexagon_SLOTS 4
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2017-06-20 06:43:19 +08:00
|
|
|
class MachineInstr;
|
|
|
|
class SDep;
|
|
|
|
class SUnit;
|
|
|
|
class TargetMachine;
|
|
|
|
class Triple;
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
class HexagonSubtarget : public HexagonGenSubtargetInfo {
|
2013-11-19 08:57:56 +08:00
|
|
|
virtual void anchor();
|
2014-06-27 08:27:40 +08:00
|
|
|
|
2015-10-17 09:33:04 +08:00
|
|
|
bool UseMemOps, UseHVXOps, UseHVXDblOps;
|
2016-07-25 22:42:11 +08:00
|
|
|
bool UseLongCalls;
|
2012-05-11 04:20:25 +08:00
|
|
|
bool ModeIEEERndNear;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
public:
|
2017-02-10 23:33:13 +08:00
|
|
|
#include "HexagonDepArch.h"
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
HexagonArchEnum HexagonArchVersion;
|
2015-11-24 22:55:26 +08:00
|
|
|
/// True if the target should use Back-Skip-Back scheduling. This is the
|
|
|
|
/// default for V60.
|
|
|
|
bool UseBSBScheduling;
|
|
|
|
|
2016-07-16 01:48:09 +08:00
|
|
|
class HexagonDAGMutation : public ScheduleDAGMutation {
|
|
|
|
public:
|
|
|
|
void apply(ScheduleDAGInstrs *DAG) override;
|
|
|
|
};
|
|
|
|
|
2014-06-27 08:27:40 +08:00
|
|
|
private:
|
2011-12-13 05:14:40 +08:00
|
|
|
std::string CPUString;
|
2014-06-27 08:27:40 +08:00
|
|
|
HexagonInstrInfo InstrInfo;
|
|
|
|
HexagonTargetLowering TLInfo;
|
|
|
|
HexagonSelectionDAGInfo TSInfo;
|
|
|
|
HexagonFrameLowering FrameLowering;
|
2011-12-13 05:14:40 +08:00
|
|
|
InstrItineraryData InstrItins;
|
2017-06-20 06:43:19 +08:00
|
|
|
|
2015-11-26 04:30:59 +08:00
|
|
|
void initializeEnvironment();
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
public:
|
2015-06-10 20:11:26 +08:00
|
|
|
HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
|
2014-06-27 08:27:40 +08:00
|
|
|
const TargetMachine &TM);
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2014-08-16 06:17:28 +08:00
|
|
|
/// getInstrItins - Return the instruction itineraries based on subtarget
|
2011-12-13 05:14:40 +08:00
|
|
|
/// selection.
|
2014-09-03 19:41:21 +08:00
|
|
|
const InstrItineraryData *getInstrItineraryData() const override {
|
2014-08-05 05:25:23 +08:00
|
|
|
return &InstrItins;
|
|
|
|
}
|
|
|
|
const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
2014-09-03 19:41:21 +08:00
|
|
|
const HexagonRegisterInfo *getRegisterInfo() const override {
|
2014-06-27 08:27:40 +08:00
|
|
|
return &InstrInfo.getRegisterInfo();
|
|
|
|
}
|
2014-09-03 19:41:21 +08:00
|
|
|
const HexagonTargetLowering *getTargetLowering() const override {
|
|
|
|
return &TLInfo;
|
|
|
|
}
|
|
|
|
const HexagonFrameLowering *getFrameLowering() const override {
|
2014-06-27 08:27:40 +08:00
|
|
|
return &FrameLowering;
|
|
|
|
}
|
2014-09-03 19:41:21 +08:00
|
|
|
const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
|
|
|
|
return &TSInfo;
|
|
|
|
}
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2014-06-27 08:27:40 +08:00
|
|
|
HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
|
|
|
|
StringRef FS);
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
/// ParseSubtargetFeatures - Parses features string setting specified
|
|
|
|
/// subtarget options. Definition of function is auto generated by tblgen.
|
|
|
|
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
|
|
|
|
2015-02-10 05:56:37 +08:00
|
|
|
bool useMemOps() const { return UseMemOps; }
|
|
|
|
bool hasV5TOps() const { return getHexagonArchVersion() >= V5; }
|
|
|
|
bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; }
|
2015-11-26 04:30:59 +08:00
|
|
|
bool hasV55TOps() const { return getHexagonArchVersion() >= V55; }
|
|
|
|
bool hasV55TOpsOnly() const { return getHexagonArchVersion() == V55; }
|
2015-10-17 09:33:04 +08:00
|
|
|
bool hasV60TOps() const { return getHexagonArchVersion() >= V60; }
|
|
|
|
bool hasV60TOpsOnly() const { return getHexagonArchVersion() == V60; }
|
2017-02-11 07:46:45 +08:00
|
|
|
bool hasV62TOps() const { return getHexagonArchVersion() >= V62; }
|
|
|
|
bool hasV62TOpsOnly() const { return getHexagonArchVersion() == V62; }
|
|
|
|
|
2015-02-10 05:56:37 +08:00
|
|
|
bool modeIEEERndNear() const { return ModeIEEERndNear; }
|
2015-11-26 04:30:59 +08:00
|
|
|
bool useHVXOps() const { return UseHVXOps; }
|
|
|
|
bool useHVXDblOps() const { return UseHVXOps && UseHVXDblOps; }
|
2015-10-17 09:33:04 +08:00
|
|
|
bool useHVXSglOps() const { return UseHVXOps && !UseHVXDblOps; }
|
2016-07-25 22:42:11 +08:00
|
|
|
bool useLongCalls() const { return UseLongCalls; }
|
2017-05-06 06:13:57 +08:00
|
|
|
bool usePredicatedCalls() const;
|
2015-11-24 22:55:26 +08:00
|
|
|
|
|
|
|
bool useBSBScheduling() const { return UseBSBScheduling; }
|
2015-03-12 06:56:10 +08:00
|
|
|
bool enableMachineScheduler() const override;
|
2017-06-20 06:43:19 +08:00
|
|
|
|
2015-03-12 06:56:10 +08:00
|
|
|
// Always use the TargetLowering default scheduler.
|
|
|
|
// FIXME: This will use the vliw scheduler which is probably just hurting
|
|
|
|
// compiler time and will be removed eventually anyway.
|
|
|
|
bool enableMachineSchedDefaultSched() const override { return false; }
|
2015-02-10 05:56:37 +08:00
|
|
|
|
2016-05-26 23:38:50 +08:00
|
|
|
AntiDepBreakMode getAntiDepBreakMode() const override { return ANTIDEP_ALL; }
|
2016-05-27 03:44:28 +08:00
|
|
|
bool enablePostRAScheduler() const override { return true; }
|
2016-05-26 23:38:50 +08:00
|
|
|
|
2016-05-28 10:02:51 +08:00
|
|
|
bool enableSubRegLiveness() const override;
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
const std::string &getCPUString () const { return CPUString; }
|
|
|
|
|
|
|
|
// Threshold for small data section
|
|
|
|
unsigned getSmallDataThreshold() const {
|
|
|
|
return Hexagon_SMALL_DATA_THRESHOLD;
|
|
|
|
}
|
2017-06-20 06:43:19 +08:00
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
const HexagonArchEnum &getHexagonArchVersion() const {
|
2015-12-14 23:03:54 +08:00
|
|
|
return HexagonArchVersion;
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
2016-07-16 01:48:09 +08:00
|
|
|
|
|
|
|
void getPostRAMutations(
|
|
|
|
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
|
|
|
|
const override;
|
2016-07-16 05:34:02 +08:00
|
|
|
|
2016-12-23 03:44:55 +08:00
|
|
|
void getSMSMutations(
|
|
|
|
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
|
|
|
|
const override;
|
|
|
|
|
2016-07-16 05:34:02 +08:00
|
|
|
/// \brief Perform target specific adjustments to the latency of a schedule
|
|
|
|
/// dependency.
|
|
|
|
void adjustSchedDependency(SUnit *def, SUnit *use, SDep& dep) const override;
|
|
|
|
|
2016-07-22 22:22:43 +08:00
|
|
|
unsigned getL1CacheLineSize() const;
|
|
|
|
unsigned getL1PrefetchDistance() const;
|
|
|
|
|
2016-07-16 05:34:02 +08:00
|
|
|
private:
|
|
|
|
// Helper function responsible for increasing the latency only.
|
2016-07-30 05:49:42 +08:00
|
|
|
void updateLatency(MachineInstr &SrcInst, MachineInstr &DstInst, SDep &Dep)
|
2016-07-18 22:23:10 +08:00
|
|
|
const;
|
2017-05-04 04:10:36 +08:00
|
|
|
void restoreLatency(SUnit *Src, SUnit *Dst) const;
|
|
|
|
void changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat) const;
|
|
|
|
bool isBestZeroLatency(SUnit *Src, SUnit *Dst, const HexagonInstrInfo *TII,
|
|
|
|
SmallSet<SUnit*, 4> &ExclSrc, SmallSet<SUnit*, 4> &ExclDst) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2017-06-20 06:43:19 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
|