Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 2 | // |
| 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 Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 16 | #include "HexagonRegisterInfo.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 17 | #include "llvm/Support/CommandLine.h" |
| 18 | #include "llvm/Support/ErrorHandling.h" |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 19 | #include <map> |
| 20 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 21 | using namespace llvm; |
| 22 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 23 | #define DEBUG_TYPE "hexagon-subtarget" |
| 24 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 25 | #define GET_SUBTARGETINFO_CTOR |
| 26 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 27 | #include "HexagonGenSubtargetInfo.inc" |
| 28 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 29 | static 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 Verma | fdc660b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 32 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 33 | static 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 Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 36 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 37 | static 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 Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 40 | |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 41 | static cl::opt<bool> EnableBSBSched("enable-bsb-sched", |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 42 | cl::Hidden, cl::ZeroOrMore, cl::init(true)); |
| 43 | |
| 44 | static 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 | |
| 48 | static cl::opt<bool> EnableHexagonHVX("enable-hexagon-hvx", |
| 49 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 50 | cl::desc("Enable Hexagon Vector eXtensions")); |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 51 | |
Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 52 | static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched", |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 53 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 54 | cl::desc("Disable Hexagon MI Scheduling")); |
| 55 | |
| 56 | void HexagonSubtarget::initializeEnvironment() { |
| 57 | UseMemOps = false; |
| 58 | ModeIEEERndNear = false; |
| 59 | UseBSBScheduling = false; |
| 60 | } |
Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 61 | |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 62 | HexagonSubtarget & |
| 63 | HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 64 | // Default architecture. |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 65 | if (CPUString.empty()) |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 66 | CPUString = "hexagonv60"; |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 67 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 68 | static std::map<StringRef, HexagonArchEnum> CpuTable { |
| 69 | { "hexagonv4", V4 }, |
| 70 | { "hexagonv5", V5 }, |
| 71 | { "hexagonv55", V55 }, |
| 72 | { "hexagonv60", V60 }, |
| 73 | }; |
| 74 | |
| 75 | auto foundIt = CpuTable.find(CPUString); |
| 76 | if (foundIt != CpuTable.end()) |
| 77 | HexagonArchVersion = foundIt->second; |
| 78 | else |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 79 | llvm_unreachable("Unrecognized Hexagon processor version"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 80 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 81 | UseHVXOps = false; |
| 82 | UseHVXDblOps = false; |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 83 | ParseSubtargetFeatures(CPUString, FS); |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 84 | |
| 85 | if (EnableHexagonHVX.getPosition()) |
| 86 | UseHVXOps = EnableHexagonHVX; |
| 87 | if (EnableHexagonHVXDouble.getPosition()) |
| 88 | UseHVXDblOps = EnableHexagonHVXDouble; |
| 89 | |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 90 | return *this; |
| 91 | } |
| 92 | |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 93 | HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU, |
| 94 | StringRef FS, const TargetMachine &TM) |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 95 | : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU), |
Eric Christopher | d737b76 | 2015-02-02 22:11:36 +0000 | [diff] [blame] | 96 | InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this), |
Mehdi Amini | 157e5a6 | 2015-07-09 02:10:08 +0000 | [diff] [blame] | 97 | FrameLowering() { |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 98 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame^] | 99 | initializeEnvironment(); |
| 100 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 101 | // Initialize scheduling itinerary for the specified CPU. |
| 102 | InstrItins = getInstrItineraryForCPU(CPUString); |
| 103 | |
Jyotsna Verma | fdc660b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 104 | // UseMemOps on by default unless disabled explicitly |
| 105 | if (DisableMemOps) |
| 106 | UseMemOps = false; |
| 107 | else if (EnableMemOps) |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 108 | UseMemOps = true; |
| 109 | else |
| 110 | UseMemOps = false; |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 111 | |
| 112 | if (EnableIEEERndNear) |
| 113 | ModeIEEERndNear = true; |
| 114 | else |
| 115 | ModeIEEERndNear = false; |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 116 | |
| 117 | UseBSBScheduling = hasV60TOps() && EnableBSBSched; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 118 | } |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 119 | |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 120 | // Pin the vtable to this file. |
| 121 | void HexagonSubtarget::anchor() {} |
Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 122 | |
| 123 | bool HexagonSubtarget::enableMachineScheduler() const { |
| 124 | if (DisableHexagonMISched.getNumOccurrences()) |
| 125 | return !DisableHexagonMISched; |
| 126 | return true; |
| 127 | } |