Home | History | Annotate | Download | only in Hexagon
      1 //===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file declares the Hexagon specific subclass of TargetSubtarget.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
     15 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
     16 
     17 #include "HexagonFrameLowering.h"
     18 #include "HexagonISelLowering.h"
     19 #include "HexagonInstrInfo.h"
     20 #include "HexagonSelectionDAGInfo.h"
     21 #include "llvm/IR/DataLayout.h"
     22 #include "llvm/Target/TargetMachine.h"
     23 #include "llvm/Target/TargetSubtargetInfo.h"
     24 #include <string>
     25 
     26 #define GET_SUBTARGETINFO_HEADER
     27 #include "HexagonGenSubtargetInfo.inc"
     28 
     29 #define Hexagon_SMALL_DATA_THRESHOLD 8
     30 #define Hexagon_SLOTS 4
     31 
     32 namespace llvm {
     33 
     34 class HexagonSubtarget : public HexagonGenSubtargetInfo {
     35   virtual void anchor();
     36 
     37   bool UseMemOps, UseHVXOps, UseHVXDblOps;
     38   bool ModeIEEERndNear;
     39 
     40 public:
     41   enum HexagonArchEnum {
     42     V4, V5, V55, V60
     43   };
     44 
     45   HexagonArchEnum HexagonArchVersion;
     46   /// True if the target should use Back-Skip-Back scheduling. This is the
     47   /// default for V60.
     48   bool UseBSBScheduling;
     49 
     50 private:
     51   std::string CPUString;
     52   HexagonInstrInfo InstrInfo;
     53   HexagonTargetLowering TLInfo;
     54   HexagonSelectionDAGInfo TSInfo;
     55   HexagonFrameLowering FrameLowering;
     56   InstrItineraryData InstrItins;
     57   void initializeEnvironment();
     58 
     59 public:
     60   HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
     61                    const TargetMachine &TM);
     62 
     63   /// getInstrItins - Return the instruction itineraries based on subtarget
     64   /// selection.
     65   const InstrItineraryData *getInstrItineraryData() const override {
     66     return &InstrItins;
     67   }
     68   const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
     69   const HexagonRegisterInfo *getRegisterInfo() const override {
     70     return &InstrInfo.getRegisterInfo();
     71   }
     72   const HexagonTargetLowering *getTargetLowering() const override {
     73     return &TLInfo;
     74   }
     75   const HexagonFrameLowering *getFrameLowering() const override {
     76     return &FrameLowering;
     77   }
     78   const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
     79     return &TSInfo;
     80   }
     81 
     82   HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
     83                                                     StringRef FS);
     84 
     85   /// ParseSubtargetFeatures - Parses features string setting specified
     86   /// subtarget options.  Definition of function is auto generated by tblgen.
     87   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
     88 
     89   bool useMemOps() const { return UseMemOps; }
     90   bool hasV5TOps() const { return getHexagonArchVersion() >= V5; }
     91   bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; }
     92   bool hasV55TOps() const { return getHexagonArchVersion() >= V55; }
     93   bool hasV55TOpsOnly() const { return getHexagonArchVersion() == V55; }
     94   bool hasV60TOps() const { return getHexagonArchVersion() >= V60; }
     95   bool hasV60TOpsOnly() const { return getHexagonArchVersion() == V60; }
     96   bool modeIEEERndNear() const { return ModeIEEERndNear; }
     97   bool useHVXOps() const { return UseHVXOps; }
     98   bool useHVXDblOps() const { return UseHVXOps && UseHVXDblOps; }
     99   bool useHVXSglOps() const { return UseHVXOps && !UseHVXDblOps; }
    100 
    101   bool useBSBScheduling() const { return UseBSBScheduling; }
    102   bool enableMachineScheduler() const override;
    103   // Always use the TargetLowering default scheduler.
    104   // FIXME: This will use the vliw scheduler which is probably just hurting
    105   // compiler time and will be removed eventually anyway.
    106   bool enableMachineSchedDefaultSched() const override { return false; }
    107 
    108   AntiDepBreakMode getAntiDepBreakMode() const override { return ANTIDEP_ALL; }
    109   bool enablePostRAScheduler() const override { return true; }
    110 
    111   bool enableSubRegLiveness() const override;
    112 
    113   const std::string &getCPUString () const { return CPUString; }
    114 
    115   // Threshold for small data section
    116   unsigned getSmallDataThreshold() const {
    117     return Hexagon_SMALL_DATA_THRESHOLD;
    118   }
    119   const HexagonArchEnum &getHexagonArchVersion() const {
    120     return HexagonArchVersion;
    121   }
    122 };
    123 
    124 } // end namespace llvm
    125 
    126 #endif
    127