[SystemZ] Remove TargetMachine CPU auto-detection
[oota-llvm.git] / lib / Target / SystemZ / SystemZSubtarget.cpp
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/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
25 SystemZSubtarget &
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 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),
41       HasFastSerialization(false), HasInterlockedAccess1(false),
42       TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
43       TLInfo(TM, *this), TSInfo(*TM.getDataLayout()), FrameLowering() {}
44
45 // Return true if GV binds locally under reloc model RM.
46 static bool bindsLocally(const GlobalValue *GV, Reloc::Model RM) {
47   // For non-PIC, all symbols bind locally.
48   if (RM == Reloc::Static)
49     return true;
50
51   return GV->hasLocalLinkage() || !GV->hasDefaultVisibility();
52 }
53
54 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
55                                        Reloc::Model RM,
56                                        CodeModel::Model CM) const {
57   // PC32DBL accesses require the low bit to be clear.  Note that a zero
58   // value selects the default alignment and is therefore OK.
59   if (GV->getAlignment() == 1)
60     return false;
61
62   // For the small model, all locally-binding symbols are in range.
63   if (CM == CodeModel::Small)
64     return bindsLocally(GV, RM);
65
66   // For Medium and above, assume that the symbol is not within the 4GB range.
67   // Taking the address of locally-defined text would be OK, but that
68   // case isn't easy to detect.
69   return false;
70 }