blob: 474192099f22fc6120e2d8d3b9ef36d9643a8b10 [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"
Richard Sandifordf834ea12013-10-31 12:14:17 +000012#include "llvm/Support/Host.h"
Richard Sandiford27d1cfe2013-07-19 16:09:03 +000013#include "MCTargetDesc/SystemZMCTargetDesc.h"
Ulrich Weigand5f613df2013-05-06 16:15:19 +000014
15#define GET_SUBTARGETINFO_TARGET_DESC
16#define GET_SUBTARGETINFO_CTOR
17#include "SystemZGenSubtargetInfo.inc"
18
19using namespace llvm;
20
21SystemZSubtarget::SystemZSubtarget(const std::string &TT,
22 const std::string &CPU,
23 const std::string &FS)
Richard Sandiford27d1cfe2013-07-19 16:09:03 +000024 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
Richard Sandiford8e92c382013-08-21 08:58:08 +000025 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
26 TargetTriple(TT) {
Ulrich Weigand5f613df2013-05-06 16:15:19 +000027 std::string CPUName = CPU;
28 if (CPUName.empty())
Richard Sandifordf834ea12013-10-31 12:14:17 +000029 CPUName = "generic";
30#if defined(__linux__) && defined(__s390x__)
31 if (CPUName == "generic")
32 CPUName = sys::getHostCPUName();
33#endif
Ulrich Weigand5f613df2013-05-06 16:15:19 +000034
35 // Parse features string.
36 ParseSubtargetFeatures(CPUName, FS);
37}
38
39// Return true if GV binds locally under reloc model RM.
40static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
41 // For non-PIC, all symbols bind locally.
42 if (RM == Reloc::Static)
43 return true;
44
45 return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
46}
47
48bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
49 Reloc::Model RM,
50 CodeModel::Model CM) const {
51 // PC32DBL accesses require the low bit to be clear. Note that a zero
52 // value selects the default alignment and is therefore OK.
53 if (GV->getAlignment() == 1)
54 return false;
55
56 // For the small model, all locally-binding symbols are in range.
57 if (CM == CodeModel::Small)
58 return bindsLocally(GV, RM);
59
60 // For Medium and above, assume that the symbol is not within the 4GB range.
61 // Taking the address of locally-defined text would be OK, but that
62 // case isn't easy to detect.
63 return false;
64}