LLVM API Documentation

MipsSubtarget.cpp

Go to the documentation of this file.
00001 //===- MipsSubtarget.cpp - Mips Subtarget Information -----------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the Mips specific subclass of TargetSubtarget.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "MipsSubtarget.h"
00015 #include "Mips.h"
00016 #include "MipsGenSubtarget.inc"
00017 #include "llvm/Module.h"
00018 #include "llvm/Support/CommandLine.h"
00019 using namespace llvm;
00020 
00021 static cl::opt<bool>
00022 NotABICall("disable-mips-abicall", cl::Hidden,
00023            cl::desc("Disable code for SVR4-style dynamic objects"));
00024 static cl::opt<bool>
00025 AbsoluteCall("enable-mips-absolute-call", cl::Hidden,
00026              cl::desc("Enable absolute call within abicall"));
00027 static cl::opt<unsigned>
00028 SSThreshold("mips-ssection-threshold", cl::Hidden,
00029             cl::desc("Small data and bss section threshold size (default=8)"),
00030             cl::init(8));
00031 
00032 MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M, 
00033                              const std::string &FS, bool little) : 
00034   MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
00035   IsFP64bit(false), IsGP64bit(false), HasVFPU(false), HasABICall(true), 
00036   HasAbsoluteCall(false), IsLinux(true), HasSEInReg(false), HasCondMov(false),
00037   HasMulDivAdd(false), HasMinMax(false), HasSwap(false), HasBitCount(false)
00038 {
00039   std::string CPU = "mips1";
00040 
00041   // Parse features string.
00042   ParseSubtargetFeatures(FS, CPU);
00043   const std::string& TT = M.getTargetTriple();
00044 
00045   // Small section size threshold
00046   SSectionThreshold = SSThreshold;
00047 
00048   // Is the target system Linux ?
00049   if (TT.find("linux") == std::string::npos)
00050     IsLinux = false;
00051 
00052   // When only the target triple is specified and is 
00053   // a allegrex target, set the features. We also match
00054   // big and little endian allegrex cores (dont really
00055   // know if a big one exists)
00056   if (TT.find("mipsallegrex") != std::string::npos ||
00057       TT.find("psp") != std::string::npos) {
00058     MipsABI = EABI;
00059     IsSingleFloat = true;
00060     MipsArchVersion = Mips2;
00061     HasVFPU = true; // Enables Allegrex Vector FPU (not supported yet)
00062     HasSEInReg = true;
00063     HasBitCount = true;
00064     HasSwap = true;
00065     HasCondMov = true;
00066   }
00067 
00068   // Abicall is the default for O32 ABI, but is disabled within EABI and in
00069   // static code.
00070   if (NotABICall || isABI_EABI() || (TM.getRelocationModel() == Reloc::Static))
00071     HasABICall = false;
00072 
00073   // TODO: disable when handling 64 bit symbols in the future.
00074   if (HasABICall && AbsoluteCall)
00075     HasAbsoluteCall = true;
00076 }