blob: 19c9ecd1ceff6d101e321229d369059b94243277 [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
Eric Christopherc4c63ae2014-06-27 00:27:40 +000051HexagonSubtarget &
52HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000053 // If the programmer has not specified a Hexagon version, default to -mv4.
54 if (CPUString.empty())
Sebastian Pop221e07e2012-07-19 18:24:50 +000055 CPUString = "hexagonv4";
Sebastian Pop1a0bef62012-08-20 19:56:47 +000056
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 Linthicum1213a7a2011-12-12 21:14:40 +000068 }
69
Sebastian Pop1a0bef62012-08-20 19:56:47 +000070 ParseSubtargetFeatures(CPUString, FS);
Eric Christopherc4c63ae2014-06-27 00:27:40 +000071 return *this;
72}
73
74HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
75 const TargetMachine &TM)
76 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU.str()),
Eric Christopherc4c63ae2014-06-27 00:27:40 +000077 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
Eric Christopher8b770652015-01-26 19:03:15 +000078 TSInfo(*TM.getDataLayout()), FrameLowering() {
Sebastian Pop1a0bef62012-08-20 19:56:47 +000079
Tony Linthicum1213a7a2011-12-12 21:14:40 +000080 // Initialize scheduling itinerary for the specified CPU.
81 InstrItins = getInstrItineraryForCPU(CPUString);
82
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000083 // UseMemOps on by default unless disabled explicitly
84 if (DisableMemOps)
85 UseMemOps = false;
86 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +000087 UseMemOps = true;
88 else
89 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +000090
91 if (EnableIEEERndNear)
92 ModeIEEERndNear = true;
93 else
94 ModeIEEERndNear = false;
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() {}