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" |
| 13 | |
Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 14 | using namespace llvm; |
| 15 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 16 | #define DEBUG_TYPE "systemz-subtarget" |
| 17 | |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 18 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 19 | #define GET_SUBTARGETINFO_CTOR |
| 20 | #include "SystemZGenSubtargetInfo.inc" |
| 21 | |
Eric Christopher | 0eaa541 | 2014-07-02 22:05:40 +0000 | [diff] [blame] | 22 | // Pin the vtable to this file. |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 23 | void SystemZSubtarget::anchor() {} |
| 24 | |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 25 | SystemZSubtarget & |
| 26 | SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 27 | std::string CPUName = CPU; |
| 28 | if (CPUName.empty()) |
Richard Sandiford | f834ea1 | 2013-10-31 12:14:17 +0000 | [diff] [blame] | 29 | CPUName = "generic"; |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 30 | // Parse features string. |
| 31 | ParseSubtargetFeatures(CPUName, FS); |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 32 | return *this; |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 35 | SystemZSubtarget::SystemZSubtarget(const std::string &TT, |
| 36 | const std::string &CPU, |
| 37 | const std::string &FS, |
| 38 | const TargetMachine &TM) |
| 39 | : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false), |
| 40 | HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false), |
Ulrich Weigand | b401218 | 2015-03-31 12:56:33 +0000 | [diff] [blame] | 41 | HasPopulationCount(false), HasFastSerialization(false), |
Ulrich Weigand | 371d10a | 2015-03-31 12:58:17 +0000 | [diff] [blame] | 42 | HasInterlockedAccess1(false), HasMiscellaneousExtensions(false), |
Eric Christopher | 8b77065 | 2015-01-26 19:03:15 +0000 | [diff] [blame] | 43 | TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)), |
Eric Christopher | a673417 | 2015-01-31 00:06:45 +0000 | [diff] [blame] | 44 | TLInfo(TM, *this), TSInfo(*TM.getDataLayout()), FrameLowering() {} |
Eric Christopher | 5234995 | 2014-07-01 20:19:02 +0000 | [diff] [blame] | 45 | |
Ulrich Weigand | 5f613df | 2013-05-06 16:15:19 +0000 | [diff] [blame] | 46 | // Return true if GV binds locally under reloc model RM. |
| 47 | static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) { |
| 48 | // For non-PIC, all symbols bind locally. |
| 49 | if (RM == Reloc::Static) |
| 50 | return true; |
| 51 | |
| 52 | return GV->hasLocalLinkage() || !GV->hasDefaultVisibility(); |
| 53 | } |
| 54 | |
| 55 | bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, |
| 56 | Reloc::Model RM, |
| 57 | CodeModel::Model CM) const { |
| 58 | // PC32DBL accesses require the low bit to be clear. Note that a zero |
| 59 | // value selects the default alignment and is therefore OK. |
| 60 | if (GV->getAlignment() == 1) |
| 61 | return false; |
| 62 | |
| 63 | // For the small model, all locally-binding symbols are in range. |
| 64 | if (CM == CodeModel::Small) |
| 65 | return bindsLocally(GV, RM); |
| 66 | |
| 67 | // For Medium and above, assume that the symbol is not within the 4GB range. |
| 68 | // Taking the address of locally-defined text would be OK, but that |
| 69 | // case isn't easy to detect. |
| 70 | return false; |
| 71 | } |