blob: 10776ae0eb34c48029e339bcce215cf9883a7c55 [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.
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000061 const InstrItineraryData *getInstrItineraryData() const override {
Eric Christopherd9134482014-08-04 21:25:23 +000062 return &InstrItins;
63 }
64 const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000065 const HexagonRegisterInfo *getRegisterInfo() const override {
Eric Christopherc4c63ae2014-06-27 00:27:40 +000066 return &InstrInfo.getRegisterInfo();
67 }
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000068 const HexagonTargetLowering *getTargetLowering() const override {
69 return &TLInfo;
70 }
71 const HexagonFrameLowering *getFrameLowering() const override {
Eric Christopherc4c63ae2014-06-27 00:27:40 +000072 return &FrameLowering;
73 }
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000074 const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
75 return &TSInfo;
76 }
77 const DataLayout *getDataLayout() const override { return &DL; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000078
Eric Christopherc4c63ae2014-06-27 00:27:40 +000079 HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
80 StringRef FS);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000081
82 /// ParseSubtargetFeatures - Parses features string setting specified
83 /// subtarget options. Definition of function is auto generated by tblgen.
84 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
85
86 bool hasV2TOps () const { return HexagonArchVersion >= V2; }
87 bool hasV2TOpsOnly () const { return HexagonArchVersion == V2; }
88 bool hasV3TOps () const { return HexagonArchVersion >= V3; }
89 bool hasV3TOpsOnly () const { return HexagonArchVersion == V3; }
90 bool hasV4TOps () const { return HexagonArchVersion >= V4; }
Sirish Pande69295b82012-05-10 20:20:25 +000091 bool hasV4TOpsOnly () const { return HexagonArchVersion == V4; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000092 bool useMemOps () const { return HexagonArchVersion >= V4 && UseMemOps; }
Sirish Pande69295b82012-05-10 20:20:25 +000093 bool hasV5TOps () const { return HexagonArchVersion >= V5; }
94 bool hasV5TOpsOnly () const { return HexagonArchVersion == V5; }
95 bool modeIEEERndNear () const { return ModeIEEERndNear; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000096
97 bool isSubtargetV2() const { return HexagonArchVersion == V2;}
98 const std::string &getCPUString () const { return CPUString; }
99
100 // Threshold for small data section
101 unsigned getSmallDataThreshold() const {
102 return Hexagon_SMALL_DATA_THRESHOLD;
103 }
104 const HexagonArchEnum &getHexagonArchVersion() const {
105 return HexagonArchVersion;
106 }
107};
108
109} // end namespace llvm
110
111#endif