ARMSubtarget.cpp revision d4022c3fbb0705abdc8eddc3ee4a5059f5ef8094
1//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// 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" 17using namespace llvm; 18 19ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, 20 bool isThumb) 21 : ARMArchVersion(V4T) 22 , ARMFPUType(None) 23 , ThumbMode((isThumb ? Thumb1 : ThumbNone)) 24 , UseThumbBacktraces(false) 25 , IsR9Reserved(false) 26 , stackAlignment(4) 27 , CPUString("generic") 28 , TargetType(isELF) // Default to ELF unless otherwise specified. 29 , TargetABI(ARM_ABI_APCS) { 30 // Determine default and user specified characteristics 31 32 // Parse features string. 33 CPUString = ParseSubtargetFeatures(FS, CPUString); 34 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 unsigned Len = TT.length(); 39 unsigned Idx = 0; 40 41 if (Len >= 5 && TT.substr(0, 4) == "armv") 42 Idx = 4; 43 else if (Len >= 6 && TT.substr(0, 6) == "thumb") { 44 isThumb = true; 45 if (Len >= 7 && TT[5] == 'v') 46 Idx = 6; 47 } 48 if (Idx) { 49 unsigned SubVer = TT[Idx]; 50 if (SubVer > '4' && SubVer <= '9') { 51 if (SubVer >= '7') { 52 ARMArchVersion = V7A; 53 if (isThumb) 54 ThumbMode = Thumb2; 55 } else if (SubVer == '6') { 56 ARMArchVersion = V6; 57 if (isThumb && Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') 58 ThumbMode = Thumb2; 59 } else if (SubVer == '5') { 60 ARMArchVersion = V5T; 61 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') 62 ARMArchVersion = V5TE; 63 } 64 } 65 } 66 67 if (Len >= 10) { 68 if (TT.find("-darwin") != std::string::npos) 69 // arm-darwin 70 TargetType = isDarwin; 71 } else if (TT.empty()) { 72#if defined(__APPLE__) 73 TargetType = isDarwin; 74#endif 75 } 76 77 if (TT.find("eabi") != std::string::npos) 78 TargetABI = ARM_ABI_AAPCS; 79 80 if (isAAPCS_ABI()) 81 stackAlignment = 8; 82 83 if (isTargetDarwin()) { 84 UseThumbBacktraces = true; 85 IsR9Reserved = true; 86 } 87} 88