blob: aa0efd4f65e0726bc5c3fd1d3af8092cdcef45c2 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===//
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 implements the Hexagon specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#include "HexagonSubtarget.h"
15#include "Hexagon.h"
Sirish Pande69295b82012-05-10 20:20:25 +000016#include "HexagonRegisterInfo.h"
Tony Linthicum1213a7a2011-12-12 21:14:40 +000017#include "llvm/Support/CommandLine.h"
18#include "llvm/Support/ErrorHandling.h"
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000019#include <map>
20
Tony Linthicum1213a7a2011-12-12 21:14:40 +000021using namespace llvm;
22
Chandler Carruthe96dd892014-04-21 22:55:11 +000023#define DEBUG_TYPE "hexagon-subtarget"
24
Tony Linthicum1213a7a2011-12-12 21:14:40 +000025#define GET_SUBTARGETINFO_CTOR
26#define GET_SUBTARGETINFO_TARGET_DESC
27#include "HexagonGenSubtargetInfo.inc"
28
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000029static cl::opt<bool> EnableMemOps("enable-hexagon-memops",
30 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
31 cl::desc("Generate V4 MEMOP in code generation for Hexagon target"));
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000032
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000033static cl::opt<bool> DisableMemOps("disable-hexagon-memops",
34 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
35 cl::desc("Do not generate V4 MEMOP in code generation for Hexagon target"));
Sirish Pande69295b82012-05-10 20:20:25 +000036
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000037static cl::opt<bool> EnableIEEERndNear("enable-hexagon-ieee-rnd-near",
38 cl::Hidden, cl::ZeroOrMore, cl::init(false),
39 cl::desc("Generate non-chopped conversion from fp to int."));
Tony Linthicum1213a7a2011-12-12 21:14:40 +000040
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000041static cl::opt<bool> EnableBSBSched("enable-bsb-sched",
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000042 cl::Hidden, cl::ZeroOrMore, cl::init(true));
43
44static cl::opt<bool> EnableHexagonHVXDouble("enable-hexagon-hvx-double",
45 cl::Hidden, cl::ZeroOrMore, cl::init(false),
46 cl::desc("Enable Hexagon Double Vector eXtensions"));
47
48static cl::opt<bool> EnableHexagonHVX("enable-hexagon-hvx",
49 cl::Hidden, cl::ZeroOrMore, cl::init(false),
50 cl::desc("Enable Hexagon Vector eXtensions"));
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000051
Eric Christopher5f141b02015-03-11 22:56:10 +000052static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched",
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000053 cl::Hidden, cl::ZeroOrMore, cl::init(false),
54 cl::desc("Disable Hexagon MI Scheduling"));
55
56void HexagonSubtarget::initializeEnvironment() {
57 UseMemOps = false;
58 ModeIEEERndNear = false;
59 UseBSBScheduling = false;
60}
Eric Christopher5f141b02015-03-11 22:56:10 +000061
Eric Christopherc4c63ae2014-06-27 00:27:40 +000062HexagonSubtarget &
63HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
Krzysztof Parzyszek759a7d02015-12-14 15:03:54 +000064 CPUString = HEXAGON_MC::selectHexagonCPU(getTargetTriple(), CPU);
Sebastian Pop1a0bef62012-08-20 19:56:47 +000065
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000066 static std::map<StringRef, HexagonArchEnum> CpuTable {
67 { "hexagonv4", V4 },
68 { "hexagonv5", V5 },
69 { "hexagonv55", V55 },
70 { "hexagonv60", V60 },
71 };
72
73 auto foundIt = CpuTable.find(CPUString);
74 if (foundIt != CpuTable.end())
75 HexagonArchVersion = foundIt->second;
76 else
Sebastian Pop1a0bef62012-08-20 19:56:47 +000077 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicum1213a7a2011-12-12 21:14:40 +000078
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000079 UseHVXOps = false;
80 UseHVXDblOps = false;
Sebastian Pop1a0bef62012-08-20 19:56:47 +000081 ParseSubtargetFeatures(CPUString, FS);
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000082
83 if (EnableHexagonHVX.getPosition())
84 UseHVXOps = EnableHexagonHVX;
85 if (EnableHexagonHVXDouble.getPosition())
86 UseHVXDblOps = EnableHexagonHVXDouble;
87
Eric Christopherc4c63ae2014-06-27 00:27:40 +000088 return *this;
89}
90
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000091HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
92 StringRef FS, const TargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +000093 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
Eric Christopherd737b762015-02-02 22:11:36 +000094 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
Mehdi Amini157e5a62015-07-09 02:10:08 +000095 FrameLowering() {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000096
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000097 initializeEnvironment();
98
Tony Linthicum1213a7a2011-12-12 21:14:40 +000099 // Initialize scheduling itinerary for the specified CPU.
100 InstrItins = getInstrItineraryForCPU(CPUString);
101
Jyotsna Vermafdc660b2013-03-22 18:41:34 +0000102 // UseMemOps on by default unless disabled explicitly
103 if (DisableMemOps)
104 UseMemOps = false;
105 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000106 UseMemOps = true;
107 else
108 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +0000109
110 if (EnableIEEERndNear)
111 ModeIEEERndNear = true;
112 else
113 ModeIEEERndNear = false;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000114
115 UseBSBScheduling = hasV60TOps() && EnableBSBSched;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000116}
Sirish Pande69295b82012-05-10 20:20:25 +0000117
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +0000118// Pin the vtable to this file.
119void HexagonSubtarget::anchor() {}
Eric Christopher5f141b02015-03-11 22:56:10 +0000120
121bool HexagonSubtarget::enableMachineScheduler() const {
122 if (DisableHexagonMISched.getNumOccurrences())
123 return !DisableHexagonMISched;
124 return true;
125}