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"
11 #include "MCTargetDesc/SystemZMCTargetDesc.h"
12 #include "llvm/CodeGen/Analysis.h"
13 #include "llvm/IR/GlobalValue.h"
14 
15 using namespace llvm;
16 
17 #define DEBUG_TYPE "systemz-subtarget"
18 
19 #define GET_SUBTARGETINFO_TARGET_DESC
20 #define GET_SUBTARGETINFO_CTOR
21 #include "SystemZGenSubtargetInfo.inc"
22 
23 // Pin the vtable to this file.
24 void SystemZSubtarget::anchor() {}
25 
26 SystemZSubtarget &
27 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
28   std::string CPUName = CPU;
29   if (CPUName.empty())
30     CPUName = "generic";
31   // Parse features string.
32   ParseSubtargetFeatures(CPUName, FS);
33   return *this;
34 }
35 
36 SystemZSubtarget::SystemZSubtarget(const Triple &TT, 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),
41       HasPopulationCount(false), HasFastSerialization(false),
42       HasInterlockedAccess1(false), HasMiscellaneousExtensions(false),
43       HasTransactionalExecution(false), HasProcessorAssist(false),
44       HasVector(false), TargetTriple(TT),
45       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
46       TSInfo(), FrameLowering() {}
47 
48 bool 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 shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV);
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 }
65