Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 1 | //===-- 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 Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 11 | #include "MCTargetDesc/SystemZMCTargetDesc.h" |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 12 | #include "llvm/IR/GlobalValue.h" |
Richard Sandiford | f834ea1 | 2013-10-31 12:14:17 +0000 | [diff] [blame] | 13 | #include "llvm/Support/Host.h" |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 14 | |
Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 15 | using namespace llvm; |
| 16 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 17 | #define DEBUG_TYPE "systemz-subtarget" |
| 18 | |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 19 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 20 | #define GET_SUBTARGETINFO_CTOR |
| 21 | #include "SystemZGenSubtargetInfo.inc" |
| 22 | |
Eric Christopher | 0eaa541 | 2014-07-02 22:05:40 +0000 | [diff] [blame^] | 23 | // Pin the vtable to this file. |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 24 | void SystemZSubtarget::anchor() {} |
| 25 | |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 26 | SystemZSubtarget & |
| 27 | SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 28 | std::string CPUName = CPU; |
| 29 | if (CPUName.empty()) |
Richard Sandiford | f834ea1 | 2013-10-31 12:14:17 +0000 | [diff] [blame] | 30 | CPUName = "generic"; |
| 31 | #if defined(__linux__) && defined(__s390x__) |
| 32 | if (CPUName == "generic") |
| 33 | CPUName = sys::getHostCPUName(); |
| 34 | #endif |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 35 | // Parse features string. |
| 36 | ParseSubtargetFeatures(CPUName, FS); |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 37 | return *this; |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 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), |
| 48 | // Make sure that global data has at least 16 bits of alignment by |
| 49 | // default, so that we can refer to it using LARL. We don't have any |
| 50 | // special requirements for stack variables though. |
| 51 | DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"), |
| 52 | InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM), |
| 53 | TSInfo(DL), FrameLowering() {} |
| 54 | |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 55 | // Return true if GV binds locally under reloc model RM. |
| 56 | static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) { |
| 57 | // For non-PIC, all symbols bind locally. |
| 58 | if (RM == Reloc::Static) |
| 59 | return true; |
| 60 | |
| 61 | return GV->hasLocalLinkage() || !GV->hasDefaultVisibility(); |
| 62 | } |
| 63 | |
| 64 | bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, |
| 65 | Reloc::Model RM, |
| 66 | CodeModel::Model CM) const { |
| 67 | // PC32DBL accesses require the low bit to be clear. Note that a zero |
| 68 | // value selects the default alignment and is therefore OK. |
| 69 | if (GV->getAlignment() == 1) |
| 70 | return false; |
| 71 | |
| 72 | // For the small model, all locally-binding symbols are in range. |
| 73 | if (CM == CodeModel::Small) |
| 74 | return bindsLocally(GV, RM); |
| 75 | |
| 76 | // For Medium and above, assume that the symbol is not within the 4GB range. |
| 77 | // Taking the address of locally-defined text would be OK, but that |
| 78 | // case isn't easy to detect. |
| 79 | return false; |
| 80 | } |