Fix the ridiculous SubtargetFeatures API where it implicitly expects CPU name to
[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 using namespace llvm;
18
19 MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
20                              const std::string &FS, bool little) :
21   MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
22   IsFP64bit(false), IsGP64bit(false), HasVFPU(false), IsLinux(true),
23   HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false), HasMinMax(false),
24   HasSwap(false), HasBitCount(false)
25 {
26   std::string CPUName = CPU;
27   if (CPUName.empty())
28     CPUName = "mips1";
29   MipsArchVersion = Mips1;
30
31   // Parse features string.
32   ParseSubtargetFeatures(FS, CPUName);
33
34   // Is the target system Linux ?
35   if (TT.find("linux") == std::string::npos)
36     IsLinux = false;
37
38   // When only the target triple is specified and is
39   // a allegrex target, set the features. We also match
40   // big and little endian allegrex cores (dont really
41   // know if a big one exists)
42   if (TT.find("mipsallegrex") != std::string::npos ||
43       TT.find("psp") != std::string::npos) {
44     MipsABI = EABI;
45     IsSingleFloat = true;
46     MipsArchVersion = Mips2;
47     HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
48     HasSEInReg = true;
49     HasBitCount = true;
50     HasSwap = true;
51     HasCondMov = true;
52   }
53 }