1 //===- SystemZSubtarget.cpp - SystemZ Subtarget Information -------*- C++ -*-=//
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 // This file implements the SystemZ specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "SystemZSubtarget.h"
15 #include "SystemZ.h"
16 #include "llvm/GlobalValue.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetRegistry.h"
19 
20 #define GET_SUBTARGETINFO_ENUM
21 #define GET_SUBTARGETINFO_MC_DESC
22 #define GET_SUBTARGETINFO_TARGET_DESC
23 #define GET_SUBTARGETINFO_CTOR
24 #include "SystemZGenSubtargetInfo.inc"
25 
26 using namespace llvm;
27 
28 SystemZSubtarget::SystemZSubtarget(const std::string &TT,
29                                    const std::string &CPU,
30                                    const std::string &FS):
31   SystemZGenSubtargetInfo(TT, CPU, FS), HasZ10Insts(false) {
32   std::string CPUName = CPU;
33   if (CPUName.empty())
34     CPUName = "z9";
35 
36   // Parse features string.
37   ParseSubtargetFeatures(CPUName, FS);
38 }
39 
40 /// True if accessing the GV requires an extra load.
41 bool SystemZSubtarget::GVRequiresExtraLoad(const GlobalValue* GV,
42                                            const TargetMachine& TM,
43                                            bool isDirectCall) const {
44   if (TM.getRelocationModel() == Reloc::PIC_) {
45     // Extra load is needed for all externally visible.
46     if (isDirectCall)
47       return false;
48 
49     if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
50       return false;
51 
52     return true;
53   }
54 
55   return false;
56 }
57 
58 MCSubtargetInfo *createSystemZMCSubtargetInfo(StringRef TT, StringRef CPU,
59                                               StringRef FS) {
60   MCSubtargetInfo *X = new MCSubtargetInfo();
61   InitSystemZMCSubtargetInfo(X, TT, CPU, FS);
62   return X;
63 }
64 
65 extern "C" void LLVMInitializeSystemZMCSubtargetInfo() {
66   TargetRegistry::RegisterMCSubtargetInfo(TheSystemZTarget,
67                                           createSystemZMCSubtargetInfo);
68 }
69