blob: b184e62b4d0d966f5d14742c1d5e2d19faadbd99 [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
14#ifndef Hexagon_SUBTARGET_H
15#define Hexagon_SUBTARGET_H
16
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
59 /// getInstrItins - Return the instruction itineraies based on subtarget
60 /// selection.
61 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
Eric Christopherc4c63ae2014-06-27 00:27:40 +000062 const HexagonInstrInfo *getInstrInfo() const { return &InstrInfo; }
63 const HexagonRegisterInfo *getRegisterInfo() const {
64 return &InstrInfo.getRegisterInfo();
65 }
66 const HexagonTargetLowering *getTargetLowering() const { return &TLInfo; }
67 const HexagonFrameLowering *getFrameLowering() const {
68 return &FrameLowering;
69 }
70 const HexagonSelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
71 const DataLayout *getDataLayout() const { return &DL; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000072
Eric Christopherc4c63ae2014-06-27 00:27:40 +000073 HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
74 StringRef FS);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000075
76 /// ParseSubtargetFeatures - Parses features string setting specified
77 /// subtarget options. Definition of function is auto generated by tblgen.
78 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
79
80 bool hasV2TOps () const { return HexagonArchVersion >= V2; }
81 bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
82 bool hasV3TOps () const { return HexagonArchVersion >= V3; }
83 bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
84 bool hasV4TOps () const { return HexagonArchVersion >= V4; }
Sirish Pande69295b82012-05-10 20:20:25 +000085 bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000086 bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
Sirish Pande69295b82012-05-10 20:20:25 +000087 bool hasV5TOps () const { return HexagonArchVersion >= V5; }
88 bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
89 bool modeIEEERndNear () const { return ModeIEEERndNear; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000090
91 bool isSubtargetV2() const { return HexagonArchVersion == V2;}
92 const std::string &getCPUString () const { return CPUString; }
93
94 // Threshold for small data section
95 unsigned getSmallDataThreshold() const {
96 return Hexagon_SMALL_DATA_THRESHOLD;
97 }
98 const HexagonArchEnum &getHexagonArchVersion() const {
99 return HexagonArchVersion;
100 }
101};
102
103} // end namespace llvm
104
105#endif