blob: dd115fdecf9780a9f5816768b7bb4ea960e8c174 [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),
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000027 MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
Eli Friedmane2c74082009-08-03 02:22:28 +000028 IsFP64bit(false), IsGP64bit(false), HasVFPU(false), IsLinux(true),
29 HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false), HasMinMax(false),
30 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 Hatanakaad5f0c92011-09-09 01:13:27 +000034 CPUName = "mips32r1";
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
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000042 // Is the target system Linux ?
43 if (TT.find("linux") == std::string::npos)
44 IsLinux = false;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000045
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000046 // When only the target triple is specified and is
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000047 // a allegrex target, set the features. We also match
48 // big and little endian allegrex cores (dont really
49 // know if a big one exists)
Bruno Cardoso Lopesf131fa22008-08-08 04:49:42 +000050 if (TT.find("mipsallegrex") != std::string::npos ||
51 TT.find("psp") != std::string::npos) {
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000052 MipsABI = EABI;
53 IsSingleFloat = true;
54 MipsArchVersion = Mips2;
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000055 HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
56 HasSEInReg = true;
Bruno Cardoso Lopes65ad4522008-08-08 06:16:31 +000057 HasBitCount = true;
Bruno Cardoso Lopes739e4412008-08-13 07:13:40 +000058 HasSwap = true;
59 HasCondMov = true;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000060 }
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000061}