llvm.org GIT mirror llvm / 3479713
Move the TLSModel information into the TargetMachine rather than hiding in TargetLowering. There was already a FIXME about this location being odd. The interface is simplified as a consequence. This will also make it easier to change TLS models when compiling with PIE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154292 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
6 changed file(s) with 37 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
2626 enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
2727 }
2828
29 // TLS models.
30 namespace TLSModel {
31 enum Model {
32 GeneralDynamic,
33 LocalDynamic,
34 InitialExec,
35 LocalExec
36 };
37 }
38
2939 // Code generation optimization level.
3040 namespace CodeGenOpt {
3141 enum Level {
6262 VLIW // Scheduling for VLIW targets.
6363 };
6464 }
65
66 // FIXME: should this be here?
67 namespace TLSModel {
68 enum Model {
69 GeneralDynamic,
70 LocalDynamic,
71 InitialExec,
72 LocalExec
73 };
74 }
75 TLSModel::Model getTLSModel(const GlobalValue *GV, Reloc::Model reloc);
7665
7766
7867 //===----------------------------------------------------------------------===//
2323
2424 class InstrItineraryData;
2525 class JITCodeEmitter;
26 class GlobalValue;
2627 class MCAsmInfo;
2728 class MCCodeGenInfo;
2829 class MCContext;
194195 /// medium, large, and target default.
195196 CodeModel::Model getCodeModel() const;
196197
198 /// getTLSModel - Returns the TLS model which should be used for the given
199 /// global variable.
200 TLSModel::Model getTLSModel(const GlobalValue *GV) const;
201
197202 /// getOptLevel - Returns the optimization level: None, Less,
198203 /// Default, or Aggressive.
199204 CodeGenOpt::Level getOptLevel() const;
3737 static cl::opt
3838 AllowPromoteIntElem("promote-elements", cl::Hidden, cl::init(true),
3939 cl::desc("Allow promotion of integer vector element types"));
40
41 namespace llvm {
42 TLSModel::Model getTLSModel(const GlobalValue *GV, Reloc::Model reloc) {
43 bool isLocal = GV->hasLocalLinkage();
44 bool isDeclaration = GV->isDeclaration();
45 // FIXME: what should we do for protected and internal visibility?
46 // For variables, is internal different from hidden?
47 bool isHidden = GV->hasHiddenVisibility();
48
49 if (reloc == Reloc::PIC_) {
50 if (isLocal || isHidden)
51 return TLSModel::LocalDynamic;
52 else
53 return TLSModel::GeneralDynamic;
54 } else {
55 if (!isDeclaration || isHidden)
56 return TLSModel::LocalExec;
57 else
58 return TLSModel::InitialExec;
59 }
60 }
61 }
6240
6341 /// InitLibcallNames - Set default libcall names.
6442 ///
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/GlobalValue.h"
1314 #include "llvm/MC/MCAsmInfo.h"
1415 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/Target/TargetMachine.h"
7374 return CodeGenInfo->getCodeModel();
7475 }
7576
77 TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
78 bool isLocal = GV->hasLocalLinkage();
79 bool isDeclaration = GV->isDeclaration();
80 // FIXME: what should we do for protected and internal visibility?
81 // For variables, is internal different from hidden?
82 bool isHidden = GV->hasHiddenVisibility();
83
84 if (getRelocationModel() == Reloc::PIC_) {
85 if (isLocal || isHidden)
86 return TLSModel::LocalDynamic;
87 else
88 return TLSModel::GeneralDynamic;
89 } else {
90 if (!isDeclaration || isHidden)
91 return TLSModel::LocalExec;
92 else
93 return TLSModel::InitialExec;
94 }
95 }
96
7697 /// getOptLevel - Returns the optimization level: None, Less,
7798 /// Default, or Aggressive.
7899 CodeGenOpt::Level TargetMachine::getOptLevel() const {
72047204 if (const GlobalAlias *GA = dyn_cast(GV))
72057205 GV = GA->resolveAliasedGlobal(false);
72067206
7207 TLSModel::Model model
7208 = getTLSModel(GV, getTargetMachine().getRelocationModel());
7207 TLSModel::Model model = getTargetMachine().getTLSModel(GV);
72097208
72107209 switch (model) {
72117210 case TLSModel::GeneralDynamic: