1 //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===// 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 #include "SystemZSubtarget.h" 11 #include "llvm/IR/GlobalValue.h" 12 #include "MCTargetDesc/SystemZMCTargetDesc.h" 13 14 #define GET_SUBTARGETINFO_TARGET_DESC 15 #define GET_SUBTARGETINFO_CTOR 16 #include "SystemZGenSubtargetInfo.inc" 17 18 using namespace llvm; 19 20 SystemZSubtarget::SystemZSubtarget(const std::string &TT, 21 const std::string &CPU, 22 const std::string &FS) 23 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false), 24 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false), 25 TargetTriple(TT) { 26 std::string CPUName = CPU; 27 if (CPUName.empty()) 28 CPUName = "z10"; 29 30 // Parse features string. 31 ParseSubtargetFeatures(CPUName, FS); 32 } 33 34 // Return true if GV binds locally under reloc model RM. 35 static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) { 36 // For non-PIC, all symbols bind locally. 37 if (RM == Reloc::Static) 38 return true; 39 40 return GV->hasLocalLinkage() || !GV->hasDefaultVisibility(); 41 } 42 43 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, 44 Reloc::Model RM, 45 CodeModel::Model CM) const { 46 // PC32DBL accesses require the low bit to be clear. Note that a zero 47 // value selects the default alignment and is therefore OK. 48 if (GV->getAlignment() == 1) 49 return false; 50 51 // For the small model, all locally-binding symbols are in range. 52 if (CM == CodeModel::Small) 53 return bindsLocally(GV, RM); 54 55 // For Medium and above, assume that the symbol is not within the 4GB range. 56 // Taking the address of locally-defined text would be OK, but that 57 // case isn't easy to detect. 58 return false; 59 } 60