llvm.org GIT mirror llvm / cbd9a19
Reapply the TargerTransformInfo changes, minus the changes to LSR and Lowerinvoke. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166248 91177308-0d34-0410-b5e6-96231b3b80d8 Nadav Rotem 7 years ago
38 changed file(s) with 720 addition(s) and 225 deletion(s). Raw diff Collapse all Expand all
0 //===-- CommandFlags.h - Register Coalescing Interface ----------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains codegen-specific flags that are shared between different
10 // command line tools. The tools "llc" and "opt" both use this file to prevent
11 // flag duplication.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_COMMAND_LINE_FLAGS_H
16 #define LLVM_CODEGEN_COMMAND_LINE_FLAGS_H
17
18 #include "llvm/Support/CommandLine.h"
19 #include "llvm/Support/CodeGen.h"
20 #include "llvm/Target/TargetMachine.h"
21
22 #include
23 using namespace llvm;
24
25 cl::opt
26 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
27
28 cl::opt
29 MCPU("mcpu",
30 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
31 cl::value_desc("cpu-name"),
32 cl::init(""));
33
34 cl::list
35 MAttrs("mattr",
36 cl::CommaSeparated,
37 cl::desc("Target specific attributes (-mattr=help for details)"),
38 cl::value_desc("a1,+a2,-a3,..."));
39
40 cl::opt
41 RelocModel("relocation-model",
42 cl::desc("Choose relocation model"),
43 cl::init(Reloc::Default),
44 cl::values(
45 clEnumValN(Reloc::Default, "default",
46 "Target default relocation model"),
47 clEnumValN(Reloc::Static, "static",
48 "Non-relocatable code"),
49 clEnumValN(Reloc::PIC_, "pic",
50 "Fully relocatable, position independent code"),
51 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
52 "Relocatable external references, non-relocatable code"),
53 clEnumValEnd));
54
55 cl::opt
56 CMModel("code-model",
57 cl::desc("Choose code model"),
58 cl::init(CodeModel::Default),
59 cl::values(clEnumValN(CodeModel::Default, "default",
60 "Target default code model"),
61 clEnumValN(CodeModel::Small, "small",
62 "Small code model"),
63 clEnumValN(CodeModel::Kernel, "kernel",
64 "Kernel code model"),
65 clEnumValN(CodeModel::Medium, "medium",
66 "Medium code model"),
67 clEnumValN(CodeModel::Large, "large",
68 "Large code model"),
69 clEnumValEnd));
70
71 cl::opt
72 RelaxAll("mc-relax-all",
73 cl::desc("When used with filetype=obj, "
74 "relax all fixups in the emitted object file"));
75
76 cl::opt
77 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
78 cl::desc("Choose a file type (not all types are supported by all targets):"),
79 cl::values(
80 clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
81 "Emit an assembly ('.s') file"),
82 clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
83 "Emit a native object ('.o') file"),
84 clEnumValN(TargetMachine::CGFT_Null, "null",
85 "Emit nothing, for performance testing"),
86 clEnumValEnd));
87
88 cl::opt DisableDotLoc("disable-dot-loc", cl::Hidden,
89 cl::desc("Do not use .loc entries"));
90
91 cl::opt DisableCFI("disable-cfi", cl::Hidden,
92 cl::desc("Do not use .cfi_* directives"));
93
94 cl::opt EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
95 cl::desc("Use .file directives with an explicit directory."));
96
97 cl::opt
98 DisableRedZone("disable-red-zone",
99 cl::desc("Do not emit code that uses the red zone."),
100 cl::init(false));
101
102 cl::opt
103 EnableFPMAD("enable-fp-mad",
104 cl::desc("Enable less precise MAD instructions to be generated"),
105 cl::init(false));
106
107 cl::opt
108 DisableFPElim("disable-fp-elim",
109 cl::desc("Disable frame pointer elimination optimization"),
110 cl::init(false));
111
112 cl::opt
113 DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
114 cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
115 cl::init(false));
116
117 cl::opt
118 EnableUnsafeFPMath("enable-unsafe-fp-math",
119 cl::desc("Enable optimizations that may decrease FP precision"),
120 cl::init(false));
121
122 cl::opt
123 EnableNoInfsFPMath("enable-no-infs-fp-math",
124 cl::desc("Enable FP math optimizations that assume no +-Infs"),
125 cl::init(false));
126
127 cl::opt
128 EnableNoNaNsFPMath("enable-no-nans-fp-math",
129 cl::desc("Enable FP math optimizations that assume no NaNs"),
130 cl::init(false));
131
132 cl::opt
133 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
134 cl::Hidden,
135 cl::desc("Force codegen to assume rounding mode can change dynamically"),
136 cl::init(false));
137
138 cl::opt
139 GenerateSoftFloatCalls("soft-float",
140 cl::desc("Generate software floating point library calls"),
141 cl::init(false));
142
143 cl::opt
144 FloatABIForCalls("float-abi",
145 cl::desc("Choose float ABI type"),
146 cl::init(FloatABI::Default),
147 cl::values(
148 clEnumValN(FloatABI::Default, "default",
149 "Target default float ABI type"),
150 clEnumValN(FloatABI::Soft, "soft",
151 "Soft float ABI (implied by -soft-float)"),
152 clEnumValN(FloatABI::Hard, "hard",
153 "Hard float ABI (uses FP registers)"),
154 clEnumValEnd));
155
156 cl::opt
157 FuseFPOps("fp-contract",
158 cl::desc("Enable aggresive formation of fused FP ops"),
159 cl::init(FPOpFusion::Standard),
160 cl::values(
161 clEnumValN(FPOpFusion::Fast, "fast",
162 "Fuse FP ops whenever profitable"),
163 clEnumValN(FPOpFusion::Standard, "on",
164 "Only fuse 'blessed' FP ops."),
165 clEnumValN(FPOpFusion::Strict, "off",
166 "Only fuse FP ops when the result won't be effected."),
167 clEnumValEnd));
168
169 cl::opt
170 DontPlaceZerosInBSS("nozero-initialized-in-bss",
171 cl::desc("Don't place zero-initialized symbols into bss section"),
172 cl::init(false));
173
174 cl::opt
175 EnableGuaranteedTailCallOpt("tailcallopt",
176 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
177 cl::init(false));
178
179 cl::opt
180 DisableTailCalls("disable-tail-calls",
181 cl::desc("Never emit tail calls"),
182 cl::init(false));
183
184 cl::opt
185 OverrideStackAlignment("stack-alignment",
186 cl::desc("Override default stack alignment"),
187 cl::init(0));
188
189 cl::opt
190 EnableRealignStack("realign-stack",
191 cl::desc("Realign stack if needed"),
192 cl::init(true));
193
194 cl::opt
195 TrapFuncName("trap-func", cl::Hidden,
196 cl::desc("Emit a call to trap function rather than a trap instruction"),
197 cl::init(""));
198
199 cl::opt
200 EnablePIE("enable-pie",
201 cl::desc("Assume the creation of a position independent executable."),
202 cl::init(false));
203
204 cl::opt
205 SegmentedStacks("segmented-stacks",
206 cl::desc("Use segmented stacks if possible."),
207 cl::init(false));
208
209 cl::opt
210 UseInitArray("use-init-array",
211 cl::desc("Use .init_array instead of .ctors."),
212 cl::init(false));
213
214 cl::opt StopAfter("stop-after",
215 cl::desc("Stop compilation after a specific pass"),
216 cl::value_desc("pass-name"),
217 cl::init(""));
218 cl::opt StartAfter("start-after",
219 cl::desc("Resume compilation after a specific pass"),
220 cl::value_desc("pass-name"),
221 cl::init(""));
222
223 cl::opt
224 SSPBufferSize("stack-protector-buffer-size", cl::init(8),
225 cl::desc("Lower bound for a buffer to be considered for "
226 "stack protection"));
227 #endif
248248 void initializeTailDuplicatePassPass(PassRegistry&);
249249 void initializeTargetPassConfigPass(PassRegistry&);
250250 void initializeDataLayoutPass(PassRegistry&);
251 void initializeTargetTransformInfoPass(PassRegistry&);
251252 void initializeTargetLibraryInfoPass(PassRegistry&);
252253 void initializeTwoAddressInstructionPassPass(PassRegistry&);
253254 void initializeTypeBasedAliasAnalysisPass(PassRegistry&);
1616 #include "llvm/Pass.h"
1717 #include "llvm/Support/CodeGen.h"
1818 #include "llvm/Target/TargetOptions.h"
19 #include "llvm/TargetTransformInfo.h"
20 #include "llvm/Target/TargetTransformImpl.h"
1921 #include "llvm/ADT/StringRef.h"
2022 #include
2123 #include
106108 virtual const TargetLowering *getTargetLowering() const { return 0; }
107109 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const{ return 0; }
108110 virtual const DataLayout *getDataLayout() const { return 0; }
111 virtual const ScalarTargetTransformInfo*
112 getScalarTargetTransformInfo() const { return 0; }
113 virtual const VectorTargetTransformInfo*
114 getVectorTargetTransformInfo() const { return 0; }
109115
110116 /// getMCAsmInfo - Return target specific asm information.
111117 ///
0 //=- llvm/Target/TargetTransformImpl.h - Target Loop Trans Info----*- C++ -*-=//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the target-specific implementations of the
10 // TargetTransform interfaces.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_TARGET_TRANSFORMATION_IMPL_H
15 #define LLVM_TARGET_TARGET_TRANSFORMATION_IMPL_H
16
17 #include "llvm/TargetTransformInfo.h"
18
19 namespace llvm {
20
21 class TargetLowering;
22
23 /// ScalarTargetTransformInfo - This is a default implementation for the
24 /// ScalarTargetTransformInfo interface. Different targets can implement
25 /// this interface differently.
26 class ScalarTargetTransformImpl : public ScalarTargetTransformInfo {
27 private:
28 const TargetLowering *TLI;
29
30 public:
31 /// Ctor
32 explicit ScalarTargetTransformImpl(const TargetLowering *TL) : TLI(TL) {}
33
34 virtual bool isLegalAddImmediate(int64_t imm) const;
35
36 virtual bool isLegalICmpImmediate(int64_t imm) const;
37
38 virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const;
39
40 virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const;
41
42 virtual bool isTypeLegal(Type *Ty) const;
43
44 virtual unsigned getJumpBufAlignment() const;
45
46 virtual unsigned getJumpBufSize() const;
47 };
48
49 class VectorTargetTransformImpl : public VectorTargetTransformInfo { };
50
51 } // end llvm namespace
52
53 #endif
0 //===- llvm/Transforms/TargetTransformInfo.h --------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This pass exposes codegen information to IR-level passes. Every
10 // transformation that uses codegen information is broken into three parts:
11 // 1. The IR-level analysis pass.
12 // 2. The IR-level transformation interface which provides the needed
13 // information.
14 // 3. Codegen-level implementation which uses target-specific hooks.
15 //
16 // This file defines #2, which is the interface that IR-level transformations
17 // use for querying the codegen.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #ifndef LLVM_TRANSFORMS_TARGET_TRANSFORM_INTERFACE
22 #define LLVM_TRANSFORMS_TARGET_TRANSFORM_INTERFACE
23
24 #include "llvm/Pass.h"
25 #include "llvm/AddressingMode.h"
26 #include "llvm/Support/DataTypes.h"
27 #include "llvm/Type.h"
28
29 namespace llvm {
30
31 class ScalarTargetTransformInfo;
32 class VectorTargetTransformInfo;
33
34 /// TargetTransformInfo - This pass provides access to the codegen
35 /// interfaces that are needed for IR-level transformations.
36 class TargetTransformInfo : public ImmutablePass {
37 private:
38 const ScalarTargetTransformInfo *STTI;
39 const VectorTargetTransformInfo *VTTI;
40 public:
41 /// Default ctor.
42 ///
43 /// @note This has to exist, because this is a pass, but it should never be
44 /// used.
45 TargetTransformInfo();
46
47 explicit TargetTransformInfo(const ScalarTargetTransformInfo* S,
48 const VectorTargetTransformInfo *V)
49 : ImmutablePass(ID), STTI(S), VTTI(V) {
50 initializeTargetTransformInfoPass(*PassRegistry::getPassRegistry());
51 }
52
53 TargetTransformInfo(const TargetTransformInfo &T) :
54 ImmutablePass(ID), STTI(T.STTI), VTTI(T.VTTI) { }
55
56 const ScalarTargetTransformInfo* getScalarTargetTransformInfo() {
57 return STTI;
58 }
59 const VectorTargetTransformInfo* getVectorTargetTransformInfo() {
60 return VTTI;
61 }
62
63 /// Pass identification, replacement for typeid.
64 static char ID;
65 };
66
67 // ---------------------------------------------------------------------------//
68 // The classes below are inherited and implemented by target-specific classes
69 // in the codegen.
70 // ---------------------------------------------------------------------------//
71
72 /// ScalarTargetTransformInfo - This interface is used by IR-level passes
73 /// that need target-dependent information for generic scalar transformations.
74 /// LSR, and LowerInvoke use this interface.
75 class ScalarTargetTransformInfo {
76 public:
77 virtual ~ScalarTargetTransformInfo() {}
78
79 /// isLegalAddImmediate - Return true if the specified immediate is legal
80 /// add immediate, that is the target has add instructions which can add
81 /// a register with the immediate without having to materialize the
82 /// immediate into a register.
83 virtual bool isLegalAddImmediate(int64_t) const {
84 return false;
85 }
86 /// isLegalICmpImmediate - Return true if the specified immediate is legal
87 /// icmp immediate, that is the target has icmp instructions which can compare
88 /// a register against the immediate without having to materialize the
89 /// immediate into a register.
90 virtual bool isLegalICmpImmediate(int64_t) const {
91 return false;
92 }
93 /// isLegalAddressingMode - Return true if the addressing mode represented by
94 /// AM is legal for this target, for a load/store of the specified type.
95 /// The type may be VoidTy, in which case only return true if the addressing
96 /// mode is legal for a load/store of any legal type.
97 /// TODO: Handle pre/postinc as well.
98 virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const {
99 return false;
100 }
101 /// isTruncateFree - Return true if it's free to truncate a value of
102 /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in
103 /// register EAX to i16 by referencing its sub-register AX.
104 virtual bool isTruncateFree(Type * /*Ty1*/, Type * /*Ty2*/) const {
105 return false;
106 }
107 /// Is this type legal.
108 virtual bool isTypeLegal(Type *Ty) const {
109 return false;
110 }
111 /// getJumpBufAlignment - returns the target's jmp_buf alignment in bytes
112 virtual unsigned getJumpBufAlignment() const {
113 return 0;
114 }
115 /// getJumpBufSize - returns the target's jmp_buf size in bytes.
116 virtual unsigned getJumpBufSize() const {
117 return 0;
118 }
119 };
120
121 class VectorTargetTransformInfo {
122 // TODO: define an interface for VectorTargetTransformInfo.
123 };
124
125 } // End llvm namespace
126
127 #endif
7070 ELFWriterInfo(*this),
7171 TLInfo(*this),
7272 TSInfo(*this),
73 FrameLowering(Subtarget) {
73 FrameLowering(Subtarget),
74 STTI(&TLInfo) {
7475 if (!Subtarget.hasARMOps())
7576 report_fatal_error("CPU: '" + Subtarget.getCPUString() + "' does not "
7677 "support ARM mode execution!");
103104 TSInfo(*this),
104105 FrameLowering(Subtarget.hasThumb2()
105106 ? new ARMFrameLowering(Subtarget)
106 : (ARMFrameLowering*)new Thumb1FrameLowering(Subtarget)) {
107 : (ARMFrameLowering*)new Thumb1FrameLowering(Subtarget)),
108 STTI(&TLInfo){
107109 }
108110
109111 namespace {
2424 #include "Thumb1FrameLowering.h"
2525 #include "Thumb2InstrInfo.h"
2626 #include "llvm/Target/TargetMachine.h"
27 #include "llvm/Target/TargetTransformImpl.h"
2728 #include "llvm/DataLayout.h"
2829 #include "llvm/MC/MCStreamer.h"
2930 #include "llvm/ADT/OwningPtr.h"
6667 ARMTargetLowering TLInfo;
6768 ARMSelectionDAGInfo TSInfo;
6869 ARMFrameLowering FrameLowering;
70 ScalarTargetTransformImpl STTI;
71 VectorTargetTransformImpl VTTI;
6972 public:
7073 ARMTargetMachine(const Target &T, StringRef TT,
7174 StringRef CPU, StringRef FS,
8790 virtual const ARMFrameLowering *getFrameLowering() const {
8891 return &FrameLowering;
8992 }
90
93 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
94 return &STTI;
95 }
96 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
97 return &VTTI;
98 }
9199 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
92100 virtual const DataLayout *getDataLayout() const { return &DL; }
93101 virtual const ARMELFWriterInfo *getELFWriterInfo() const {
109117 ARMSelectionDAGInfo TSInfo;
110118 // Either Thumb1FrameLowering or ARMFrameLowering.
111119 OwningPtr FrameLowering;
120 ScalarTargetTransformImpl STTI;
121 VectorTargetTransformImpl VTTI;
112122 public:
113123 ThumbTargetMachine(const Target &T, StringRef TT,
114124 StringRef CPU, StringRef FS,
137147 virtual const ARMFrameLowering *getFrameLowering() const {
138148 return FrameLowering.get();
139149 }
150 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
151 return &STTI;
152 }
153 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
154 return &VTTI;
155 }
140156 virtual const DataLayout *getDataLayout() const { return &DL; }
141157 virtual const ARMELFWriterInfo *getELFWriterInfo() const {
142158 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
1010 TargetMachineC.cpp
1111 TargetRegisterInfo.cpp
1212 TargetSubtargetInfo.cpp
13 TargetTransformImpl.cpp
1314 )
1415
1516 foreach(t ${LLVM_TARGETS_TO_BUILD})
4242 FrameLowering(Subtarget),
4343 TLInfo(*this),
4444 TSInfo(*this),
45 InstrItins(Subtarget.getInstrItineraryData()) {
45 InstrItins(Subtarget.getInstrItineraryData()),
46 STTI(&TLInfo){
4647 }
4748
4849 //===----------------------------------------------------------------------===//
1919 #include "SPUSelectionDAGInfo.h"
2020 #include "SPUFrameLowering.h"
2121 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Target/TargetTransformImpl.h"
2223 #include "llvm/DataLayout.h"
2324
2425 namespace llvm {
3334 SPUTargetLowering TLInfo;
3435 SPUSelectionDAGInfo TSInfo;
3536 InstrItineraryData InstrItins;
37 ScalarTargetTransformImpl STTI;
38 VectorTargetTransformImpl VTTI;
3639 public:
3740 SPUTargetMachine(const Target &T, StringRef TT,
3841 StringRef CPU, StringRef FS, const TargetOptions &Options,
7679 virtual const InstrItineraryData *getInstrItineraryData() const {
7780 return &InstrItins;
7881 }
82 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
83 return &STTI;
84 }
85 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
86 return &VTTI;
87 }
7988
8089 // Pass Pipeline Configuration
8190 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
7373 Subtarget(TT, CPU, FS), InstrInfo(Subtarget), TLInfo(*this),
7474 TSInfo(*this),
7575 FrameLowering(Subtarget),
76 InstrItins(&Subtarget.getInstrItineraryData()) {
76 InstrItins(&Subtarget.getInstrItineraryData()),
77 STTI(&TLInfo) {
7778 setMCUseCFI(false);
7879 }
7980
8687 PM.add(createDeadCodeEliminationPass());
8788 PM.add(createConstantPropagationPass());
8889 PM.add(createLoopUnrollPass());
89 PM.add(createLoopStrengthReducePass(getTargetLowering()));
90 PM.add(createLoopStrengthReducePass());
9091 return true;
9192 }
9293
2020 #include "HexagonFrameLowering.h"
2121 #include "llvm/Target/TargetMachine.h"
2222 #include "llvm/DataLayout.h"
23 #include "llvm/Target/TargetTransformImpl.h"
2324
2425 namespace llvm {
2526
3334 HexagonSelectionDAGInfo TSInfo;
3435 HexagonFrameLowering FrameLowering;
3536 const InstrItineraryData* InstrItins;
37 ScalarTargetTransformImpl STTI;
38 VectorTargetTransformImpl VTTI;
3639
3740 public:
3841 HexagonTargetMachine(const Target &T, StringRef TT,StringRef CPU,
6770 return &TSInfo;
6871 }
6972
73 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
74 return &STTI;
75 }
76
77 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
78 return &VTTI;
79 }
80
7081 virtual const DataLayout *getDataLayout() const { return &DL; }
7182 static unsigned getModuleMatchQuality(const Module &M);
7283
4141 InstrInfo(*this),
4242 FrameLowering(Subtarget),
4343 TLInfo(*this), TSInfo(*this), ELFWriterInfo(*this),
44 InstrItins(Subtarget.getInstrItineraryData()) {
44 InstrItins(Subtarget.getInstrItineraryData()), STTI(&TLInfo) {
4545 }
4646
4747 namespace {
2424 #include "llvm/Target/TargetMachine.h"
2525 #include "llvm/DataLayout.h"
2626 #include "llvm/Target/TargetFrameLowering.h"
27 #include "llvm/Target/TargetTransformImpl.h"
2728
2829 namespace llvm {
2930 class formatted_raw_ostream;
3839 MBlazeIntrinsicInfo IntrinsicInfo;
3940 MBlazeELFWriterInfo ELFWriterInfo;
4041 InstrItineraryData InstrItins;
42 ScalarTargetTransformImpl STTI;
43 VectorTargetTransformImpl VTTI;
4144
4245 public:
4346 MBlazeTargetMachine(const Target &T, StringRef TT,
7679 virtual const MBlazeELFWriterInfo *getELFWriterInfo() const {
7780 return &ELFWriterInfo;
7881 }
82 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const
83 { return &STTI; }
84 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const
85 { return &VTTI; }
7986
8087 // Pass Pipeline Configuration
8188 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
3535 // FIXME: Check DataLayout string.
3636 DL("e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"),
3737 InstrInfo(*this), TLInfo(*this), TSInfo(*this),
38 FrameLowering(Subtarget) { }
38 FrameLowering(Subtarget), STTI(&TLInfo) { }
3939
4040 namespace {
4141 /// MSP430 Code Generator Pass Configuration Options.
2323 #include "llvm/DataLayout.h"
2424 #include "llvm/Target/TargetFrameLowering.h"
2525 #include "llvm/Target/TargetMachine.h"
26 #include "llvm/Target/TargetTransformImpl.h"
2627
2728 namespace llvm {
2829
3536 MSP430TargetLowering TLInfo;
3637 MSP430SelectionDAGInfo TSInfo;
3738 MSP430FrameLowering FrameLowering;
39 ScalarTargetTransformImpl STTI;
40 VectorTargetTransformImpl VTTI;
3841
3942 public:
4043 MSP430TargetMachine(const Target &T, StringRef TT,
6063 virtual const MSP430SelectionDAGInfo* getSelectionDAGInfo() const {
6164 return &TSInfo;
6265 }
63
66 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
67 return &STTI;
68 }
69 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
70 return &VTTI;
71 }
6472 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
6573 }; // MSP430TargetMachine.
6674
5252 InstrInfo(MipsInstrInfo::create(*this)),
5353 FrameLowering(MipsFrameLowering::create(*this, Subtarget)),
5454 TLInfo(*this), TSInfo(*this), JITInfo(),
55 ELFWriterInfo(false, isLittle) {
55 ELFWriterInfo(false, isLittle), STTI(&TLInfo) {
5656 }
5757
5858 void MipsebTargetMachine::anchor() { }
2323 #include "llvm/Target/TargetMachine.h"
2424 #include "llvm/DataLayout.h"
2525 #include "llvm/Target/TargetFrameLowering.h"
26 #include "llvm/Target/TargetTransformImpl.h"
2627
2728 namespace llvm {
2829 class formatted_raw_ostream;
3738 MipsSelectionDAGInfo TSInfo;
3839 MipsJITInfo JITInfo;
3940 MipsELFWriterInfo ELFWriterInfo;
41 ScalarTargetTransformImpl STTI;
42 VectorTargetTransformInfo VTTI;
4043
4144 public:
4245 MipsTargetMachine(const Target &T, StringRef TT,
7376 virtual const MipsELFWriterInfo *getELFWriterInfo() const {
7477 return &ELFWriterInfo;
7578 }
79 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
80 return &STTI;
81 }
82 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
83 return &VTTI;
84 }
7685
7786 // Pass Pipeline Configuration
7887 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
7171 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
7272 Subtarget(TT, CPU, FS, is64bit),
7373 DL(Subtarget.getDataLayout()),
74 InstrInfo(*this), TLInfo(*this), TSInfo(*this), FrameLowering(*this,is64bit)
74 InstrInfo(*this), TLInfo(*this), TSInfo(*this), FrameLowering(*this,is64bit),
75 STTI(&TLInfo)
7576 /*FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0)*/ {
7677 }
7778
2424 #include "llvm/Target/TargetFrameLowering.h"
2525 #include "llvm/Target/TargetMachine.h"
2626 #include "llvm/Target/TargetSelectionDAGInfo.h"
27 #include "llvm/Target/TargetTransformImpl.h"
2728
2829 namespace llvm {
2930
4243
4344 // Hold Strings that can be free'd all together with NVPTXTargetMachine
4445 ManagedStringPool ManagedStrPool;
46
47 ScalarTargetTransformImpl STTI;
48 VectorTargetTransformImpl VTTI;
4549
4650 //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
4751 // bool DisableVerify, MCContext *&OutCtx);
7074
7175 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
7276 return &TSInfo;
77 }
78 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
79 return &STTI;
80 }
81 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
82 return &VTTI;
7383 }
7484
7585 //virtual bool addInstSelector(PassManagerBase &PM,
4242 DL(Subtarget.getDataLayoutString()), InstrInfo(*this),
4343 FrameLowering(Subtarget), JITInfo(*this, is64Bit),
4444 TLInfo(*this), TSInfo(*this),
45 InstrItins(Subtarget.getInstrItineraryData()) {
45 InstrItins(Subtarget.getInstrItineraryData()),
46 STTI(&TLInfo){
4647
4748 // The binutils for the BG/P are too old for CFI.
4849 if (Subtarget.isBGP())
2020 #include "PPCISelLowering.h"
2121 #include "PPCSelectionDAGInfo.h"
2222 #include "llvm/Target/TargetMachine.h"
23 #include "llvm/Target/TargetTransformImpl.h"
2324 #include "llvm/DataLayout.h"
2425
2526 namespace llvm {
3536 PPCTargetLowering TLInfo;
3637 PPCSelectionDAGInfo TSInfo;
3738 InstrItineraryData InstrItins;
39 ScalarTargetTransformImpl STTI;
40 VectorTargetTransformImpl VTTI;
3841
3942 public:
4043 PPCTargetMachine(const Target &T, StringRef TT,
6164 virtual const PPCSubtarget *getSubtargetImpl() const { return &Subtarget; }
6265 virtual const InstrItineraryData *getInstrItineraryData() const {
6366 return &InstrItins;
67 }
68 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
69 return &STTI;
70 }
71 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
72 return &VTTI;
6473 }
6574
6675 // Pass Pipeline Configuration
3535 DL(Subtarget.getDataLayout()),
3636 InstrInfo(Subtarget),
3737 TLInfo(*this), TSInfo(*this),
38 FrameLowering(Subtarget) {
38 FrameLowering(Subtarget),STTI(&TLInfo) {
3939 }
4040
4141 namespace {
2121 #include "llvm/Target/TargetMachine.h"
2222 #include "llvm/DataLayout.h"
2323 #include "llvm/Target/TargetFrameLowering.h"
24 #include "llvm/Target/TargetTransformImpl.h"
2425
2526 namespace llvm {
2627
3132 SparcTargetLowering TLInfo;
3233 SparcSelectionDAGInfo TSInfo;
3334 SparcFrameLowering FrameLowering;
35 ScalarTargetTransformImpl STTI;
36 VectorTargetTransformImpl VTTI;
3437 public:
3538 SparcTargetMachine(const Target &T, StringRef TT,
3639 StringRef CPU, StringRef FS, const TargetOptions &Options,
5053 }
5154 virtual const SparcSelectionDAGInfo* getSelectionDAGInfo() const {
5255 return &TSInfo;
56 }
57 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
58 return &STTI;
59 }
60 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
61 return &VTTI;
5362 }
5463 virtual const DataLayout *getDataLayout() const { return &DL; }
5564
2525 void llvm::initializeTarget(PassRegistry &Registry) {
2626 initializeDataLayoutPass(Registry);
2727 initializeTargetLibraryInfoPass(Registry);
28 initializeTargetTransformInfoPass(Registry);
2829 }
2930
3031 void LLVMInitializeTarget(LLVMPassRegistryRef R) {
0 // llvm/Target/TargetTransformImpl.cpp - Target Loop Trans Info ---*- C++ -*-=//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/Target/TargetTransformImpl.h"
10 #include "llvm/Target/TargetLowering.h"
11
12 using namespace llvm;
13
14 bool ScalarTargetTransformImpl::isLegalAddImmediate(int64_t imm) const {
15 return TLI->isLegalAddImmediate(imm);
16 }
17
18 bool ScalarTargetTransformImpl::isLegalICmpImmediate(int64_t imm) const {
19 return TLI->isLegalICmpImmediate(imm);
20 }
21
22 bool ScalarTargetTransformImpl::isLegalAddressingMode(const AddrMode &AM,
23 Type *Ty) const {
24 return TLI->isLegalAddressingMode(AM, Ty);
25 }
26
27 bool ScalarTargetTransformImpl::isTruncateFree(Type *Ty1, Type *Ty2) const {
28 return TLI->isTruncateFree(Ty1, Ty2);
29 }
30
31 bool ScalarTargetTransformImpl::isTypeLegal(Type *Ty) const {
32 EVT T = TLI->getValueType(Ty);
33 return TLI->isTypeLegal(T);
34 }
35
36 unsigned ScalarTargetTransformImpl::getJumpBufAlignment() const {
37 return TLI->getJumpBufAlignment();
38 }
39
40 unsigned ScalarTargetTransformImpl::getJumpBufSize() const {
41 return TLI->getJumpBufSize();
42 }
4747 InstrInfo(*this),
4848 TSInfo(*this),
4949 TLInfo(*this),
50 JITInfo(*this) {
50 JITInfo(*this),
51 STTI(&TLInfo) {
5152 }
5253
5354 void X86_64TargetMachine::anchor() { }
6364 InstrInfo(*this),
6465 TSInfo(*this),
6566 TLInfo(*this),
66 JITInfo(*this) {
67 JITInfo(*this),
68 STTI(&TLInfo) {
6769 }
6870
6971 /// X86TargetMachine ctor - Create an X86 target.
2424 #include "llvm/Target/TargetMachine.h"
2525 #include "llvm/DataLayout.h"
2626 #include "llvm/Target/TargetFrameLowering.h"
27 #include "llvm/Target/TargetTransformImpl.h"
2728
2829 namespace llvm {
2930
8485 X86SelectionDAGInfo TSInfo;
8586 X86TargetLowering TLInfo;
8687 X86JITInfo JITInfo;
88 ScalarTargetTransformImpl STTI;
89 VectorTargetTransformImpl VTTI;
8790 public:
8891 X86_32TargetMachine(const Target &T, StringRef TT,
8992 StringRef CPU, StringRef FS, const TargetOptions &Options,
102105 virtual X86JITInfo *getJITInfo() {
103106 return &JITInfo;
104107 }
108 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
109 return &STTI;
110 }
111 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
112 return &VTTI;
113 }
105114 };
106115
107116 /// X86_64TargetMachine - X86 64-bit target machine.
113122 X86SelectionDAGInfo TSInfo;
114123 X86TargetLowering TLInfo;
115124 X86JITInfo JITInfo;
125 ScalarTargetTransformImpl STTI;
126 VectorTargetTransformImpl VTTI;
116127 public:
117128 X86_64TargetMachine(const Target &T, StringRef TT,
118129 StringRef CPU, StringRef FS, const TargetOptions &Options,
131142 virtual X86JITInfo *getJITInfo() {
132143 return &JITInfo;
133144 }
145 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
146 return &STTI;
147 }
148 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
149 return &VTTI;
150 }
134151 };
135152
136153 } // End llvm namespace
3131 InstrInfo(),
3232 FrameLowering(Subtarget),
3333 TLInfo(*this),
34 TSInfo(*this) {
34 TSInfo(*this), STTI(&TLInfo) {
3535 }
3636
3737 namespace {
1919 #include "XCoreISelLowering.h"
2020 #include "XCoreSelectionDAGInfo.h"
2121 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Target/TargetTransformImpl.h"
2223 #include "llvm/DataLayout.h"
2324
2425 namespace llvm {
3031 XCoreFrameLowering FrameLowering;
3132 XCoreTargetLowering TLInfo;
3233 XCoreSelectionDAGInfo TSInfo;
34 ScalarTargetTransformImpl STTI;
35 VectorTargetTransformImpl VTTI;
3336 public:
3437 XCoreTargetMachine(const Target &T, StringRef TT,
3538 StringRef CPU, StringRef FS, const TargetOptions &Options,
5255 virtual const TargetRegisterInfo *getRegisterInfo() const {
5356 return &InstrInfo.getRegisterInfo();
5457 }
58 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
59 return &STTI;
60 }
61 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
62 return &VTTI;
63 }
5564 virtual const DataLayout *getDataLayout() const { return &DL; }
5665
5766 // Pass Pipeline Configuration
3232 PrintModulePass.cpp
3333 Type.cpp
3434 TypeFinder.cpp
35 TargetTransformInfo.cpp
3536 Use.cpp
3637 User.cpp
3738 Value.cpp
0 //===- llvm/VMCore/TargetTransformInfo.cpp ----------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/TargetTransformInfo.h"
10 #include "llvm/Support/ErrorHandling.h"
11
12 using namespace llvm;
13
14 /// Default ctor.
15 ///
16 /// @note This has to exist, because this is a pass, but it should never be
17 /// used.
18 TargetTransformInfo::TargetTransformInfo() : ImmutablePass(ID) {
19 report_fatal_error("Bad TargetTransformInfo ctor used. "
20 "Tool did not specify a TargetTransformInfo to use?");
21 }
22
23 INITIALIZE_PASS(TargetTransformInfo, "TargetTransformInfo",
24 "Target Transform Info", false, true)
25 char TargetTransformInfo::ID = 0;
26
2020 #include "llvm/ADT/Triple.h"
2121 #include "llvm/Assembly/PrintModulePass.h"
2222 #include "llvm/Support/IRReader.h"
23 #include "llvm/CodeGen/CommandFlags.h"
2324 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
2425 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
2526 #include "llvm/MC/SubtargetFeature.h"
6162 static cl::opt
6263 TargetTriple("mtriple", cl::desc("Override target triple for module"));
6364
64 static cl::opt
65 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
66
67 static cl::opt
68 MCPU("mcpu",
69 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
70 cl::value_desc("cpu-name"),
71 cl::init(""));
72
73 static cl::list
74 MAttrs("mattr",
75 cl::CommaSeparated,
76 cl::desc("Target specific attributes (-mattr=help for details)"),
77 cl::value_desc("a1,+a2,-a3,..."));
78
79 static cl::opt
80 RelocModel("relocation-model",
81 cl::desc("Choose relocation model"),
82 cl::init(Reloc::Default),
83 cl::values(
84 clEnumValN(Reloc::Default, "default",
85 "Target default relocation model"),
86 clEnumValN(Reloc::Static, "static",
87 "Non-relocatable code"),
88 clEnumValN(Reloc::PIC_, "pic",
89 "Fully relocatable, position independent code"),
90 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
91 "Relocatable external references, non-relocatable code"),
92 clEnumValEnd));
93
94 static cl::opt
95 CMModel("code-model",
96 cl::desc("Choose code model"),
97 cl::init(CodeModel::Default),
98 cl::values(clEnumValN(CodeModel::Default, "default",
99 "Target default code model"),
100 clEnumValN(CodeModel::Small, "small",
101 "Small code model"),
102 clEnumValN(CodeModel::Kernel, "kernel",
103 "Kernel code model"),
104 clEnumValN(CodeModel::Medium, "medium",
105 "Medium code model"),
106 clEnumValN(CodeModel::Large, "large",
107 "Large code model"),
108 clEnumValEnd));
109
110 static cl::opt
111 RelaxAll("mc-relax-all",
112 cl::desc("When used with filetype=obj, "
113 "relax all fixups in the emitted object file"));
114
115 cl::opt
116 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
117 cl::desc("Choose a file type (not all types are supported by all targets):"),
118 cl::values(
119 clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
120 "Emit an assembly ('.s') file"),
121 clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
122 "Emit a native object ('.o') file"),
123 clEnumValN(TargetMachine::CGFT_Null, "null",
124 "Emit nothing, for performance testing"),
125 clEnumValEnd));
126
12765 cl::opt NoVerify("disable-verify", cl::Hidden,
12866 cl::desc("Do not verify input module"));
12967
130 cl::opt DisableDotLoc("disable-dot-loc", cl::Hidden,
131 cl::desc("Do not use .loc entries"));
132
133 cl::opt DisableCFI("disable-cfi", cl::Hidden,
134 cl::desc("Do not use .cfi_* directives"));
135
136 cl::opt EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
137 cl::desc("Use .file directives with an explicit directory."));
138
139 static cl::opt
140 DisableRedZone("disable-red-zone",
141 cl::desc("Do not emit code that uses the red zone."),
142 cl::init(false));
143
144 static cl::opt
145 EnableFPMAD("enable-fp-mad",
146 cl::desc("Enable less precise MAD instructions to be generated"),
147 cl::init(false));
148
149 static cl::opt
150 DisableFPElim("disable-fp-elim",
151 cl::desc("Disable frame pointer elimination optimization"),
152 cl::init(false));
153
154 static cl::opt
155 DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
156 cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
157 cl::init(false));
158
159 static cl::opt
160 EnableUnsafeFPMath("enable-unsafe-fp-math",
161 cl::desc("Enable optimizations that may decrease FP precision"),
162 cl::init(false));
163
164 static cl::opt
165 EnableNoInfsFPMath("enable-no-infs-fp-math",
166 cl::desc("Enable FP math optimizations that assume no +-Infs"),
167 cl::init(false));
168
169 static cl::opt
170 EnableNoNaNsFPMath("enable-no-nans-fp-math",
171 cl::desc("Enable FP math optimizations that assume no NaNs"),
172 cl::init(false));
173
174 static cl::opt
175 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
176 cl::Hidden,
177 cl::desc("Force codegen to assume rounding mode can change dynamically"),
178 cl::init(false));
179
180 static cl::opt
181 GenerateSoftFloatCalls("soft-float",
182 cl::desc("Generate software floating point library calls"),
183 cl::init(false));
184
185 static cl::opt
186 FloatABIForCalls("float-abi",
187 cl::desc("Choose float ABI type"),
188 cl::init(FloatABI::Default),
189 cl::values(
190 clEnumValN(FloatABI::Default, "default",
191 "Target default float ABI type"),
192 clEnumValN(FloatABI::Soft, "soft",
193 "Soft float ABI (implied by -soft-float)"),
194 clEnumValN(FloatABI::Hard, "hard",
195 "Hard float ABI (uses FP registers)"),
196 clEnumValEnd));
197
198 static cl::opt
199 FuseFPOps("fp-contract",
200 cl::desc("Enable aggresive formation of fused FP ops"),
201 cl::init(FPOpFusion::Standard),
202 cl::values(
203 clEnumValN(FPOpFusion::Fast, "fast",
204 "Fuse FP ops whenever profitable"),
205 clEnumValN(FPOpFusion::Standard, "on",
206 "Only fuse 'blessed' FP ops."),
207 clEnumValN(FPOpFusion::Strict, "off",
208 "Only fuse FP ops when the result won't be effected."),
209 clEnumValEnd));
210
211 static cl::opt
212 DontPlaceZerosInBSS("nozero-initialized-in-bss",
213 cl::desc("Don't place zero-initialized symbols into bss section"),
214 cl::init(false));
215
216 static cl::opt
68 cl::opt
21769 DisableSimplifyLibCalls("disable-simplify-libcalls",
218 cl::desc("Disable simplify-libcalls"),
219 cl::init(false));
220
221 static cl::opt
222 EnableGuaranteedTailCallOpt("tailcallopt",
223 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
224 cl::init(false));
225
226 static cl::opt
227 DisableTailCalls("disable-tail-calls",
228 cl::desc("Never emit tail calls"),
229 cl::init(false));
230
231 static cl::opt
232 OverrideStackAlignment("stack-alignment",
233 cl::desc("Override default stack alignment"),
234 cl::init(0));
235
236 static cl::opt
237 EnableRealignStack("realign-stack",
238 cl::desc("Realign stack if needed"),
239 cl::init(true));
240
241 static cl::opt
242 TrapFuncName("trap-func", cl::Hidden,
243 cl::desc("Emit a call to trap function rather than a trap instruction"),
244 cl::init(""));
245
246 static cl::opt
247 EnablePIE("enable-pie",
248 cl::desc("Assume the creation of a position independent executable."),
249 cl::init(false));
250
251 static cl::opt
252 SegmentedStacks("segmented-stacks",
253 cl::desc("Use segmented stacks if possible."),
254 cl::init(false));
255
256 static cl::opt
257 UseInitArray("use-init-array",
258 cl::desc("Use .init_array instead of .ctors."),
259 cl::init(false));
260
261 static cl::opt StopAfter("stop-after",
262 cl::desc("Stop compilation after a specific pass"),
263 cl::value_desc("pass-name"),
264 cl::init(""));
265 static cl::opt StartAfter("start-after",
266 cl::desc("Resume compilation after a specific pass"),
267 cl::value_desc("pass-name"),
268 cl::init(""));
269
270 static cl::opt
271 SSPBufferSize("stack-protector-buffer-size", cl::init(8),
272 cl::desc("Lower bound for a buffer to be considered for "
273 "stack protection"));
70 cl::desc("Disable simplify-libcalls"),
71 cl::init(false));
27472
27573 // GetFileNameRoot - Helper function to get the basename of a filename.
27674 static inline std::string
504302 TLI->disableAllFunctions();
505303 PM.add(TLI);
506304
305 if (target.get()) {
306 PM.add(new TargetTransformInfo(target->getScalarTargetTransformInfo(),
307 target->getVectorTargetTransformInfo()));
308 }
309
507310 // Add the target data from the target machine, if it exists, or the module.
508311 if (const DataLayout *TD = Target.getDataLayout())
509312 PM.add(new DataLayout(*TD));
370370
371371 // Add an appropriate DataLayout instance for this module...
372372 passes.add(new DataLayout(*_target->getDataLayout()));
373 passes.add(new TargetTransformInfo(_target->getScalarTargetTransformInfo(),
374 _target->getVectorTargetTransformInfo()));
373375
374376 // Enabling internalize here would use its AllButMain variant. It
375377 // keeps only main if it exists and does nothing for libraries. Instead
None set(LLVM_LINK_COMPONENTS bitreader asmparser bitwriter instrumentation scalaropts ipo vectorize)
0 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} bitreader asmparser bitwriter instrumentation scalaropts ipo vectorize)
11
22 add_llvm_tool(opt
33 AnalysisWrappers.cpp
1818 type = Tool
1919 name = opt
2020 parent = Tools
21 required_libraries = AsmParser BitReader BitWriter IPO Instrumentation Scalar
21 required_libraries = AsmParser BitReader BitWriter IPO Instrumentation Scalar all-targets
88
99 LEVEL := ../..
1010 TOOLNAME := opt
11 LINK_COMPONENTS := bitreader bitwriter asmparser instrumentation scalaropts ipo vectorize
11 LINK_COMPONENTS := bitreader bitwriter asmparser instrumentation scalaropts ipo vectorize all-targets
1212
1313 include $(LEVEL)/Makefile.common
1717 #include "llvm/Module.h"
1818 #include "llvm/PassManager.h"
1919 #include "llvm/CallGraphSCCPass.h"
20 #include "llvm/CodeGen/CommandFlags.h"
2021 #include "llvm/Bitcode/ReaderWriter.h"
2122 #include "llvm/Assembly/PrintModulePass.h"
2223 #include "llvm/Analysis/Verifier.h"
3536 #include "llvm/Support/PluginLoader.h"
3637 #include "llvm/Support/PrettyStackTrace.h"
3738 #include "llvm/Support/SystemUtils.h"
39 #include "llvm/Support/TargetRegistry.h"
3840 #include "llvm/Support/ToolOutputFile.h"
41 #include "llvm/MC/SubtargetFeature.h"
3942 #include "llvm/LinkAllPasses.h"
4043 #include "llvm/LinkAllVMCore.h"
4144 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
477480 /*RunInliner=*/ !DisableInline);
478481 }
479482
483 //===----------------------------------------------------------------------===//
484 // CodeGen-related helper functions.
485 //
486 static TargetOptions GetTargetOptions() {
487 TargetOptions Options;
488 Options.LessPreciseFPMADOption = EnableFPMAD;
489 Options.NoFramePointerElim = DisableFPElim;
490 Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
491 Options.AllowFPOpFusion = FuseFPOps;
492 Options.UnsafeFPMath = EnableUnsafeFPMath;
493 Options.NoInfsFPMath = EnableNoInfsFPMath;
494 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
495 Options.HonorSignDependentRoundingFPMathOption =
496 EnableHonorSignDependentRoundingFPMath;
497 Options.UseSoftFloat = GenerateSoftFloatCalls;
498 if (FloatABIForCalls != FloatABI::Default)
499 Options.FloatABIType = FloatABIForCalls;
500 Options.NoZerosInBSS = DontPlaceZerosInBSS;
501 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
502 Options.DisableTailCalls = DisableTailCalls;
503 Options.StackAlignmentOverride = OverrideStackAlignment;
504 Options.RealignStack = EnableRealignStack;
505 Options.TrapFuncName = TrapFuncName;
506 Options.PositionIndependentExecutable = EnablePIE;
507 Options.EnableSegmentedStacks = SegmentedStacks;
508 Options.UseInitArray = UseInitArray;
509 Options.SSPBufferSize = SSPBufferSize;
510 return Options;
511 }
512
513 CodeGenOpt::Level GetCodeGenOptLevel() {
514 if (OptLevelO1)
515 return CodeGenOpt::Less;
516 if (OptLevelO2)
517 return CodeGenOpt::Default;
518 if (OptLevelO3)
519 return CodeGenOpt::Aggressive;
520 return CodeGenOpt::None;
521 }
522
523 // Returns the TargetMachine instance or zero if no triple is provided.
524 static TargetMachine* GetTargetMachine(std::string TripleStr) {
525 if (TripleStr.empty())
526 return 0;
527
528 // Get the target specific parser.
529 std::string Error;
530 Triple TheTriple(Triple::normalize(TargetTriple));
531
532 const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
533 Error);
534 if (!TheTarget) {
535 return 0;
536 }
537
538 // Package up features to be passed to target/subtarget
539 std::string FeaturesStr;
540 if (MAttrs.size()) {
541 SubtargetFeatures Features;
542 for (unsigned i = 0; i != MAttrs.size(); ++i)
543 Features.AddFeature(MAttrs[i]);
544 FeaturesStr = Features.getString();
545 }
546
547 return TheTarget->createTargetMachine(TheTriple.getTriple(),
548 MCPU, FeaturesStr, GetTargetOptions(),
549 RelocModel, CMModel,
550 GetCodeGenOptLevel());
551 }
480552
481553 //===----------------------------------------------------------------------===//
482554 // main for opt
577649
578650 if (TD)
579651 Passes.add(TD);
652
653 std::auto_ptr TM(GetTargetMachine(TargetTriple));
654 if (TM.get()) {
655 Passes.add(new TargetTransformInfo(TM->getScalarTargetTransformInfo(),
656 TM->getVectorTargetTransformInfo()));
657 }
580658
581659 OwningPtr FPasses;
582660 if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {