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 | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 17 | #include "llvm/Module.h" |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame^] | 18 | #include "llvm/Support/CommandLine.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame^] | 21 | cl::opt<bool> NotABICall("disable-mips-abicall", cl::Hidden, |
| 22 | cl::desc("Disable code for SVR4-style dynamic objects")); |
| 23 | cl::opt<bool> AbsoluteCall("enable-mips-absolute-call", cl::Hidden, |
| 24 | cl::desc("Enable absolute call within abicall")); |
| 25 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 26 | MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M, |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 27 | const std::string &FS, bool little) : |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 28 | MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false), |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame^] | 29 | IsFP64bit(false), IsGP64bit(false), HasVFPU(false), HasSEInReg(false), |
| 30 | HasABICall(true), HasAbsoluteCall(false), IsLinux(true) |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 31 | { |
Bruno Cardoso Lopes | 000604a | 2007-11-06 03:15:20 +0000 | [diff] [blame] | 32 | std::string CPU = "mips1"; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 33 | |
| 34 | // Parse features string. |
| 35 | ParseSubtargetFeatures(FS, CPU); |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame^] | 36 | const std::string& TT = M.getTargetTriple(); |
| 37 | |
| 38 | // Is the target system Linux ? |
| 39 | if (TT.find("linux") == std::string::npos) |
| 40 | IsLinux = false; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 41 | |
| 42 | // When only the target triple is specified and is |
| 43 | // a allegrex target, set the features. We also match |
| 44 | // big and little endian allegrex cores (dont really |
| 45 | // know if a big one exists) |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 46 | if (TT.find("mipsallegrex") != std::string::npos) { |
| 47 | MipsABI = EABI; |
| 48 | IsSingleFloat = true; |
| 49 | MipsArchVersion = Mips2; |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 50 | HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet) |
| 51 | HasSEInReg = true; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 52 | } |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame^] | 53 | |
| 54 | // Abicall is the default for O32 ABI and is ignored |
| 55 | // for EABI. |
| 56 | if (NotABICall || isABI_EABI()) |
| 57 | HasABICall = false; |
| 58 | |
| 59 | // TODO: disable when handling 64 bit symbols in the future. |
| 60 | if (HasABICall && AbsoluteCall) |
| 61 | HasAbsoluteCall = true; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 62 | } |