blob: b2b26521fffdc0192c8cf9feb3830552e6695eea [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 Chengffc0e732011-07-09 05:47:46 +000016#include "llvm/Target/TargetRegistry.h"
Evan Cheng94214702011-07-01 20:45:01 +000017
Evan Chengebdeeab2011-07-08 01:53:10 +000018#define GET_SUBTARGETINFO_ENUM
Evan Cheng94214702011-07-01 20:45:01 +000019#define GET_SUBTARGETINFO_MC_DESC
20#define GET_SUBTARGETINFO_TARGET_DESC
Evan Chengebdeeab2011-07-08 01:53:10 +000021#define GET_SUBTARGETINFO_CTOR
Evan Cheng385e9302011-07-01 22:36:09 +000022#include "MipsGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000023
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000024using namespace llvm;
25
Evan Cheng276365d2011-06-30 01:53:36 +000026MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
27 const std::string &FS, bool little) :
Evan Cheng0ddff1b2011-07-07 07:07:08 +000028 MipsGenSubtargetInfo(TT, CPU, FS),
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000029 MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
Eli Friedmane2c74082009-08-03 02:22:28 +000030 IsFP64bit(false), IsGP64bit(false), HasVFPU(false), IsLinux(true),
31 HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false), HasMinMax(false),
32 HasSwap(false), HasBitCount(false)
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000033{
Evan Cheng276365d2011-06-30 01:53:36 +000034 std::string CPUName = CPU;
35 if (CPUName.empty())
36 CPUName = "mips1";
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +000037 MipsArchVersion = Mips1;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000038
39 // Parse features string.
Evan Cheng0ddff1b2011-07-07 07:07:08 +000040 ParseSubtargetFeatures(CPUName, FS);
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000041
Evan Cheng94214702011-07-01 20:45:01 +000042 // Initialize scheduling itinerary for the specified CPU.
43 InstrItins = getInstrItineraryForCPU(CPUName);
44
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000045 // Is the target system Linux ?
46 if (TT.find("linux") == std::string::npos)
47 IsLinux = false;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000048
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000049 // When only the target triple is specified and is
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000050 // a allegrex target, set the features. We also match
51 // big and little endian allegrex cores (dont really
52 // know if a big one exists)
Bruno Cardoso Lopesf131fa22008-08-08 04:49:42 +000053 if (TT.find("mipsallegrex") != std::string::npos ||
54 TT.find("psp") != std::string::npos) {
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000055 MipsABI = EABI;
56 IsSingleFloat = true;
57 MipsArchVersion = Mips2;
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000058 HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
59 HasSEInReg = true;
Bruno Cardoso Lopes65ad4522008-08-08 06:16:31 +000060 HasBitCount = true;
Bruno Cardoso Lopes739e4412008-08-13 07:13:40 +000061 HasSwap = true;
62 HasCondMov = true;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000063 }
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000064}
Evan Chengffc0e732011-07-09 05:47:46 +000065
66MCSubtargetInfo *createMipsMCSubtargetInfo(StringRef TT, StringRef CPU,
67 StringRef FS) {
68 MCSubtargetInfo *X = new MCSubtargetInfo();
69 InitMipsMCSubtargetInfo(X, CPU, FS);
70 return X;
71}
72
73extern "C" void LLVMInitializeMipsMCSubtargetInfo() {
74 TargetRegistry::RegisterMCSubtargetInfo(TheMipsTarget,
75 createMipsMCSubtargetInfo);
76}