2007-01-19 07:51:42 +00:00
|
|
|
//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 07:51:42 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the ARM specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMSubtarget.h"
|
|
|
|
#include "ARMGenSubtarget.inc"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-05-29 23:41:08 +00:00
|
|
|
ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS,
|
|
|
|
bool isThumb)
|
2007-01-19 19:22:40 +00:00
|
|
|
: ARMArchVersion(V4T)
|
2009-05-23 19:51:43 +00:00
|
|
|
, ARMFPUType(None)
|
2009-05-29 23:41:08 +00:00
|
|
|
, ThumbMode((isThumb ? Thumb1 : ThumbNone))
|
2007-01-19 19:22:40 +00:00
|
|
|
, UseThumbBacktraces(false)
|
|
|
|
, IsR9Reserved(false)
|
2007-02-13 19:52:28 +00:00
|
|
|
, stackAlignment(4)
|
2009-05-23 19:50:50 +00:00
|
|
|
, CPUString("generic")
|
2007-02-13 19:52:28 +00:00
|
|
|
, TargetType(isELF) // Default to ELF unless otherwise specified.
|
|
|
|
, TargetABI(ARM_ABI_APCS) {
|
2007-01-19 07:51:42 +00:00
|
|
|
// Determine default and user specified characteristics
|
|
|
|
|
|
|
|
// Parse features string.
|
2009-05-23 19:50:50 +00:00
|
|
|
CPUString = ParseSubtargetFeatures(FS, CPUString);
|
2007-01-19 07:51:42 +00:00
|
|
|
|
|
|
|
// Set the boolean corresponding to the current target triple, or the default
|
|
|
|
// if one cannot be determined, to true.
|
|
|
|
const std::string& TT = M.getTargetTriple();
|
2009-03-08 04:02:49 +00:00
|
|
|
unsigned Len = TT.length();
|
2009-03-09 20:25:39 +00:00
|
|
|
unsigned Idx = 0;
|
2009-05-29 23:41:08 +00:00
|
|
|
|
2009-03-09 20:25:39 +00:00
|
|
|
if (Len >= 5 && TT.substr(0, 4) == "armv")
|
|
|
|
Idx = 4;
|
|
|
|
else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
|
2009-05-29 23:41:08 +00:00
|
|
|
isThumb = true;
|
2009-03-09 20:25:39 +00:00
|
|
|
if (Len >= 7 && TT[5] == 'v')
|
|
|
|
Idx = 6;
|
|
|
|
}
|
|
|
|
if (Idx) {
|
|
|
|
unsigned SubVer = TT[Idx];
|
|
|
|
if (SubVer > '4' && SubVer <= '9') {
|
2009-05-29 23:41:08 +00:00
|
|
|
if (SubVer >= '7') {
|
|
|
|
ARMArchVersion = V7A;
|
|
|
|
if (isThumb)
|
|
|
|
ThumbMode = Thumb2;
|
|
|
|
} else if (SubVer == '6') {
|
2009-03-09 20:25:39 +00:00
|
|
|
ARMArchVersion = V6;
|
2009-05-29 23:41:08 +00:00
|
|
|
if (isThumb && Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
|
|
|
|
ThumbMode = Thumb2;
|
|
|
|
} else if (SubVer == '5') {
|
2009-03-09 20:25:39 +00:00
|
|
|
ARMArchVersion = V5T;
|
|
|
|
if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
|
|
|
|
ARMArchVersion = V5TE;
|
2009-03-08 04:02:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-09 20:25:39 +00:00
|
|
|
if (Len >= 10) {
|
2007-01-19 19:22:40 +00:00
|
|
|
if (TT.find("-darwin") != std::string::npos)
|
2009-03-09 20:25:39 +00:00
|
|
|
// arm-darwin
|
2007-01-19 19:22:40 +00:00
|
|
|
TargetType = isDarwin;
|
2007-01-19 07:51:42 +00:00
|
|
|
} else if (TT.empty()) {
|
|
|
|
#if defined(__APPLE__)
|
2007-01-19 19:22:40 +00:00
|
|
|
TargetType = isDarwin;
|
2007-01-19 07:51:42 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-02-13 19:52:28 +00:00
|
|
|
if (TT.find("eabi") != std::string::npos)
|
|
|
|
TargetABI = ARM_ABI_AAPCS;
|
|
|
|
|
|
|
|
if (isAAPCS_ABI())
|
|
|
|
stackAlignment = 8;
|
|
|
|
|
2007-01-19 19:22:40 +00:00
|
|
|
if (isTargetDarwin()) {
|
2007-01-19 07:51:42 +00:00
|
|
|
UseThumbBacktraces = true;
|
|
|
|
IsR9Reserved = true;
|
2007-02-13 19:52:28 +00:00
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|