Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1 | //===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 7 | // |
| 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" |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 17 | using namespace llvm; |
| 18 | |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 19 | ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb) |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 20 | : ARMArchVersion(V4T) |
| 21 | , HasVFP2(false) |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 22 | , IsThumb(thumb) |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 23 | , UseThumbBacktraces(false) |
| 24 | , IsR9Reserved(false) |
Lauro Ramos Venancio | 3630e78 | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 25 | , stackAlignment(4) |
| 26 | , TargetType(isELF) // Default to ELF unless otherwise specified. |
| 27 | , TargetABI(ARM_ABI_APCS) { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 28 | |
| 29 | // Determine default and user specified characteristics |
| 30 | std::string CPU = "generic"; |
| 31 | |
| 32 | // Parse features string. |
| 33 | ParseSubtargetFeatures(FS, CPU); |
| 34 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 35 | // Set the boolean corresponding to the current target triple, or the default |
| 36 | // if one cannot be determined, to true. |
| 37 | const std::string& TT = M.getTargetTriple(); |
| 38 | if (TT.length() > 5) { |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 39 | if (TT.find("-darwin") != std::string::npos) |
| 40 | TargetType = isDarwin; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 41 | } else if (TT.empty()) { |
| 42 | #if defined(__APPLE__) |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 43 | TargetType = isDarwin; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 44 | #endif |
| 45 | } |
| 46 | |
Lauro Ramos Venancio | 3630e78 | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 47 | if (TT.find("eabi") != std::string::npos) |
| 48 | TargetABI = ARM_ABI_AAPCS; |
| 49 | |
| 50 | if (isAAPCS_ABI()) |
| 51 | stackAlignment = 8; |
| 52 | |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 53 | if (isTargetDarwin()) { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 54 | UseThumbBacktraces = true; |
| 55 | IsR9Reserved = true; |
Lauro Ramos Venancio | 3630e78 | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 56 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 57 | } |