blob: 342438801143a0cf655190295a0162ae6a2e022e [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
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000021cl::opt<bool> NotABICall("disable-mips-abicall", cl::Hidden,
22 cl::desc("Disable code for SVR4-style dynamic objects"));
23cl::opt<bool> AbsoluteCall("enable-mips-absolute-call", cl::Hidden,
24 cl::desc("Enable absolute call within abicall"));
25
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000026MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M,
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000027 const std::string &FS, bool little) :
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000028 MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000029 IsFP64bit(false), IsGP64bit(false), HasVFPU(false), HasSEInReg(false),
30 HasABICall(true), HasAbsoluteCall(false), IsLinux(true)
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000031{
Bruno Cardoso Lopes000604a2007-11-06 03:15:20 +000032 std::string CPU = "mips1";
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000033
34 // Parse features string.
35 ParseSubtargetFeatures(FS, CPU);
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000036 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 Lopes225ca9c2008-07-05 19:05:21 +000041
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 Lopes225ca9c2008-07-05 19:05:21 +000046 if (TT.find("mipsallegrex") != std::string::npos) {
47 MipsABI = EABI;
48 IsSingleFloat = true;
49 MipsArchVersion = Mips2;
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000050 HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
51 HasSEInReg = true;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000052 }
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000053
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 Lopes972f5892007-06-06 07:42:06 +000062}