blob: cd482b3e3af1acdba84faae45932657008d1bc6c [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"
19using namespace llvm;
20
Chandler Carruthe96dd892014-04-21 22:55:11 +000021#define DEBUG_TYPE "hexagon-subtarget"
22
Tony Linthicum1213a7a2011-12-12 21:14:40 +000023#define GET_SUBTARGETINFO_CTOR
24#define GET_SUBTARGETINFO_TARGET_DESC
25#include "HexagonGenSubtargetInfo.inc"
26
27static cl::opt<bool>
28EnableV3("enable-hexagon-v3", cl::Hidden,
29 cl::desc("Enable Hexagon V3 instructions."));
30
31static cl::opt<bool>
32EnableMemOps(
33 "enable-hexagon-memops",
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000034 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
35 cl::desc(
36 "Generate V4 MEMOP in code generation for Hexagon target"));
37
38static cl::opt<bool>
39DisableMemOps(
40 "disable-hexagon-memops",
41 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
42 cl::desc(
43 "Do not generate V4 MEMOP in code generation for Hexagon target"));
Sirish Pande69295b82012-05-10 20:20:25 +000044
45static cl::opt<bool>
46EnableIEEERndNear(
47 "enable-hexagon-ieee-rnd-near",
48 cl::Hidden, cl::ZeroOrMore, cl::init(false),
49 cl::desc("Generate non-chopped conversion from fp to int."));
Tony Linthicum1213a7a2011-12-12 21:14:40 +000050
Eric Christopher5f141b02015-03-11 22:56:10 +000051static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched",
52 cl::Hidden, cl::ZeroOrMore, cl::init(false),
53 cl::desc("Disable Hexagon MI Scheduling"));
54
Eric Christopherc4c63ae2014-06-27 00:27:40 +000055HexagonSubtarget &
56HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000057 // If the programmer has not specified a Hexagon version, default to -mv4.
58 if (CPUString.empty())
Sebastian Pop221e07e2012-07-19 18:24:50 +000059 CPUString = "hexagonv4";
Sebastian Pop1a0bef62012-08-20 19:56:47 +000060
Colin LeMahieu4fd203d2015-02-09 21:56:37 +000061 if (CPUString == "hexagonv4") {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000062 HexagonArchVersion = V4;
63 } else if (CPUString == "hexagonv5") {
64 HexagonArchVersion = V5;
65 } else {
66 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicum1213a7a2011-12-12 21:14:40 +000067 }
68
Sebastian Pop1a0bef62012-08-20 19:56:47 +000069 ParseSubtargetFeatures(CPUString, FS);
Eric Christopherc4c63ae2014-06-27 00:27:40 +000070 return *this;
71}
72
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000073HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
74 StringRef FS, const TargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +000075 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
Eric Christopherd737b762015-02-02 22:11:36 +000076 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
Mehdi Amini157e5a62015-07-09 02:10:08 +000077 FrameLowering() {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000078
Tony Linthicum1213a7a2011-12-12 21:14:40 +000079 // Initialize scheduling itinerary for the specified CPU.
80 InstrItins = getInstrItineraryForCPU(CPUString);
81
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000082 // UseMemOps on by default unless disabled explicitly
83 if (DisableMemOps)
84 UseMemOps = false;
85 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +000086 UseMemOps = true;
87 else
88 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +000089
90 if (EnableIEEERndNear)
91 ModeIEEERndNear = true;
92 else
93 ModeIEEERndNear = false;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000094}
Sirish Pande69295b82012-05-10 20:20:25 +000095
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000096// Pin the vtable to this file.
97void HexagonSubtarget::anchor() {}
Eric Christopher5f141b02015-03-11 22:56:10 +000098
99bool HexagonSubtarget::enableMachineScheduler() const {
100 if (DisableHexagonMISched.getNumOccurrences())
101 return !DisableHexagonMISched;
102 return true;
103}