blob: e7cbf1b62e79e4ed2dd4349d7e4dab9978f92af2 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- HexagonSubtarget.h - Define Subtarget for the Hexagon ---*- C++ -*-===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +00002//
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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
15#define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
Tony Linthicum1213a7a2011-12-12 21:14:40 +000016
Eric Christopherc4c63ae2014-06-27 00:27:40 +000017#include "HexagonFrameLowering.h"
18#include "HexagonInstrInfo.h"
19#include "HexagonISelLowering.h"
20#include "HexagonSelectionDAGInfo.h"
21#include "llvm/IR/DataLayout.h"
Tony Linthicum1213a7a2011-12-12 21:14:40 +000022#include "llvm/Target/TargetMachine.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000023#include "llvm/Target/TargetSubtargetInfo.h"
Tony Linthicum1213a7a2011-12-12 21:14:40 +000024#include <string>
25
26#define GET_SUBTARGETINFO_HEADER
27#include "HexagonGenSubtargetInfo.inc"
28
29#define Hexagon_SMALL_DATA_THRESHOLD 8
Sirish Pande69295b82012-05-10 20:20:25 +000030#define Hexagon_SLOTS 4
Tony Linthicum1213a7a2011-12-12 21:14:40 +000031
32namespace llvm {
33
34class HexagonSubtarget : public HexagonGenSubtargetInfo {
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000035 virtual void anchor();
Eric Christopherc4c63ae2014-06-27 00:27:40 +000036
Tony Linthicum1213a7a2011-12-12 21:14:40 +000037 bool UseMemOps;
Sirish Pande69295b82012-05-10 20:20:25 +000038 bool ModeIEEERndNear;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000039
40public:
41 enum HexagonArchEnum {
Sirish Pande69295b82012-05-10 20:20:25 +000042 V1, V2, V3, V4, V5
Tony Linthicum1213a7a2011-12-12 21:14:40 +000043 };
44
45 HexagonArchEnum HexagonArchVersion;
Eric Christopherc4c63ae2014-06-27 00:27:40 +000046private:
Tony Linthicum1213a7a2011-12-12 21:14:40 +000047 std::string CPUString;
Eric Christopherc4c63ae2014-06-27 00:27:40 +000048 const DataLayout DL; // Calculates type size & alignment.
49 HexagonInstrInfo InstrInfo;
50 HexagonTargetLowering TLInfo;
51 HexagonSelectionDAGInfo TSInfo;
52 HexagonFrameLowering FrameLowering;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000053 InstrItineraryData InstrItins;
54
55public:
Eric Christopherc4c63ae2014-06-27 00:27:40 +000056 HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
57 const TargetMachine &TM);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000058
Robin Morissetd18cda62014-08-15 22:17:28 +000059 /// getInstrItins - Return the instruction itineraries based on subtarget
Tony Linthicum1213a7a2011-12-12 21:14:40 +000060 /// selection.
Eric Christopherd9134482014-08-04 21:25:23 +000061 const InstrItineraryData *getInstrItineraryData() const {
62 return &InstrItins;
63 }
64 const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
Eric Christopherc4c63ae2014-06-27 00:27:40 +000065 const HexagonRegisterInfo *getRegisterInfo() const {
66 return &InstrInfo.getRegisterInfo();
67 }
68 const HexagonTargetLowering *getTargetLowering() const { return &TLInfo; }
69 const HexagonFrameLowering *getFrameLowering() const {
70 return &FrameLowering;
71 }
72 const HexagonSelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
73 const DataLayout *getDataLayout() const { return &DL; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000074
Eric Christopherc4c63ae2014-06-27 00:27:40 +000075 HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
76 StringRef FS);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000077
78 /// ParseSubtargetFeatures - Parses features string setting specified
79 /// subtarget options. Definition of function is auto generated by tblgen.
80 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
81
82 bool hasV2TOps () const { return HexagonArchVersion >= V2; }
83 bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
84 bool hasV3TOps () const { return HexagonArchVersion >= V3; }
85 bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
86 bool hasV4TOps () const { return HexagonArchVersion >= V4; }
Sirish Pande69295b82012-05-10 20:20:25 +000087 bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000088 bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
Sirish Pande69295b82012-05-10 20:20:25 +000089 bool hasV5TOps () const { return HexagonArchVersion >= V5; }
90 bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
91 bool modeIEEERndNear () const { return ModeIEEERndNear; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000092
93 bool isSubtargetV2() const { return HexagonArchVersion == V2;}
94 const std::string &getCPUString () const { return CPUString; }
95
96 // Threshold for small data section
97 unsigned getSmallDataThreshold() const {
98 return Hexagon_SMALL_DATA_THRESHOLD;
99 }
100 const HexagonArchEnum &getHexagonArchVersion() const {
101 return HexagonArchVersion;
102 }
103};
104
105} // end namespace llvm
106
107#endif