Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1 | //===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Evan Cheng and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 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" |
| 17 | #include "llvm/Support/CommandLine.h" |
| 18 | using namespace llvm; |
| 19 | |
| 20 | // FIXME: this is temporary. |
| 21 | static cl::opt<bool> Thumb("enable-thumb", |
| 22 | cl::desc("Switch to thumb mode in ARM backend")); |
| 23 | |
| 24 | ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS) |
Evan Cheng | 181fe36 | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 25 | : ARMArchVersion(V4T) |
| 26 | , HasVFP2(false) |
| 27 | , UseThumbBacktraces(false) |
| 28 | , IsR9Reserved(false) |
Lauro Ramos Venancio | 048e16ff | 2007-02-13 19:52:28 +0000 | [diff] [blame^] | 29 | , stackAlignment(4) |
| 30 | , TargetType(isELF) // Default to ELF unless otherwise specified. |
| 31 | , TargetABI(ARM_ABI_APCS) { |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 32 | |
| 33 | // Determine default and user specified characteristics |
| 34 | std::string CPU = "generic"; |
| 35 | |
| 36 | // Parse features string. |
| 37 | ParseSubtargetFeatures(FS, CPU); |
| 38 | |
| 39 | IsThumb = Thumb; |
| 40 | |
| 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(); |
| 44 | if (TT.length() > 5) { |
Evan Cheng | 181fe36 | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 45 | if (TT.find("-darwin") != std::string::npos) |
| 46 | TargetType = isDarwin; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 47 | } else if (TT.empty()) { |
| 48 | #if defined(__APPLE__) |
Evan Cheng | 181fe36 | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 49 | TargetType = isDarwin; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 50 | #endif |
| 51 | } |
| 52 | |
Lauro Ramos Venancio | 048e16ff | 2007-02-13 19:52:28 +0000 | [diff] [blame^] | 53 | if (TT.find("eabi") != std::string::npos) |
| 54 | TargetABI = ARM_ABI_AAPCS; |
| 55 | |
| 56 | if (isAAPCS_ABI()) |
| 57 | stackAlignment = 8; |
| 58 | |
Evan Cheng | 181fe36 | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 59 | if (isTargetDarwin()) { |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 60 | UseThumbBacktraces = true; |
| 61 | IsR9Reserved = true; |
Lauro Ramos Venancio | 048e16ff | 2007-02-13 19:52:28 +0000 | [diff] [blame^] | 62 | } |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 63 | } |