HexagonSubtarget.h revision 239462
11573Srgrimes//===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- C++ -*-===//
21573Srgrimes//
31573Srgrimes//                     The LLVM Compiler Infrastructure
41573Srgrimes//
51573Srgrimes// This file is distributed under the University of Illinois Open Source
61573Srgrimes// License. See LICENSE.TXT for details.
71573Srgrimes//
81573Srgrimes//===----------------------------------------------------------------------===//
91573Srgrimes//
101573Srgrimes// This file declares the Hexagon specific subclass of TargetSubtarget.
111573Srgrimes//
121573Srgrimes//===----------------------------------------------------------------------===//
131573Srgrimes
141573Srgrimes#ifndef Hexagon_SUBTARGET_H
151573Srgrimes#define Hexagon_SUBTARGET_H
161573Srgrimes
171573Srgrimes#include "llvm/Target/TargetSubtargetInfo.h"
181573Srgrimes#include "llvm/Target/TargetMachine.h"
191573Srgrimes#include <string>
201573Srgrimes
211573Srgrimes#define GET_SUBTARGETINFO_HEADER
221573Srgrimes#include "HexagonGenSubtargetInfo.inc"
231573Srgrimes
241573Srgrimes#define Hexagon_SMALL_DATA_THRESHOLD 8
251573Srgrimes#define Hexagon_SLOTS 4
261573Srgrimes
271573Srgrimesnamespace llvm {
281573Srgrimes
291573Srgrimesclass HexagonSubtarget : public HexagonGenSubtargetInfo {
3084227Sdillon
3184227Sdillon  bool UseMemOps;
3284227Sdillon  bool ModeIEEERndNear;
331573Srgrimes
341573Srgrimespublic:
351573Srgrimes  enum HexagonArchEnum {
361573Srgrimes    V1, V2, V3, V4, V5
371573Srgrimes  };
381573Srgrimes
3917141Sjkh  HexagonArchEnum HexagonArchVersion;
401573Srgrimes  std::string CPUString;
411573Srgrimes  InstrItineraryData InstrItins;
421573Srgrimes
431573Srgrimespublic:
441573Srgrimes  HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS);
451573Srgrimes
46  /// getInstrItins - Return the instruction itineraies based on subtarget
47  /// selection.
48  const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
49
50
51  /// ParseSubtargetFeatures - Parses features string setting specified
52  /// subtarget options.  Definition of function is auto generated by tblgen.
53  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
54
55  bool hasV2TOps () const { return HexagonArchVersion >= V2; }
56  bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
57  bool hasV3TOps () const { return HexagonArchVersion >= V3; }
58  bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
59  bool hasV4TOps () const { return HexagonArchVersion >= V4; }
60  bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
61  bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
62  bool hasV5TOps () const { return HexagonArchVersion >= V5; }
63  bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
64  bool modeIEEERndNear () const { return ModeIEEERndNear; }
65
66  bool isSubtargetV2() const { return HexagonArchVersion == V2;}
67  const std::string &getCPUString () const { return CPUString; }
68
69  // Threshold for small data section
70  unsigned getSmallDataThreshold() const {
71    return Hexagon_SMALL_DATA_THRESHOLD;
72  }
73  const HexagonArchEnum &getHexagonArchVersion() const {
74    return  HexagonArchVersion;
75  }
76};
77
78} // end namespace llvm
79
80#endif
81