blob: 4245f274f8f046fdbcc30a06b465c257a753dd96 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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 Lopes4fb1f542008-07-05 19:05:21 +000017#include "llvm/Module.h"
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +000018#include "llvm/Support/CommandLine.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
20
Anton Korobeynikov18720012008-08-22 21:27:49 +000021static cl::opt<bool>
22NotABICall("disable-mips-abicall", cl::Hidden,
23 cl::desc("Disable code for SVR4-style dynamic objects"));
24static cl::opt<bool>
25AbsoluteCall("enable-mips-absolute-call", cl::Hidden,
26 cl::desc("Enable absolute call within abicall"));
27static cl::opt<unsigned>
28SSThreshold("mips-ssection-threshold", cl::Hidden,
29 cl::desc("Small data and bss section threshold size (default=8)"),
30 cl::init(8));
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +000031
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M,
Bruno Cardoso Lopesdb260942008-06-04 01:45:25 +000033 const std::string &FS, bool little) :
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000034 MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
Bruno Cardoso Lopes10ff0392008-07-30 17:01:06 +000035 IsFP64bit(false), IsGP64bit(false), HasVFPU(false), HasABICall(true),
36 HasAbsoluteCall(false), IsLinux(true), HasSEInReg(false), HasCondMov(false),
37 HasMulDivAdd(false), HasMinMax(false), HasSwap(false), HasBitCount(false)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038{
Bruno Cardoso Lopes0ec193d2007-11-06 03:15:20 +000039 std::string CPU = "mips1";
Bruno Cardoso Lopes643c0402009-05-27 17:23:44 +000040 MipsArchVersion = Mips1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
42 // Parse features string.
43 ParseSubtargetFeatures(FS, CPU);
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +000044 const std::string& TT = M.getTargetTriple();
45
Bruno Cardoso Lopes12355a82008-07-21 18:52:34 +000046 // Small section size threshold
47 SSectionThreshold = SSThreshold;
48
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +000049 // Is the target system Linux ?
50 if (TT.find("linux") == std::string::npos)
51 IsLinux = false;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000052
53 // When only the target triple is specified and is
54 // a allegrex target, set the features. We also match
55 // big and little endian allegrex cores (dont really
56 // know if a big one exists)
Bruno Cardoso Lopesb619af72008-08-08 04:49:42 +000057 if (TT.find("mipsallegrex") != std::string::npos ||
58 TT.find("psp") != std::string::npos) {
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000059 MipsABI = EABI;
60 IsSingleFloat = true;
61 MipsArchVersion = Mips2;
Bruno Cardoso Lopesdfd657f2008-07-09 05:32:22 +000062 HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
63 HasSEInReg = true;
Bruno Cardoso Lopesea4fc382008-08-08 06:16:31 +000064 HasBitCount = true;
Bruno Cardoso Lopes60f3e052008-08-13 07:13:40 +000065 HasSwap = true;
66 HasCondMov = true;
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000067 }
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +000068
Bruno Cardoso Lopesc690c7c2008-09-15 21:06:55 +000069 // Abicall is the default for O32 ABI, but is disabled within EABI and in
70 // static code.
71 if (NotABICall || isABI_EABI() || (TM.getRelocationModel() == Reloc::Static))
Bruno Cardoso Lopes29c15352008-07-14 14:42:54 +000072 HasABICall = false;
73
74 // TODO: disable when handling 64 bit symbols in the future.
75 if (HasABICall && AbsoluteCall)
76 HasAbsoluteCall = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077}