LLVM  3.7.0
SystemZSubtarget.cpp
Go to the documentation of this file.
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"
12 #include "llvm/IR/GlobalValue.h"
13 
14 using namespace llvm;
15 
16 #define DEBUG_TYPE "systemz-subtarget"
17 
18 #define GET_SUBTARGETINFO_TARGET_DESC
19 #define GET_SUBTARGETINFO_CTOR
20 #include "SystemZGenSubtargetInfo.inc"
21 
22 // Pin the vtable to this file.
23 void SystemZSubtarget::anchor() {}
24 
26 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
27  std::string CPUName = CPU;
28  if (CPUName.empty())
29  CPUName = "generic";
30  // Parse features string.
31  ParseSubtargetFeatures(CPUName, FS);
32  return *this;
33 }
34 
35 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
36  const std::string &FS,
37  const TargetMachine &TM)
38  : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
39  HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
40  HasPopulationCount(false), HasFastSerialization(false),
41  HasInterlockedAccess1(false), HasMiscellaneousExtensions(false),
42  HasTransactionalExecution(false), HasProcessorAssist(false),
43  HasVector(false), TargetTriple(TT),
44  InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
45  TSInfo(), FrameLowering() {}
46 
47 // Return true if GV binds locally under reloc model RM.
48 static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
49  // For non-PIC, all symbols bind locally.
50  if (RM == Reloc::Static)
51  return true;
52 
53  return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
54 }
55 
58  CodeModel::Model CM) const {
59  // PC32DBL accesses require the low bit to be clear. Note that a zero
60  // value selects the default alignment and is therefore OK.
61  if (GV->getAlignment() == 1)
62  return false;
63 
64  // For the small model, all locally-binding symbols are in range.
65  if (CM == CodeModel::Small)
66  return bindsLocally(GV, RM);
67 
68  // For Medium and above, assume that the symbol is not within the 4GB range.
69  // Taking the address of locally-defined text would be OK, but that
70  // case isn't easy to detect.
71  return false;
72 }
bool isPC32DBLSymbol(const GlobalValue *GV, Reloc::Model RM, CodeModel::Model CM) const
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
bool hasDefaultVisibility() const
Definition: GlobalValue.h:140
#define false
Definition: ConvertUTF.c:65
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM)
bool hasLocalLinkage() const
Definition: GlobalValue.h:280
unsigned getAlignment() const
Definition: Globals.cpp:63
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
SystemZSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM)