blob: 70c87fa19d1a839cdfb6412a0282edcbe6b43812 [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
51HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS):
52 HexagonGenSubtargetInfo(TT, CPU, FS),
Tony Linthicum1213a7a2011-12-12 21:14:40 +000053 CPUString(CPU.str()) {
Tony Linthicum1213a7a2011-12-12 21:14:40 +000054
Sebastian Pop1a0bef62012-08-20 19:56:47 +000055 // If the programmer has not specified a Hexagon version, default to -mv4.
56 if (CPUString.empty())
Sebastian Pop221e07e2012-07-19 18:24:50 +000057 CPUString = "hexagonv4";
Sebastian Pop1a0bef62012-08-20 19:56:47 +000058
59 if (CPUString == "hexagonv2") {
60 HexagonArchVersion = V2;
61 } else if (CPUString == "hexagonv3") {
62 EnableV3 = true;
63 HexagonArchVersion = V3;
64 } else if (CPUString == "hexagonv4") {
65 HexagonArchVersion = V4;
66 } else if (CPUString == "hexagonv5") {
67 HexagonArchVersion = V5;
68 } else {
69 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicum1213a7a2011-12-12 21:14:40 +000070 }
71
Sebastian Pop1a0bef62012-08-20 19:56:47 +000072 ParseSubtargetFeatures(CPUString, FS);
73
Tony Linthicum1213a7a2011-12-12 21:14:40 +000074 // Initialize scheduling itinerary for the specified CPU.
75 InstrItins = getInstrItineraryForCPU(CPUString);
76
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000077 // UseMemOps on by default unless disabled explicitly
78 if (DisableMemOps)
79 UseMemOps = false;
80 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +000081 UseMemOps = true;
82 else
83 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +000084
85 if (EnableIEEERndNear)
86 ModeIEEERndNear = true;
87 else
88 ModeIEEERndNear = false;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000089}
Sirish Pande69295b82012-05-10 20:20:25 +000090
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000091// Pin the vtable to this file.
92void HexagonSubtarget::anchor() {}