blob: ac83d839fecd2d8849197c19d3c266bedd0660f9 [file] [log] [blame]
Jia Liu9f610112012-02-17 08:55:11 +00001//===-- MipsSubtarget.cpp - Mips Subtarget Information --------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Lopes35e43c42007-06-06 07:42:06 +00007//
Akira Hatanakae2489122011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00009//
Evan Cheng0d639a22011-07-01 21:01:15 +000010// This file implements the Mips specific subclass of TargetSubtargetInfo.
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000011//
Akira Hatanakae2489122011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000013
14#include "MipsSubtarget.h"
15#include "Mips.h"
Akira Hatanaka047473e2012-03-28 00:24:17 +000016#include "MipsRegisterInfo.h"
Evan Cheng2bb40352011-08-24 18:08:43 +000017#include "llvm/Support/TargetRegistry.h"
Evan Cheng54b68e32011-07-01 20:45:01 +000018
Evan Cheng54b68e32011-07-01 20:45:01 +000019#define GET_SUBTARGETINFO_TARGET_DESC
Evan Cheng4d1ca962011-07-08 01:53:10 +000020#define GET_SUBTARGETINFO_CTOR
Evan Chengc9c090d2011-07-01 22:36:09 +000021#include "MipsGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000022
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000023using namespace llvm;
24
David Blaikiea379b1812011-12-20 02:50:00 +000025void MipsSubtarget::anchor() { }
26
Evan Chengfe6e4052011-06-30 01:53:36 +000027MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
Akira Hatanakaad495022012-08-22 03:18:13 +000028 const std::string &FS, bool little,
29 Reloc::Model RM) :
Evan Cheng1a72add62011-07-07 07:07:08 +000030 MipsGenSubtargetInfo(TT, CPU, FS),
Jia Liuf54f60f2012-02-28 07:46:26 +000031 MipsArchVersion(Mips32), MipsABI(UnknownABI), IsLittle(little),
Akira Hatanaka1b185f42011-09-21 17:31:45 +000032 IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false),
33 IsLinux(true), HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false),
Akira Hatanaka0faaebf2012-05-16 22:19:56 +000034 HasMinMax(false), HasSwap(false), HasBitCount(false), InMips16Mode(false)
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000035{
Evan Chengfe6e4052011-06-30 01:53:36 +000036 std::string CPUName = CPU;
37 if (CPUName.empty())
Akira Hatanakadc25f9f2011-11-29 23:08:41 +000038 CPUName = "mips32";
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000039
40 // Parse features string.
Evan Cheng1a72add62011-07-07 07:07:08 +000041 ParseSubtargetFeatures(CPUName, FS);
Bruno Cardoso Lopes80ab8f92008-07-14 14:42:54 +000042
Evan Cheng54b68e32011-07-01 20:45:01 +000043 // Initialize scheduling itinerary for the specified CPU.
44 InstrItins = getInstrItineraryForCPU(CPUName);
45
Akira Hatanaka6de4d122011-09-21 02:45:29 +000046 // Set MipsABI if it hasn't been set yet.
47 if (MipsABI == UnknownABI)
Jia Liuf54f60f2012-02-28 07:46:26 +000048 MipsABI = hasMips64() ? N64 : O32;
Akira Hatanaka6de4d122011-09-21 02:45:29 +000049
50 // Check if Architecture and ABI are compatible.
51 assert(((!hasMips64() && (isABI_O32() || isABI_EABI())) ||
52 (hasMips64() && (isABI_N32() || isABI_N64()))) &&
53 "Invalid Arch & ABI pair.");
54
Bruno Cardoso Lopes80ab8f92008-07-14 14:42:54 +000055 // Is the target system Linux ?
56 if (TT.find("linux") == std::string::npos)
57 IsLinux = false;
Akira Hatanakaad495022012-08-22 03:18:13 +000058
59 // Set UseSmallSection.
60 UseSmallSection = !IsLinux && (RM == Reloc::Static);
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000061}
Akira Hatanaka047473e2012-03-28 00:24:17 +000062
63bool
64MipsSubtarget::enablePostRAScheduler(CodeGenOpt::Level OptLevel,
Akira Hatanaka5fd22482012-06-14 21:10:56 +000065 TargetSubtargetInfo::AntiDepBreakMode &Mode,
66 RegClassVector &CriticalPathRCs) const {
Akira Hatanakacf434ee2012-05-15 03:14:52 +000067 Mode = TargetSubtargetInfo::ANTIDEP_NONE;
Akira Hatanaka047473e2012-03-28 00:24:17 +000068 CriticalPathRCs.clear();
69 CriticalPathRCs.push_back(hasMips64() ?
70 &Mips::CPU64RegsRegClass : &Mips::CPURegsRegClass);
Akira Hatanaka2c670062012-03-28 00:52:23 +000071 return OptLevel >= CodeGenOpt::Aggressive;
Akira Hatanaka047473e2012-03-28 00:24:17 +000072}