Normalize Subtarget constructors to take a target triple string instead of
[oota-llvm.git] / lib / Target / Mips / MipsSubtarget.cpp
1 //===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===//
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 Mips specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MipsSubtarget.h"
15 #include "Mips.h"
16 #include "MipsGenSubtarget.inc"
17 #include "llvm/Support/CommandLine.h"
18 using namespace llvm;
19
20 static cl::opt<bool>
21 NotABICall("disable-mips-abicall", cl::Hidden,
22            cl::desc("Disable code for SVR4-style dynamic objects"));
23 static cl::opt<bool>
24 AbsoluteCall("enable-mips-absolute-call", cl::Hidden,
25              cl::desc("Enable absolute call within abicall"));
26
27 MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const std::string &TT,
28                              const std::string &FS, bool little) : 
29   MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
30   IsFP64bit(false), IsGP64bit(false), HasVFPU(false), HasABICall(true), 
31   HasAbsoluteCall(false), IsLinux(true), HasSEInReg(false), HasCondMov(false),
32   HasMulDivAdd(false), HasMinMax(false), HasSwap(false), HasBitCount(false)
33 {
34   std::string CPU = "mips1";
35   MipsArchVersion = Mips1;
36
37   // Parse features string.
38   ParseSubtargetFeatures(FS, CPU);
39
40   // Is the target system Linux ?
41   if (TT.find("linux") == std::string::npos)
42     IsLinux = false;
43
44   // When only the target triple is specified and is 
45   // a allegrex target, set the features. We also match
46   // big and little endian allegrex cores (dont really
47   // know if a big one exists)
48   if (TT.find("mipsallegrex") != std::string::npos ||
49       TT.find("psp") != std::string::npos) {
50     MipsABI = EABI;
51     IsSingleFloat = true;
52     MipsArchVersion = Mips2;
53     HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
54     HasSEInReg = true;
55     HasBitCount = true;
56     HasSwap = true;
57     HasCondMov = true;
58   }
59
60   // Abicall is the default for O32 ABI, but is disabled within EABI and in
61   // static code.
62   if (NotABICall || isABI_EABI() || (TM.getRelocationModel() == Reloc::Static))
63     HasABICall = false;
64
65   // TODO: disable when handling 64 bit symbols in the future.
66   if (HasABICall && AbsoluteCall)
67     HasAbsoluteCall = true;
68 }