SystemZSubtarget.cpp revision 263508
1344063Smm//===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===// 2344063Smm// 3344063Smm// The LLVM Compiler Infrastructure 4344063Smm// 5344063Smm// This file is distributed under the University of Illinois Open Source 6344063Smm// License. See LICENSE.TXT for details. 7358090Smm// 8358090Smm//===----------------------------------------------------------------------===// 9344063Smm 10344063Smm#include "SystemZSubtarget.h" 11344063Smm#include "llvm/IR/GlobalValue.h" 12344063Smm#include "llvm/Support/Host.h" 13344063Smm#include "MCTargetDesc/SystemZMCTargetDesc.h" 14344063Smm 15344063Smm#define GET_SUBTARGETINFO_TARGET_DESC 16344063Smm#define GET_SUBTARGETINFO_CTOR 17344063Smm#include "SystemZGenSubtargetInfo.inc" 18344063Smm 19344063Smmusing namespace llvm; 20344063Smm 21344063Smm// Pin the vtabel to this file. 22344063Smmvoid SystemZSubtarget::anchor() {} 23344063Smm 24344063SmmSystemZSubtarget::SystemZSubtarget(const std::string &TT, 25344063Smm const std::string &CPU, 26344063Smm const std::string &FS) 27344063Smm : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false), 28344063Smm HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false), 29344063Smm TargetTriple(TT) { 30344063Smm std::string CPUName = CPU; 31344063Smm if (CPUName.empty()) 32344063Smm CPUName = "generic"; 33344063Smm#if defined(__linux__) && defined(__s390x__) 34344063Smm if (CPUName == "generic") 35344063Smm CPUName = sys::getHostCPUName(); 36344063Smm#endif 37344063Smm 38344063Smm // Parse features string. 39344063Smm ParseSubtargetFeatures(CPUName, FS); 40344063Smm} 41344063Smm 42344063Smm// Return true if GV binds locally under reloc model RM. 43344063Smmstatic bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) { 44344063Smm // For non-PIC, all symbols bind locally. 45344063Smm if (RM == Reloc::Static) 46344063Smm return true; 47344063Smm 48344063Smm return GV->hasLocalLinkage() || !GV->hasDefaultVisibility(); 49344063Smm} 50344063Smm 51344063Smmbool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, 52344063Smm Reloc::Model RM, 53344063Smm CodeModel::Model CM) const { 54344063Smm // PC32DBL accesses require the low bit to be clear. Note that a zero 55344063Smm // value selects the default alignment and is therefore OK. 56344063Smm if (GV->getAlignment() == 1) 57344063Smm return false; 58344063Smm 59344063Smm // For the small model, all locally-binding symbols are in range. 60344063Smm if (CM == CodeModel::Small) 61344063Smm return bindsLocally(GV, RM); 62344063Smm 63344063Smm // For Medium and above, assume that the symbol is not within the 4GB range. 64344063Smm // Taking the address of locally-defined text would be OK, but that 65344063Smm // case isn't easy to detect. 66344063Smm return false; 67344063Smm} 68344063Smm