LLVM API Documentation

HexagonSubtarget.h
Go to the documentation of this file.
00001 //===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the Hexagon specific subclass of TargetSubtarget.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
00015 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
00016 
00017 #include "HexagonFrameLowering.h"
00018 #include "HexagonInstrInfo.h"
00019 #include "HexagonISelLowering.h"
00020 #include "HexagonSelectionDAGInfo.h"
00021 #include "llvm/IR/DataLayout.h"
00022 #include "llvm/Target/TargetMachine.h"
00023 #include "llvm/Target/TargetSubtargetInfo.h"
00024 #include <string>
00025 
00026 #define GET_SUBTARGETINFO_HEADER
00027 #include "HexagonGenSubtargetInfo.inc"
00028 
00029 #define Hexagon_SMALL_DATA_THRESHOLD 8
00030 #define Hexagon_SLOTS 4
00031 
00032 namespace llvm {
00033 
00034 class HexagonSubtarget : public HexagonGenSubtargetInfo {
00035   virtual void anchor();
00036 
00037   bool UseMemOps;
00038   bool ModeIEEERndNear;
00039 
00040 public:
00041   enum HexagonArchEnum {
00042     V1, V2, V3, V4, V5
00043   };
00044 
00045   HexagonArchEnum HexagonArchVersion;
00046 private:
00047   std::string CPUString;
00048   const DataLayout DL;       // Calculates type size & alignment.
00049   HexagonInstrInfo InstrInfo;
00050   HexagonTargetLowering TLInfo;
00051   HexagonSelectionDAGInfo TSInfo;
00052   HexagonFrameLowering FrameLowering;
00053   InstrItineraryData InstrItins;
00054 
00055 public:
00056   HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
00057                    const TargetMachine &TM);
00058 
00059   /// getInstrItins - Return the instruction itineraries based on subtarget
00060   /// selection.
00061   const InstrItineraryData *getInstrItineraryData() const override {
00062     return &InstrItins;
00063   }
00064   const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
00065   const HexagonRegisterInfo *getRegisterInfo() const override {
00066     return &InstrInfo.getRegisterInfo();
00067   }
00068   const HexagonTargetLowering *getTargetLowering() const override {
00069     return &TLInfo;
00070   }
00071   const HexagonFrameLowering *getFrameLowering() const override {
00072     return &FrameLowering;
00073   }
00074   const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
00075     return &TSInfo;
00076   }
00077   const DataLayout *getDataLayout() const override { return &DL; }
00078 
00079   HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
00080                                                     StringRef FS);
00081 
00082   /// ParseSubtargetFeatures - Parses features string setting specified
00083   /// subtarget options.  Definition of function is auto generated by tblgen.
00084   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
00085 
00086   bool hasV2TOps () const { return HexagonArchVersion >= V2; }
00087   bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
00088   bool hasV3TOps () const { return HexagonArchVersion >= V3; }
00089   bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
00090   bool hasV4TOps () const { return HexagonArchVersion >= V4; }
00091   bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
00092   bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
00093   bool hasV5TOps () const { return HexagonArchVersion >= V5; }
00094   bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
00095   bool modeIEEERndNear () const { return ModeIEEERndNear; }
00096 
00097   bool isSubtargetV2() const { return HexagonArchVersion == V2;}
00098   const std::string &getCPUString () const { return CPUString; }
00099 
00100   // Threshold for small data section
00101   unsigned getSmallDataThreshold() const {
00102     return Hexagon_SMALL_DATA_THRESHOLD;
00103   }
00104   const HexagonArchEnum &getHexagonArchVersion() const {
00105     return  HexagonArchVersion;
00106   }
00107 };
00108 
00109 } // end namespace llvm
00110 
00111 #endif