blob: dc299f27830b85adf676e90732b4f2b712916c57 [file] [log] [blame]
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00001//===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00009//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file implements the Mips specific subclass of TargetSubtargetInfo.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000011//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000013
14#include "MipsSubtarget.h"
15#include "Mips.h"
Evan Cheng3e74d6f2011-08-24 18:08:43 +000016#include "llvm/Support/TargetRegistry.h"
Evan Cheng94214702011-07-01 20:45:01 +000017
Evan Cheng94214702011-07-01 20:45:01 +000018#define GET_SUBTARGETINFO_TARGET_DESC
Evan Chengebdeeab2011-07-08 01:53:10 +000019#define GET_SUBTARGETINFO_CTOR
Evan Cheng385e9302011-07-01 22:36:09 +000020#include "MipsGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000021
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000022using namespace llvm;
23
Evan Cheng276365d2011-06-30 01:53:36 +000024MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
25 const std::string &FS, bool little) :
Evan Cheng0ddff1b2011-07-07 07:07:08 +000026 MipsGenSubtargetInfo(TT, CPU, FS),
Akira Hatanaka0e64f812011-09-21 17:31:45 +000027 MipsArchVersion(Mips32), MipsABI(UnknownABI), IsLittle(little),
28 IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false),
29 IsLinux(true), HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false),
30 HasMinMax(false), HasSwap(false), HasBitCount(false)
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000031{
Evan Cheng276365d2011-06-30 01:53:36 +000032 std::string CPUName = CPU;
33 if (CPUName.empty())
Akira Hatanakaed2a7d22011-11-29 23:08:41 +000034 CPUName = "mips32";
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000035
36 // Parse features string.
Evan Cheng0ddff1b2011-07-07 07:07:08 +000037 ParseSubtargetFeatures(CPUName, FS);
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000038
Evan Cheng94214702011-07-01 20:45:01 +000039 // Initialize scheduling itinerary for the specified CPU.
40 InstrItins = getInstrItineraryForCPU(CPUName);
41
Akira Hatanaka8c1b4bf2011-09-21 02:45:29 +000042 // Set MipsABI if it hasn't been set yet.
43 if (MipsABI == UnknownABI)
44 MipsABI = hasMips64() ? N64 : O32;
45
46 // Check if Architecture and ABI are compatible.
47 assert(((!hasMips64() && (isABI_O32() || isABI_EABI())) ||
48 (hasMips64() && (isABI_N32() || isABI_N64()))) &&
49 "Invalid Arch & ABI pair.");
50
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000051 // Is the target system Linux ?
52 if (TT.find("linux") == std::string::npos)
53 IsLinux = false;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000054}