blob: 34cdad786f82ad7ce037db90f8ca2ede39fb2c54 [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"
Eric Christopherc4c63ae2014-06-27 00:27:40 +000018#include "HexagonISelLowering.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000019#include "HexagonInstrInfo.h"
Eric Christopherc4c63ae2014-06-27 00:27:40 +000020#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 {
Colin LeMahieu4fd203d2015-02-09 21:56:37 +000042 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 HexagonInstrInfo InstrInfo;
49 HexagonTargetLowering TLInfo;
50 HexagonSelectionDAGInfo TSInfo;
51 HexagonFrameLowering FrameLowering;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000052 InstrItineraryData InstrItins;
53
54public:
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000055 HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
Eric Christopherc4c63ae2014-06-27 00:27:40 +000056 const TargetMachine &TM);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000057
Robin Morissetd18cda62014-08-15 22:17:28 +000058 /// getInstrItins - Return the instruction itineraries based on subtarget
Tony Linthicum1213a7a2011-12-12 21:14:40 +000059 /// selection.
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000060 const InstrItineraryData *getInstrItineraryData() const override {
Eric Christopherd9134482014-08-04 21:25:23 +000061 return &InstrItins;
62 }
63 const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000064 const HexagonRegisterInfo *getRegisterInfo() const override {
Eric Christopherc4c63ae2014-06-27 00:27:40 +000065 return &InstrInfo.getRegisterInfo();
66 }
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000067 const HexagonTargetLowering *getTargetLowering() const override {
68 return &TLInfo;
69 }
70 const HexagonFrameLowering *getFrameLowering() const override {
Eric Christopherc4c63ae2014-06-27 00:27:40 +000071 return &FrameLowering;
72 }
Benjamin Kramer8c90fd72014-09-03 11:41:21 +000073 const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
74 return &TSInfo;
75 }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000076
Eric Christopherc4c63ae2014-06-27 00:27:40 +000077 HexagonSubtarget &initializeSubtargetDependencies(StringRef CPU,
78 StringRef FS);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000079
80 /// ParseSubtargetFeatures - Parses features string setting specified
81 /// subtarget options. Definition of function is auto generated by tblgen.
82 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
83
Colin LeMahieu4fd203d2015-02-09 21:56:37 +000084 bool useMemOps() const { return UseMemOps; }
85 bool hasV5TOps() const { return getHexagonArchVersion() >= V5; }
86 bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; }
87 bool modeIEEERndNear() const { return ModeIEEERndNear; }
Eric Christopher5f141b02015-03-11 22:56:10 +000088 bool enableMachineScheduler() const override;
89 // Always use the TargetLowering default scheduler.
90 // FIXME: This will use the vliw scheduler which is probably just hurting
91 // compiler time and will be removed eventually anyway.
92 bool enableMachineSchedDefaultSched() const override { return false; }
Tony Linthicum1213a7a2011-12-12 21:14:40 +000093
Tony Linthicum1213a7a2011-12-12 21:14:40 +000094 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