blob: 24fb7b401632595545d3e8a30c7de7af20c87270 [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>
Tony Linthicum1213a7a2011-12-12 21:14:40 +000028EnableMemOps(
29 "enable-hexagon-memops",
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000030 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
31 cl::desc(
32 "Generate V4 MEMOP in code generation for Hexagon target"));
33
34static cl::opt<bool>
35DisableMemOps(
36 "disable-hexagon-memops",
37 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
38 cl::desc(
39 "Do not generate V4 MEMOP in code generation for Hexagon target"));
Sirish Pande69295b82012-05-10 20:20:25 +000040
41static cl::opt<bool>
42EnableIEEERndNear(
43 "enable-hexagon-ieee-rnd-near",
44 cl::Hidden, cl::ZeroOrMore, cl::init(false),
45 cl::desc("Generate non-chopped conversion from fp to int."));
Tony Linthicum1213a7a2011-12-12 21:14:40 +000046
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000047static cl::opt<bool> EnableBSBSched("enable-bsb-sched",
48 cl::Hidden, cl::ZeroOrMore, cl::init(true));
49
Eric Christopher5f141b02015-03-11 22:56:10 +000050static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched",
51 cl::Hidden, cl::ZeroOrMore, cl::init(false),
52 cl::desc("Disable Hexagon MI Scheduling"));
53
Eric Christopherc4c63ae2014-06-27 00:27:40 +000054HexagonSubtarget &
55HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000056 // If the programmer has not specified a Hexagon version, default to -mv4.
57 if (CPUString.empty())
Sebastian Pop221e07e2012-07-19 18:24:50 +000058 CPUString = "hexagonv4";
Sebastian Pop1a0bef62012-08-20 19:56:47 +000059
Colin LeMahieu4fd203d2015-02-09 21:56:37 +000060 if (CPUString == "hexagonv4") {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000061 HexagonArchVersion = V4;
62 } else if (CPUString == "hexagonv5") {
63 HexagonArchVersion = V5;
64 } else {
65 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicum1213a7a2011-12-12 21:14:40 +000066 }
67
Sebastian Pop1a0bef62012-08-20 19:56:47 +000068 ParseSubtargetFeatures(CPUString, FS);
Eric Christopherc4c63ae2014-06-27 00:27:40 +000069 return *this;
70}
71
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000072HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
73 StringRef FS, const TargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +000074 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
Eric Christopherd737b762015-02-02 22:11:36 +000075 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
Mehdi Amini157e5a62015-07-09 02:10:08 +000076 FrameLowering() {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000077
Tony Linthicum1213a7a2011-12-12 21:14:40 +000078 // Initialize scheduling itinerary for the specified CPU.
79 InstrItins = getInstrItineraryForCPU(CPUString);
80
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000081 // UseMemOps on by default unless disabled explicitly
82 if (DisableMemOps)
83 UseMemOps = false;
84 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +000085 UseMemOps = true;
86 else
87 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +000088
89 if (EnableIEEERndNear)
90 ModeIEEERndNear = true;
91 else
92 ModeIEEERndNear = false;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000093
94 UseBSBScheduling = hasV60TOps() && EnableBSBSched;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000095}
Sirish Pande69295b82012-05-10 20:20:25 +000096
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000097// Pin the vtable to this file.
98void HexagonSubtarget::anchor() {}
Eric Christopher5f141b02015-03-11 22:56:10 +000099
100bool HexagonSubtarget::enableMachineScheduler() const {
101 if (DisableHexagonMISched.getNumOccurrences())
102 return !DisableHexagonMISched;
103 return true;
104}