Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===// |
Tony Linthicum | b4b5415 | 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 | 7517bbc | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 16 | #include "HexagonRegisterInfo.h" |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 17 | #include "llvm/Support/CommandLine.h" |
| 18 | #include "llvm/Support/ErrorHandling.h" |
| 19 | using namespace llvm; |
| 20 | |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 21 | #define GET_SUBTARGETINFO_CTOR |
| 22 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 23 | #include "HexagonGenSubtargetInfo.inc" |
| 24 | |
| 25 | static cl::opt<bool> |
| 26 | EnableV3("enable-hexagon-v3", cl::Hidden, |
| 27 | cl::desc("Enable Hexagon V3 instructions.")); |
| 28 | |
| 29 | static cl::opt<bool> |
| 30 | EnableMemOps( |
| 31 | "enable-hexagon-memops", |
Jyotsna Verma | 97e602b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 32 | cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true), |
| 33 | cl::desc( |
| 34 | "Generate V4 MEMOP in code generation for Hexagon target")); |
| 35 | |
| 36 | static cl::opt<bool> |
| 37 | DisableMemOps( |
| 38 | "disable-hexagon-memops", |
| 39 | cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false), |
| 40 | cl::desc( |
| 41 | "Do not generate V4 MEMOP in code generation for Hexagon target")); |
Sirish Pande | 7517bbc | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 42 | |
| 43 | static cl::opt<bool> |
| 44 | EnableIEEERndNear( |
| 45 | "enable-hexagon-ieee-rnd-near", |
| 46 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 47 | cl::desc("Generate non-chopped conversion from fp to int.")); |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 48 | |
| 49 | HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS): |
| 50 | HexagonGenSubtargetInfo(TT, CPU, FS), |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 51 | CPUString(CPU.str()) { |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 52 | |
Sebastian Pop | b72a939 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 53 | // If the programmer has not specified a Hexagon version, default to -mv4. |
| 54 | if (CPUString.empty()) |
Sebastian Pop | e88ed09 | 2012-07-19 18:24:50 +0000 | [diff] [blame] | 55 | CPUString = "hexagonv4"; |
Sebastian Pop | b72a939 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 56 | |
| 57 | if (CPUString == "hexagonv2") { |
| 58 | HexagonArchVersion = V2; |
| 59 | } else if (CPUString == "hexagonv3") { |
| 60 | EnableV3 = true; |
| 61 | HexagonArchVersion = V3; |
| 62 | } else if (CPUString == "hexagonv4") { |
| 63 | HexagonArchVersion = V4; |
| 64 | } else if (CPUString == "hexagonv5") { |
| 65 | HexagonArchVersion = V5; |
| 66 | } else { |
| 67 | llvm_unreachable("Unrecognized Hexagon processor version"); |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Sebastian Pop | b72a939 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 70 | ParseSubtargetFeatures(CPUString, FS); |
| 71 | |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 72 | // Initialize scheduling itinerary for the specified CPU. |
| 73 | InstrItins = getInstrItineraryForCPU(CPUString); |
| 74 | |
Jyotsna Verma | 97e602b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 75 | // UseMemOps on by default unless disabled explicitly |
| 76 | if (DisableMemOps) |
| 77 | UseMemOps = false; |
| 78 | else if (EnableMemOps) |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 79 | UseMemOps = true; |
| 80 | else |
| 81 | UseMemOps = false; |
Sirish Pande | 7517bbc | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 82 | |
| 83 | if (EnableIEEERndNear) |
| 84 | ModeIEEERndNear = true; |
| 85 | else |
| 86 | ModeIEEERndNear = false; |
Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 87 | } |
Sirish Pande | 7517bbc | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 88 | |