2007-01-19 15:51:42 +08:00
|
|
|
//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 15:51:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the ARM specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMSubtarget.h"
|
|
|
|
#include "ARMGenSubtarget.inc"
|
2009-08-29 07:18:09 +08:00
|
|
|
#include "llvm/GlobalValue.h"
|
2009-06-09 06:53:56 +08:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2009-06-23 05:01:46 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-11-10 08:48:55 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2007-01-19 15:51:42 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-23 05:01:46 +08:00
|
|
|
static cl::opt<bool>
|
|
|
|
ReserveR9("arm-reserve-r9", cl::Hidden,
|
|
|
|
cl::desc("Reserve R9, making it unavailable as GPR"));
|
2009-10-02 06:19:57 +08:00
|
|
|
static cl::opt<bool>
|
|
|
|
UseNEONFP("arm-use-neon-fp",
|
|
|
|
cl::desc("Use NEON for single-precision FP"),
|
|
|
|
cl::init(false), cl::Hidden);
|
2009-06-23 05:01:46 +08:00
|
|
|
|
2009-11-24 08:44:37 +08:00
|
|
|
static cl::opt<bool>
|
|
|
|
UseMOVT("arm-use-movt",
|
|
|
|
cl::init(true), cl::Hidden);
|
|
|
|
|
2009-08-03 06:11:08 +08:00
|
|
|
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
|
2009-10-16 14:11:08 +08:00
|
|
|
bool isT)
|
2010-03-07 03:39:36 +08:00
|
|
|
: ARMArchVersion(V4)
|
2009-05-24 03:51:43 +08:00
|
|
|
, ARMFPUType(None)
|
2009-10-02 06:19:57 +08:00
|
|
|
, UseNEONForSinglePrecisionFP(UseNEONFP)
|
2009-10-16 14:11:08 +08:00
|
|
|
, IsThumb(isT)
|
2009-06-02 04:00:48 +08:00
|
|
|
, ThumbMode(Thumb1)
|
2009-09-30 08:10:16 +08:00
|
|
|
, PostRAScheduler(false)
|
2009-06-23 05:01:46 +08:00
|
|
|
, IsR9Reserved(ReserveR9)
|
2009-11-24 08:44:37 +08:00
|
|
|
, UseMovt(UseMOVT)
|
2010-03-15 02:42:38 +08:00
|
|
|
, HasFP16(false)
|
2007-02-14 03:52:28 +08:00
|
|
|
, stackAlignment(4)
|
2009-05-24 03:50:50 +08:00
|
|
|
, CPUString("generic")
|
2007-02-14 03:52:28 +08:00
|
|
|
, TargetType(isELF) // Default to ELF unless otherwise specified.
|
|
|
|
, TargetABI(ARM_ABI_APCS) {
|
2009-06-09 06:53:56 +08:00
|
|
|
// default to soft float ABI
|
|
|
|
if (FloatABIType == FloatABI::Default)
|
|
|
|
FloatABIType = FloatABI::Soft;
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// Determine default and user specified characteristics
|
|
|
|
|
|
|
|
// Parse features string.
|
2009-05-24 03:50:50 +08:00
|
|
|
CPUString = ParseSubtargetFeatures(FS, CPUString);
|
2007-01-19 15:51:42 +08:00
|
|
|
|
2010-03-07 03:39:36 +08:00
|
|
|
// When no arch is specified either by CPU or by attributes, make the default
|
|
|
|
// ARMv4T.
|
|
|
|
if (CPUString == "generic" && (FS.empty() || FS == "generic"))
|
|
|
|
ARMArchVersion = V4T;
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// Set the boolean corresponding to the current target triple, or the default
|
|
|
|
// if one cannot be determined, to true.
|
2009-03-08 12:02:49 +08:00
|
|
|
unsigned Len = TT.length();
|
2009-03-10 04:25:39 +08:00
|
|
|
unsigned Idx = 0;
|
2009-05-30 07:41:08 +08:00
|
|
|
|
2009-03-10 04:25:39 +08:00
|
|
|
if (Len >= 5 && TT.substr(0, 4) == "armv")
|
|
|
|
Idx = 4;
|
2009-06-23 05:28:22 +08:00
|
|
|
else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
|
2009-06-02 04:00:48 +08:00
|
|
|
IsThumb = true;
|
2009-03-10 04:25:39 +08:00
|
|
|
if (Len >= 7 && TT[5] == 'v')
|
|
|
|
Idx = 6;
|
|
|
|
}
|
|
|
|
if (Idx) {
|
|
|
|
unsigned SubVer = TT[Idx];
|
2010-03-07 03:39:36 +08:00
|
|
|
if (SubVer >= '7' && SubVer <= '9') {
|
|
|
|
ARMArchVersion = V7A;
|
|
|
|
} else if (SubVer == '6') {
|
|
|
|
ARMArchVersion = V6;
|
|
|
|
if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
|
|
|
|
ARMArchVersion = V6T2;
|
|
|
|
} else if (SubVer == '5') {
|
|
|
|
ARMArchVersion = V5T;
|
|
|
|
if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
|
|
|
|
ARMArchVersion = V5TE;
|
|
|
|
} else if (SubVer == '4') {
|
|
|
|
if (Len >= Idx+2 && TT[Idx+1] == 't')
|
|
|
|
ARMArchVersion = V4T;
|
|
|
|
else
|
|
|
|
ARMArchVersion = V4;
|
2009-03-08 12:02:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 08:16:10 +08:00
|
|
|
// Thumb2 implies at least V6T2.
|
2010-03-07 03:39:36 +08:00
|
|
|
if (ARMArchVersion >= V6T2)
|
|
|
|
ThumbMode = Thumb2;
|
|
|
|
else if (ThumbMode >= Thumb2)
|
2009-08-01 08:16:10 +08:00
|
|
|
ARMArchVersion = V6T2;
|
|
|
|
|
2009-03-10 04:25:39 +08:00
|
|
|
if (Len >= 10) {
|
2007-01-20 03:22:40 +08:00
|
|
|
if (TT.find("-darwin") != std::string::npos)
|
2009-03-10 04:25:39 +08:00
|
|
|
// arm-darwin
|
2007-01-20 03:22:40 +08:00
|
|
|
TargetType = isDarwin;
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
|
|
|
|
2007-02-14 03:52:28 +08:00
|
|
|
if (TT.find("eabi") != std::string::npos)
|
|
|
|
TargetABI = ARM_ABI_AAPCS;
|
|
|
|
|
|
|
|
if (isAAPCS_ABI())
|
|
|
|
stackAlignment = 8;
|
|
|
|
|
2009-06-19 07:14:30 +08:00
|
|
|
if (isTargetDarwin())
|
2009-06-23 05:01:46 +08:00
|
|
|
IsR9Reserved = ReserveR9 | (ARMArchVersion < V6);
|
2009-10-02 05:46:35 +08:00
|
|
|
|
2009-10-16 14:11:08 +08:00
|
|
|
if (!isThumb() || hasThumb2())
|
|
|
|
PostRAScheduler = true;
|
|
|
|
|
2009-10-02 05:46:35 +08:00
|
|
|
// Set CPU specific features.
|
|
|
|
if (CPUString == "cortex-a8") {
|
2009-10-16 14:18:09 +08:00
|
|
|
// On Cortex-a8, it's faster to perform some single-precision FP
|
2009-10-16 13:33:58 +08:00
|
|
|
// operations with NEON instructions.
|
2009-10-02 06:19:57 +08:00
|
|
|
if (UseNEONFP.getPosition() == 0)
|
|
|
|
UseNEONForSinglePrecisionFP = true;
|
2009-10-02 05:46:35 +08:00
|
|
|
}
|
2007-01-19 15:51:42 +08:00
|
|
|
}
|
2009-08-29 07:18:09 +08:00
|
|
|
|
|
|
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
|
2009-09-03 15:04:02 +08:00
|
|
|
bool
|
|
|
|
ARMSubtarget::GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) const {
|
|
|
|
if (RelocM == Reloc::Static)
|
2009-08-29 07:18:09 +08:00
|
|
|
return false;
|
2009-09-03 15:04:02 +08:00
|
|
|
|
2010-01-28 04:34:15 +08:00
|
|
|
// Materializable GVs (in JIT lazy compilation mode) do not require an extra
|
|
|
|
// load from stub.
|
|
|
|
bool isDecl = GV->isDeclaration() && !GV->isMaterializable();
|
2009-09-03 15:04:02 +08:00
|
|
|
|
|
|
|
if (!isTargetDarwin()) {
|
|
|
|
// Extra load is needed for all externally visible.
|
|
|
|
if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (RelocM == Reloc::PIC_) {
|
|
|
|
// If this is a strong reference to a definition, it is definitely not
|
|
|
|
// through a stub.
|
|
|
|
if (!isDecl && !GV->isWeakForLinker())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Unless we have a symbol with hidden visibility, we have to go through a
|
|
|
|
// normal $non_lazy_ptr stub because this symbol might be resolved late.
|
|
|
|
if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// If symbol visibility is hidden, we have a stub for common symbol
|
|
|
|
// references and external declarations.
|
|
|
|
if (isDecl || GV->hasCommonLinkage())
|
|
|
|
// Hidden $non_lazy_ptr reference.
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// If this is a strong reference to a definition, it is definitely not
|
|
|
|
// through a stub.
|
|
|
|
if (!isDecl && !GV->isWeakForLinker())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Unless we have a symbol with hidden visibility, we have to go through a
|
|
|
|
// normal $non_lazy_ptr stub because this symbol might be resolved late.
|
|
|
|
if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2009-08-29 07:18:09 +08:00
|
|
|
}
|
2009-11-10 08:48:55 +08:00
|
|
|
|
|
|
|
bool ARMSubtarget::enablePostRAScheduler(
|
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
TargetSubtarget::AntiDepBreakMode& Mode,
|
2009-11-14 03:52:48 +08:00
|
|
|
RegClassVector& CriticalPathRCs) const {
|
2009-11-10 08:48:55 +08:00
|
|
|
Mode = TargetSubtarget::ANTIDEP_CRITICAL;
|
2009-11-14 03:52:48 +08:00
|
|
|
CriticalPathRCs.clear();
|
|
|
|
CriticalPathRCs.push_back(&ARM::GPRRegClass);
|
2009-11-10 08:48:55 +08:00
|
|
|
return PostRAScheduler && OptLevel >= CodeGenOpt::Default;
|
|
|
|
}
|