Jia Liu | c570711 | 2012-02-17 08:55:11 +0000 | [diff] [blame] | 1 | //===-- MipsSubtarget.cpp - Mips Subtarget Information --------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 9 | // |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file implements the Mips specific subclass of TargetSubtargetInfo. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 11 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 13 | |
| 14 | #include "MipsSubtarget.h" |
| 15 | #include "Mips.h" |
Akira Hatanaka | 81a424b | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 16 | #include "MipsRegisterInfo.h" |
Evan Cheng | 3e74d6f | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 17 | #include "llvm/Support/TargetRegistry.h" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 18 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 19 | #define GET_SUBTARGETINFO_TARGET_DESC |
Evan Cheng | ebdeeab | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 20 | #define GET_SUBTARGETINFO_CTOR |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 21 | #include "MipsGenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 22 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 25 | void MipsSubtarget::anchor() { } |
| 26 | |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 27 | MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU, |
| 28 | const std::string &FS, bool little) : |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 29 | MipsGenSubtargetInfo(TT, CPU, FS), |
Jia Liu | bb481f8 | 2012-02-28 07:46:26 +0000 | [diff] [blame] | 30 | MipsArchVersion(Mips32), MipsABI(UnknownABI), IsLittle(little), |
Akira Hatanaka | 0e64f81 | 2011-09-21 17:31:45 +0000 | [diff] [blame] | 31 | IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false), |
| 32 | IsLinux(true), HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false), |
Akira Hatanaka | 66e19c3 | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 33 | HasMinMax(false), HasSwap(false), HasBitCount(false), InMips16Mode(false) |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 34 | { |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 35 | std::string CPUName = CPU; |
| 36 | if (CPUName.empty()) |
Akira Hatanaka | ed2a7d2 | 2011-11-29 23:08:41 +0000 | [diff] [blame] | 37 | CPUName = "mips32"; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 38 | |
| 39 | // Parse features string. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 40 | ParseSubtargetFeatures(CPUName, FS); |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 41 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 42 | // Initialize scheduling itinerary for the specified CPU. |
| 43 | InstrItins = getInstrItineraryForCPU(CPUName); |
| 44 | |
Akira Hatanaka | 8c1b4bf | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 45 | // Set MipsABI if it hasn't been set yet. |
| 46 | if (MipsABI == UnknownABI) |
Jia Liu | bb481f8 | 2012-02-28 07:46:26 +0000 | [diff] [blame] | 47 | MipsABI = hasMips64() ? N64 : O32; |
Akira Hatanaka | 8c1b4bf | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 48 | |
| 49 | // Check if Architecture and ABI are compatible. |
| 50 | assert(((!hasMips64() && (isABI_O32() || isABI_EABI())) || |
| 51 | (hasMips64() && (isABI_N32() || isABI_N64()))) && |
| 52 | "Invalid Arch & ABI pair."); |
| 53 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 54 | // Is the target system Linux ? |
| 55 | if (TT.find("linux") == std::string::npos) |
| 56 | IsLinux = false; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 57 | } |
Akira Hatanaka | 81a424b | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 58 | |
| 59 | bool |
| 60 | MipsSubtarget::enablePostRAScheduler(CodeGenOpt::Level OptLevel, |
Akira Hatanaka | 864f660 | 2012-06-14 21:10:56 +0000 | [diff] [blame] | 61 | TargetSubtargetInfo::AntiDepBreakMode &Mode, |
| 62 | RegClassVector &CriticalPathRCs) const { |
Akira Hatanaka | 24d86e0 | 2012-05-15 03:14:52 +0000 | [diff] [blame] | 63 | Mode = TargetSubtargetInfo::ANTIDEP_NONE; |
Akira Hatanaka | 81a424b | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 64 | CriticalPathRCs.clear(); |
| 65 | CriticalPathRCs.push_back(hasMips64() ? |
| 66 | &Mips::CPU64RegsRegClass : &Mips::CPURegsRegClass); |
Akira Hatanaka | 5ca6b02 | 2012-03-28 00:52:23 +0000 | [diff] [blame] | 67 | return OptLevel >= CodeGenOpt::Aggressive; |
Akira Hatanaka | 81a424b | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 68 | } |