blob: 7ac7b4923d686c4a1c6128df169714a6f9721899 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the ARM specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#include "ARMSubtarget.h"
15#include "ARMGenSubtarget.inc"
16#include "llvm/Module.h"
Anton Korobeynikov11713322009-06-08 22:53:56 +000017#include "llvm/Target/TargetMachine.h"
18#include "llvm/Target/TargetOptions.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
20
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000021ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS,
22 bool isThumb)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023 : ARMArchVersion(V4T)
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000024 , ARMFPUType(None)
Anton Korobeynikove7540d62009-06-01 20:00:48 +000025 , IsThumb(isThumb)
26 , ThumbMode(Thumb1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 , IsR9Reserved(false)
28 , stackAlignment(4)
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000029 , CPUString("generic")
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030 , TargetType(isELF) // Default to ELF unless otherwise specified.
31 , TargetABI(ARM_ABI_APCS) {
Anton Korobeynikov11713322009-06-08 22:53:56 +000032 // default to soft float ABI
33 if (FloatABIType == FloatABI::Default)
34 FloatABIType = FloatABI::Soft;
35
Dan Gohmanf17a25c2007-07-18 16:29:46 +000036 // Determine default and user specified characteristics
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037
38 // Parse features string.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000039 CPUString = ParseSubtargetFeatures(FS, CPUString);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
41 // Set the boolean corresponding to the current target triple, or the default
42 // if one cannot be determined, to true.
43 const std::string& TT = M.getTargetTriple();
Evan Chengac1f7792009-03-08 04:02:49 +000044 unsigned Len = TT.length();
Evan Chenga5de2fc2009-03-09 20:25:39 +000045 unsigned Idx = 0;
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000046
Evan Chenga5de2fc2009-03-09 20:25:39 +000047 if (Len >= 5 && TT.substr(0, 4) == "armv")
48 Idx = 4;
49 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
Anton Korobeynikove7540d62009-06-01 20:00:48 +000050 IsThumb = true;
Evan Chenga5de2fc2009-03-09 20:25:39 +000051 if (Len >= 7 && TT[5] == 'v')
52 Idx = 6;
53 }
54 if (Idx) {
55 unsigned SubVer = TT[Idx];
56 if (SubVer > '4' && SubVer <= '9') {
Anton Korobeynikove7540d62009-06-01 20:00:48 +000057 if (SubVer >= '7')
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000058 ARMArchVersion = V7A;
Anton Korobeynikove7540d62009-06-01 20:00:48 +000059 else if (SubVer == '6')
Evan Chenga5de2fc2009-03-09 20:25:39 +000060 ARMArchVersion = V6;
Anton Korobeynikove7540d62009-06-01 20:00:48 +000061 else if (SubVer == '5') {
Evan Chenga5de2fc2009-03-09 20:25:39 +000062 ARMArchVersion = V5T;
63 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
64 ARMArchVersion = V5TE;
Evan Chengac1f7792009-03-08 04:02:49 +000065 }
66 }
67 }
68
Evan Chenga5de2fc2009-03-09 20:25:39 +000069 if (Len >= 10) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070 if (TT.find("-darwin") != std::string::npos)
Evan Chenga5de2fc2009-03-09 20:25:39 +000071 // arm-darwin
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072 TargetType = isDarwin;
73 } else if (TT.empty()) {
74#if defined(__APPLE__)
75 TargetType = isDarwin;
76#endif
77 }
78
79 if (TT.find("eabi") != std::string::npos)
80 TargetABI = ARM_ABI_AAPCS;
81
82 if (isAAPCS_ABI())
83 stackAlignment = 8;
84
Evan Cheng9ecae172009-06-18 23:14:30 +000085 if (isTargetDarwin())
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086 IsR9Reserved = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087}