LLVM API Documentation
00001 //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===// 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 #include "SystemZSubtarget.h" 00011 #include "MCTargetDesc/SystemZMCTargetDesc.h" 00012 #include "llvm/IR/GlobalValue.h" 00013 #include "llvm/Support/Host.h" 00014 00015 using namespace llvm; 00016 00017 #define DEBUG_TYPE "systemz-subtarget" 00018 00019 #define GET_SUBTARGETINFO_TARGET_DESC 00020 #define GET_SUBTARGETINFO_CTOR 00021 #include "SystemZGenSubtargetInfo.inc" 00022 00023 // Pin the vtable to this file. 00024 void SystemZSubtarget::anchor() {} 00025 00026 SystemZSubtarget & 00027 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { 00028 std::string CPUName = CPU; 00029 if (CPUName.empty()) 00030 CPUName = "generic"; 00031 #if defined(__linux__) && defined(__s390x__) 00032 if (CPUName == "generic") 00033 CPUName = sys::getHostCPUName(); 00034 #endif 00035 // Parse features string. 00036 ParseSubtargetFeatures(CPUName, FS); 00037 return *this; 00038 } 00039 00040 SystemZSubtarget::SystemZSubtarget(const std::string &TT, 00041 const std::string &CPU, 00042 const std::string &FS, 00043 const TargetMachine &TM) 00044 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false), 00045 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false), 00046 HasFastSerialization(false), HasInterlockedAccess1(false), 00047 TargetTriple(TT), 00048 // Make sure that global data has at least 16 bits of alignment by 00049 // default, so that we can refer to it using LARL. We don't have any 00050 // special requirements for stack variables though. 00051 DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"), 00052 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM), 00053 TSInfo(DL), FrameLowering() {} 00054 00055 // Return true if GV binds locally under reloc model RM. 00056 static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) { 00057 // For non-PIC, all symbols bind locally. 00058 if (RM == Reloc::Static) 00059 return true; 00060 00061 return GV->hasLocalLinkage() || !GV->hasDefaultVisibility(); 00062 } 00063 00064 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, 00065 Reloc::Model RM, 00066 CodeModel::Model CM) const { 00067 // PC32DBL accesses require the low bit to be clear. Note that a zero 00068 // value selects the default alignment and is therefore OK. 00069 if (GV->getAlignment() == 1) 00070 return false; 00071 00072 // For the small model, all locally-binding symbols are in range. 00073 if (CM == CodeModel::Small) 00074 return bindsLocally(GV, RM); 00075 00076 // For Medium and above, assume that the symbol is not within the 4GB range. 00077 // Taking the address of locally-defined text would be OK, but that 00078 // case isn't easy to detect. 00079 return false; 00080 }