blob: 4bacb8fa670d9ae7e45b11dffacf8d5c3884db36 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===//
Tony Linthicumb4b54152011-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 Pande7517bbc2012-05-10 20:20:25 +000016#include "HexagonRegisterInfo.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000017#include "llvm/Support/CommandLine.h"
18#include "llvm/Support/ErrorHandling.h"
19using namespace llvm;
20
Tony Linthicumb4b54152011-12-12 21:14:40 +000021#define GET_SUBTARGETINFO_CTOR
22#define GET_SUBTARGETINFO_TARGET_DESC
23#include "HexagonGenSubtargetInfo.inc"
24
25static cl::opt<bool>
26EnableV3("enable-hexagon-v3", cl::Hidden,
27 cl::desc("Enable Hexagon V3 instructions."));
28
29static cl::opt<bool>
30EnableMemOps(
31 "enable-hexagon-memops",
32 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed,
Sirish Pande7517bbc2012-05-10 20:20:25 +000033 cl::desc("Generate V4 memop instructions."));
34
35static cl::opt<bool>
36EnableIEEERndNear(
37 "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 Linthicumb4b54152011-12-12 21:14:40 +000040
41HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS):
42 HexagonGenSubtargetInfo(TT, CPU, FS),
Tony Linthicumb4b54152011-12-12 21:14:40 +000043 CPUString(CPU.str()) {
Tony Linthicumb4b54152011-12-12 21:14:40 +000044
Sebastian Popb72a9392012-08-20 19:56:47 +000045 // If the programmer has not specified a Hexagon version, default to -mv4.
46 if (CPUString.empty())
Sebastian Pope88ed092012-07-19 18:24:50 +000047 CPUString = "hexagonv4";
Sebastian Popb72a9392012-08-20 19:56:47 +000048
49 if (CPUString == "hexagonv2") {
50 HexagonArchVersion = V2;
51 } else if (CPUString == "hexagonv3") {
52 EnableV3 = true;
53 HexagonArchVersion = V3;
54 } else if (CPUString == "hexagonv4") {
55 HexagonArchVersion = V4;
56 } else if (CPUString == "hexagonv5") {
57 HexagonArchVersion = V5;
58 } else {
59 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicumb4b54152011-12-12 21:14:40 +000060 }
61
Sebastian Popb72a9392012-08-20 19:56:47 +000062 ParseSubtargetFeatures(CPUString, FS);
63
Tony Linthicumb4b54152011-12-12 21:14:40 +000064 // Initialize scheduling itinerary for the specified CPU.
65 InstrItins = getInstrItineraryForCPU(CPUString);
66
Tony Linthicumb4b54152011-12-12 21:14:40 +000067 if (EnableMemOps)
68 UseMemOps = true;
69 else
70 UseMemOps = false;
Sirish Pande7517bbc2012-05-10 20:20:25 +000071
72 if (EnableIEEERndNear)
73 ModeIEEERndNear = true;
74 else
75 ModeIEEERndNear = false;
Tony Linthicumb4b54152011-12-12 21:14:40 +000076}
Sirish Pande7517bbc2012-05-10 20:20:25 +000077