SystemZSubtarget.cpp revision 251607
1207753Smm//===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===// 2207753Smm// 3207753Smm// The LLVM Compiler Infrastructure 4207753Smm// 5207753Smm// This file is distributed under the University of Illinois Open Source 6207753Smm// License. See LICENSE.TXT for details. 7207753Smm// 8207753Smm//===----------------------------------------------------------------------===// 9207753Smm 10207753Smm#include "SystemZSubtarget.h" 11207753Smm#include "llvm/IR/GlobalValue.h" 12207753Smm 13207753Smm#define GET_SUBTARGETINFO_TARGET_DESC 14207753Smm#define GET_SUBTARGETINFO_CTOR 15207753Smm#include "SystemZGenSubtargetInfo.inc" 16207753Smm 17207753Smmusing namespace llvm; 18207753Smm 19207753SmmSystemZSubtarget::SystemZSubtarget(const std::string &TT, 20207753Smm const std::string &CPU, 21207753Smm const std::string &FS) 22207753Smm : SystemZGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT) { 23207753Smm std::string CPUName = CPU; 24207753Smm if (CPUName.empty()) 25207753Smm CPUName = "z10"; 26207753Smm 27207753Smm // Parse features string. 28207753Smm ParseSubtargetFeatures(CPUName, FS); 29207753Smm} 30207753Smm 31207753Smm// Return true if GV binds locally under reloc model RM. 32207753Smmstatic bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) { 33207753Smm // For non-PIC, all symbols bind locally. 34207753Smm if (RM == Reloc::Static) 35207753Smm return true; 36207753Smm 37207753Smm return GV->hasLocalLinkage() || !GV->hasDefaultVisibility(); 38207753Smm} 39207753Smm 40207753Smmbool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, 41207753Smm Reloc::Model RM, 42207753Smm CodeModel::Model CM) const { 43207753Smm // PC32DBL accesses require the low bit to be clear. Note that a zero 44207753Smm // value selects the default alignment and is therefore OK. 45207753Smm if (GV->getAlignment() == 1) 46207753Smm return false; 47207753Smm 48207753Smm // For the small model, all locally-binding symbols are in range. 49207753Smm if (CM == CodeModel::Small) 50207753Smm return bindsLocally(GV, RM); 51207753Smm 52207753Smm // For Medium and above, assume that the symbol is not within the 4GB range. 53207753Smm // Taking the address of locally-defined text would be OK, but that 54207753Smm // case isn't easy to detect. 55207753Smm return false; 56207753Smm} 57207753Smm