blob: cfd3324aadb77b016471a0626da4f7f8c3c807dc [file] [log] [blame]
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001//===-- 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 "llvm/IR/GlobalValue.h"
12
13#define GET_SUBTARGETINFO_TARGET_DESC
14#define GET_SUBTARGETINFO_CTOR
15#include "SystemZGenSubtargetInfo.inc"
16
17using namespace llvm;
18
19SystemZSubtarget::SystemZSubtarget(const std::string &TT,
20 const std::string &CPU,
21 const std::string &FS)
22 : SystemZGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT) {
23 std::string CPUName = CPU;
24 if (CPUName.empty())
25 CPUName = "z10";
26
27 // Parse features string.
28 ParseSubtargetFeatures(CPUName, FS);
29}
30
31// Return true if GV binds locally under reloc model RM.
32static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
33 // For non-PIC, all symbols bind locally.
34 if (RM == Reloc::Static)
35 return true;
36
37 return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
38}
39
40bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
41 Reloc::Model RM,
42 CodeModel::Model CM) const {
43 // PC32DBL accesses require the low bit to be clear. Note that a zero
44 // value selects the default alignment and is therefore OK.
45 if (GV->getAlignment() == 1)
46 return false;
47
48 // For the small model, all locally-binding symbols are in range.
49 if (CM == CodeModel::Small)
50 return bindsLocally(GV, RM);
51
52 // For Medium and above, assume that the symbol is not within the 4GB range.
53 // Taking the address of locally-defined text would be OK, but that
54 // case isn't easy to detect.
55 return false;
56}