blob: 48f58a55aadafbdbbbd0d8bed77c805aab4d0ea0 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +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 Lopes225ca9c2008-07-05 19:05:21 +000017#include "llvm/Module.h"
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000018#include "llvm/Support/CommandLine.h"
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000019using namespace llvm;
20
Anton Korobeynikov70f24c62008-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 Lopes43d526d2008-07-14 14:42:54 +000031
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000032MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M,
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000033 const std::string &FS, bool little) :
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000034 MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
Bruno Cardoso Lopesd3a680d2008-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)
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000038{
Bruno Cardoso Lopes000604a2007-11-06 03:15:20 +000039 std::string CPU = "mips1";
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000040
41 // Parse features string.
42 ParseSubtargetFeatures(FS, CPU);
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000043 const std::string& TT = M.getTargetTriple();
44
Bruno Cardoso Lopes91fd5322008-07-21 18:52:34 +000045 // Small section size threshold
46 SSectionThreshold = SSThreshold;
47
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000048 // Is the target system Linux ?
49 if (TT.find("linux") == std::string::npos)
50 IsLinux = false;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000051
52 // When only the target triple is specified and is
53 // a allegrex target, set the features. We also match
54 // big and little endian allegrex cores (dont really
55 // know if a big one exists)
Bruno Cardoso Lopesf131fa22008-08-08 04:49:42 +000056 if (TT.find("mipsallegrex") != std::string::npos ||
57 TT.find("psp") != std::string::npos) {
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000058 MipsABI = EABI;
59 IsSingleFloat = true;
60 MipsArchVersion = Mips2;
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000061 HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
62 HasSEInReg = true;
Bruno Cardoso Lopes65ad4522008-08-08 06:16:31 +000063 HasBitCount = true;
Bruno Cardoso Lopes739e4412008-08-13 07:13:40 +000064 HasSwap = true;
65 HasCondMov = true;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000066 }
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000067
Bruno Cardoso Lopesb3d72992008-09-15 21:06:55 +000068 // Abicall is the default for O32 ABI, but is disabled within EABI and in
69 // static code.
70 if (NotABICall || isABI_EABI() || (TM.getRelocationModel() == Reloc::Static))
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000071 HasABICall = false;
72
73 // TODO: disable when handling 64 bit symbols in the future.
74 if (HasABICall && AbsoluteCall)
75 HasAbsoluteCall = true;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000076}