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