LLVM API Documentation
00001 //===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the ARM specific subclass of TargetSubtarget. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "ARMSubtarget.h" 00015 #include "ARMGenSubtarget.inc" 00016 #include "llvm/GlobalValue.h" 00017 #include "llvm/Target/TargetOptions.h" 00018 #include "llvm/Support/CommandLine.h" 00019 using namespace llvm; 00020 00021 static cl::opt<bool> 00022 ReserveR9("arm-reserve-r9", cl::Hidden, 00023 cl::desc("Reserve R9, making it unavailable as GPR")); 00024 00025 ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS, 00026 bool isThumb) 00027 : ARMArchVersion(V4T) 00028 , ARMFPUType(None) 00029 , UseNEONForSinglePrecisionFP(false) 00030 , IsThumb(isThumb) 00031 , ThumbMode(Thumb1) 00032 , IsR9Reserved(ReserveR9) 00033 , stackAlignment(4) 00034 , CPUString("generic") 00035 , TargetType(isELF) // Default to ELF unless otherwise specified. 00036 , TargetABI(ARM_ABI_APCS) { 00037 // default to soft float ABI 00038 if (FloatABIType == FloatABI::Default) 00039 FloatABIType = FloatABI::Soft; 00040 00041 // Determine default and user specified characteristics 00042 00043 // Parse features string. 00044 CPUString = ParseSubtargetFeatures(FS, CPUString); 00045 00046 // Set the boolean corresponding to the current target triple, or the default 00047 // if one cannot be determined, to true. 00048 unsigned Len = TT.length(); 00049 unsigned Idx = 0; 00050 00051 if (Len >= 5 && TT.substr(0, 4) == "armv") 00052 Idx = 4; 00053 else if (Len >= 6 && TT.substr(0, 5) == "thumb") { 00054 IsThumb = true; 00055 if (Len >= 7 && TT[5] == 'v') 00056 Idx = 6; 00057 } 00058 if (Idx) { 00059 unsigned SubVer = TT[Idx]; 00060 if (SubVer > '4' && SubVer <= '9') { 00061 if (SubVer >= '7') { 00062 ARMArchVersion = V7A; 00063 } else if (SubVer == '6') { 00064 ARMArchVersion = V6; 00065 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') 00066 ARMArchVersion = V6T2; 00067 } else if (SubVer == '5') { 00068 ARMArchVersion = V5T; 00069 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') 00070 ARMArchVersion = V5TE; 00071 } 00072 if (ARMArchVersion >= V6T2) 00073 ThumbMode = Thumb2; 00074 } 00075 } 00076 00077 // Thumb2 implies at least V6T2. 00078 if (ARMArchVersion < V6T2 && ThumbMode >= Thumb2) 00079 ARMArchVersion = V6T2; 00080 00081 if (Len >= 10) { 00082 if (TT.find("-darwin") != std::string::npos) 00083 // arm-darwin 00084 TargetType = isDarwin; 00085 } 00086 00087 if (TT.find("eabi") != std::string::npos) 00088 TargetABI = ARM_ABI_AAPCS; 00089 00090 if (isAAPCS_ABI()) 00091 stackAlignment = 8; 00092 00093 if (isTargetDarwin()) 00094 IsR9Reserved = ReserveR9 | (ARMArchVersion < V6); 00095 } 00096 00097 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol. 00098 bool ARMSubtarget::GVIsIndirectSymbol(GlobalValue *GV, bool isStatic) const { 00099 // If symbol visibility is hidden, the extra load is not needed if 00100 // the symbol is definitely defined in the current translation unit. 00101 bool isDecl = GV->isDeclaration() || GV->hasAvailableExternallyLinkage(); 00102 if (GV->hasHiddenVisibility() && (!isDecl && !GV->hasCommonLinkage())) 00103 return false; 00104 return !isStatic && (isDecl || GV->isWeakForLinker()); 00105 }