Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 1 | //===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===// |
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" |
Evan Cheng | 3e74d6f | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 16 | #include "llvm/Support/TargetRegistry.h" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 17 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 18 | #define GET_SUBTARGETINFO_TARGET_DESC |
Evan Cheng | ebdeeab | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 19 | #define GET_SUBTARGETINFO_CTOR |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 20 | #include "MipsGenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 21 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 22 | using namespace llvm; |
| 23 | |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 24 | MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU, |
| 25 | const std::string &FS, bool little) : |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 26 | MipsGenSubtargetInfo(TT, CPU, FS), |
Akira Hatanaka | 0e64f81 | 2011-09-21 17:31:45 +0000 | [diff] [blame^] | 27 | 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 Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 31 | { |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 32 | std::string CPUName = CPU; |
| 33 | if (CPUName.empty()) |
Akira Hatanaka | ad5f0c9 | 2011-09-09 01:13:27 +0000 | [diff] [blame] | 34 | CPUName = "mips32r1"; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 35 | |
| 36 | // Parse features string. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 37 | ParseSubtargetFeatures(CPUName, FS); |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 38 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 39 | // Initialize scheduling itinerary for the specified CPU. |
| 40 | InstrItins = getInstrItineraryForCPU(CPUName); |
| 41 | |
Akira Hatanaka | 8c1b4bf | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 42 | // 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 Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 51 | // Is the target system Linux ? |
| 52 | if (TT.find("linux") == std::string::npos) |
| 53 | IsLinux = false; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 54 | } |