MipsSubtarget.cpp revision 5ffd24c49f6d78c166ee357424bf4e20f61af6bc
1//===-- MipsSubtarget.cpp - Mips Subtarget Information --------------------===//
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 TargetSubtargetInfo.
11//
12//===----------------------------------------------------------------------===//
13
14#include "MipsSubtarget.h"
15#include "Mips.h"
16#include "MipsRegisterInfo.h"
17#include "llvm/Support/TargetRegistry.h"
18
19#define GET_SUBTARGETINFO_TARGET_DESC
20#define GET_SUBTARGETINFO_CTOR
21#include "MipsGenSubtargetInfo.inc"
22
23using namespace llvm;
24
25void MipsSubtarget::anchor() { }
26
27MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
28                             const std::string &FS, bool little,
29                             Reloc::Model _RM) :
30  MipsGenSubtargetInfo(TT, CPU, FS),
31  MipsArchVersion(Mips32), MipsABI(UnknownABI), IsLittle(little),
32  IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false),
33  IsLinux(true), HasSEInReg(false), HasCondMov(false), HasSwap(false),
34  HasBitCount(false), HasFPIdx(false),
35  InMips16Mode(false), InMicroMipsMode(false), HasDSP(false), HasDSPR2(false),
36  RM(_RM)
37{
38  std::string CPUName = CPU;
39  if (CPUName.empty())
40    CPUName = "mips32";
41
42  // Parse features string.
43  ParseSubtargetFeatures(CPUName, FS);
44
45  // Initialize scheduling itinerary for the specified CPU.
46  InstrItins = getInstrItineraryForCPU(CPUName);
47
48  // Set MipsABI if it hasn't been set yet.
49  if (MipsABI == UnknownABI)
50    MipsABI = hasMips64() ? N64 : O32;
51
52  // Check if Architecture and ABI are compatible.
53  assert(((!hasMips64() && (isABI_O32() || isABI_EABI())) ||
54          (hasMips64() && (isABI_N32() || isABI_N64()))) &&
55         "Invalid  Arch & ABI pair.");
56
57  // Is the target system Linux ?
58  if (TT.find("linux") == std::string::npos)
59    IsLinux = false;
60
61  // Set UseSmallSection.
62  UseSmallSection = !IsLinux && (RM == Reloc::Static);
63}
64
65bool
66MipsSubtarget::enablePostRAScheduler(CodeGenOpt::Level OptLevel,
67                                    TargetSubtargetInfo::AntiDepBreakMode &Mode,
68                                     RegClassVector &CriticalPathRCs) const {
69  Mode = TargetSubtargetInfo::ANTIDEP_NONE;
70  CriticalPathRCs.clear();
71  CriticalPathRCs.push_back(hasMips64() ?
72                            &Mips::CPU64RegsRegClass : &Mips::CPURegsRegClass);
73  return OptLevel >= CodeGenOpt::Aggressive;
74}
75