blob: a011157dcdfc3ed81f924f9e3d143415ca08cfd6 [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"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000011#include "MCTargetDesc/SystemZMCTargetDesc.h"
Ulrich Weigand5f613df2013-05-06 16:15:19 +000012#include "llvm/IR/GlobalValue.h"
Richard Sandifordf834ea12013-10-31 12:14:17 +000013#include "llvm/Support/Host.h"
Ulrich Weigand5f613df2013-05-06 16:15:19 +000014
Chandler Carruthd174b722014-04-22 02:03:14 +000015using namespace llvm;
16
Chandler Carruthe96dd892014-04-21 22:55:11 +000017#define DEBUG_TYPE "systemz-subtarget"
18
Ulrich Weigand5f613df2013-05-06 16:15:19 +000019#define GET_SUBTARGETINFO_TARGET_DESC
20#define GET_SUBTARGETINFO_CTOR
21#include "SystemZGenSubtargetInfo.inc"
22
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000023// Pin the vtabel to this file.
24void SystemZSubtarget::anchor() {}
25
Ulrich Weigand5f613df2013-05-06 16:15:19 +000026SystemZSubtarget::SystemZSubtarget(const std::string &TT,
27 const std::string &CPU,
28 const std::string &FS)
Richard Sandiford27d1cfe2013-07-19 16:09:03 +000029 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
Richard Sandiford8e92c382013-08-21 08:58:08 +000030 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
Richard Sandiford45645a22013-12-24 15:14:05 +000031 HasFastSerialization(false), HasInterlockedAccess1(false),
32 TargetTriple(TT) {
Ulrich Weigand5f613df2013-05-06 16:15:19 +000033 std::string CPUName = CPU;
34 if (CPUName.empty())
Richard Sandifordf834ea12013-10-31 12:14:17 +000035 CPUName = "generic";
36#if defined(__linux__) && defined(__s390x__)
37 if (CPUName == "generic")
38 CPUName = sys::getHostCPUName();
39#endif
Ulrich Weigand5f613df2013-05-06 16:15:19 +000040
41 // Parse features string.
42 ParseSubtargetFeatures(CPUName, FS);
43}
44
45// Return true if GV binds locally under reloc model RM.
46static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
47 // For non-PIC, all symbols bind locally.
48 if (RM == Reloc::Static)
49 return true;
50
51 return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
52}
53
54bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
55 Reloc::Model RM,
56 CodeModel::Model CM) const {
57 // PC32DBL accesses require the low bit to be clear. Note that a zero
58 // value selects the default alignment and is therefore OK.
59 if (GV->getAlignment() == 1)
60 return false;
61
62 // For the small model, all locally-binding symbols are in range.
63 if (CM == CodeModel::Small)
64 return bindsLocally(GV, RM);
65
66 // For Medium and above, assume that the symbol is not within the 4GB range.
67 // Taking the address of locally-defined text would be OK, but that
68 // case isn't easy to detect.
69 return false;
70}