Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 1 | //===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===// |
| 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 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Mips specific subclass of TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "MipsSubtarget.h" |
| 15 | #include "Mips.h" |
| 16 | #include "MipsGenSubtarget.inc" |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 17 | #include "llvm/Support/CommandLine.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| 19 | |
Anton Korobeynikov | 70f24c6 | 2008-08-22 21:27:49 +0000 | [diff] [blame] | 20 | static cl::opt<bool> |
| 21 | NotABICall("disable-mips-abicall", cl::Hidden, |
| 22 | cl::desc("Disable code for SVR4-style dynamic objects")); |
| 23 | static cl::opt<bool> |
| 24 | AbsoluteCall("enable-mips-absolute-call", cl::Hidden, |
| 25 | cl::desc("Enable absolute call within abicall")); |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 26 | |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 27 | MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const std::string &TT, |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 28 | const std::string &FS, bool little) : |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 29 | MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false), |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 30 | IsFP64bit(false), IsGP64bit(false), HasVFPU(false), HasABICall(true), |
| 31 | HasAbsoluteCall(false), IsLinux(true), HasSEInReg(false), HasCondMov(false), |
| 32 | HasMulDivAdd(false), HasMinMax(false), HasSwap(false), HasBitCount(false) |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 33 | { |
Bruno Cardoso Lopes | 000604a | 2007-11-06 03:15:20 +0000 | [diff] [blame] | 34 | std::string CPU = "mips1"; |
Bruno Cardoso Lopes | d3bdf19 | 2009-05-27 17:23:44 +0000 | [diff] [blame] | 35 | MipsArchVersion = Mips1; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 36 | |
| 37 | // Parse features string. |
| 38 | ParseSubtargetFeatures(FS, CPU); |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 39 | |
| 40 | // Is the target system Linux ? |
| 41 | if (TT.find("linux") == std::string::npos) |
| 42 | IsLinux = false; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 43 | |
| 44 | // When only the target triple is specified and is |
| 45 | // a allegrex target, set the features. We also match |
| 46 | // big and little endian allegrex cores (dont really |
| 47 | // know if a big one exists) |
Bruno Cardoso Lopes | f131fa2 | 2008-08-08 04:49:42 +0000 | [diff] [blame] | 48 | if (TT.find("mipsallegrex") != std::string::npos || |
| 49 | TT.find("psp") != std::string::npos) { |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 50 | MipsABI = EABI; |
| 51 | IsSingleFloat = true; |
| 52 | MipsArchVersion = Mips2; |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 53 | HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet) |
| 54 | HasSEInReg = true; |
Bruno Cardoso Lopes | 65ad452 | 2008-08-08 06:16:31 +0000 | [diff] [blame] | 55 | HasBitCount = true; |
Bruno Cardoso Lopes | 739e441 | 2008-08-13 07:13:40 +0000 | [diff] [blame] | 56 | HasSwap = true; |
| 57 | HasCondMov = true; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 58 | } |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 59 | |
Bruno Cardoso Lopes | b3d7299 | 2008-09-15 21:06:55 +0000 | [diff] [blame] | 60 | // Abicall is the default for O32 ABI, but is disabled within EABI and in |
| 61 | // static code. |
| 62 | if (NotABICall || isABI_EABI() || (TM.getRelocationModel() == Reloc::Static)) |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 63 | HasABICall = false; |
| 64 | |
| 65 | // TODO: disable when handling 64 bit symbols in the future. |
| 66 | if (HasABICall && AbsoluteCall) |
| 67 | HasAbsoluteCall = true; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 68 | } |