1 //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "SystemZSubtarget.h"
11 #include "MCTargetDesc/SystemZMCTargetDesc.h"
12 #include "llvm/IR/GlobalValue.h"
13 #include "llvm/Support/Host.h"
17 #define DEBUG_TYPE "systemz-subtarget"
19 #define GET_SUBTARGETINFO_TARGET_DESC
20 #define GET_SUBTARGETINFO_CTOR
21 #include "SystemZGenSubtargetInfo.inc"
23 // Pin the vtable to this file.
24 void SystemZSubtarget::anchor() {}
27 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
28 std::string CPUName = CPU;
31 #if defined(__linux__) && defined(__s390x__)
32 if (CPUName == "generic")
33 CPUName = sys::getHostCPUName();
35 // Parse features string.
36 ParseSubtargetFeatures(CPUName, FS);
40 SystemZSubtarget::SystemZSubtarget(const std::string &TT,
41 const std::string &CPU,
42 const std::string &FS,
43 const TargetMachine &TM)
44 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
45 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
46 HasFastSerialization(false), HasInterlockedAccess1(false),
47 TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
48 TLInfo(TM, *this), TSInfo(*TM.getDataLayout()), FrameLowering() {}
50 // Return true if GV binds locally under reloc model RM.
51 static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
52 // For non-PIC, all symbols bind locally.
53 if (RM == Reloc::Static)
56 return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
59 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
61 CodeModel::Model CM) const {
62 // PC32DBL accesses require the low bit to be clear. Note that a zero
63 // value selects the default alignment and is therefore OK.
64 if (GV->getAlignment() == 1)
67 // For the small model, all locally-binding symbols are in range.
68 if (CM == CodeModel::Small)
69 return bindsLocally(GV, RM);
71 // For Medium and above, assume that the symbol is not within the 4GB range.
72 // Taking the address of locally-defined text would be OK, but that
73 // case isn't easy to detect.