llvm.org GIT mirror llvm / 578a1d2
Fix some Include What You Use warnings in examples; other minor fixes. Differential revision: http://reviews.llvm.org/D20607 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270645 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 4 years ago
9 changed file(s) with 115 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
None //===-- BrainF.cpp - BrainF compiler example ----------------------------===//
0 //===-- BrainF.cpp - BrainF compiler example ------------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file is distributed under the University of Illinois Open Source
55 // License. See LICENSE.TXT for details.
66 //
7 //===--------------------------------------------------------------------===//
7 //===----------------------------------------------------------------------===//
88 //
99 // This class compiles the BrainF language into LLVM assembly.
1010 //
2020 // [ while(*h) { Start loop
2121 // ] } End loop
2222 //
23 //===--------------------------------------------------------------------===//
23 //===----------------------------------------------------------------------===//
2424
2525 #include "BrainF.h"
26 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/APInt.h"
27 #include "llvm/IR/BasicBlock.h"
28 #include "llvm/IR/Constant.h"
2729 #include "llvm/IR/Constants.h"
30 #include "llvm/IR/DerivedTypes.h"
31 #include "llvm/IR/Function.h"
32 #include "llvm/IR/GlobalValue.h"
33 #include "llvm/IR/GlobalVariable.h"
34 #include "llvm/IR/InstrTypes.h"
35 #include "llvm/IR/Instruction.h"
2836 #include "llvm/IR/Instructions.h"
2937 #include "llvm/IR/Intrinsics.h"
38 #include "llvm/IR/Module.h"
39 #include "llvm/IR/Type.h"
40 #include "llvm/Support/Casting.h"
41 #include
3042 #include
3143
3244 using namespace llvm;
None //===-- BrainF.h - BrainF compiler class ----------------------*- C++ -*-===//
0 //===-- BrainF.h - BrainF compiler class ------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file is distributed under the University of Illinois Open Source
55 // License. See LICENSE.TXT for details.
66 //
7 //===--------------------------------------------------------------------===//
7 //===----------------------------------------------------------------------===//
88 //
99 // This class stores the data for the BrainF compiler so it doesn't have
1010 // to pass all of it around. The main method is parse.
1111 //
12 //===--------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
1313
1414 #ifndef BRAINF_H
1515 #define BRAINF_H
1717 #include "llvm/IR/IRBuilder.h"
1818 #include "llvm/IR/LLVMContext.h"
1919 #include "llvm/IR/Module.h"
20 #include
2021
2122 using namespace llvm;
2223
9091 Value *curhead;
9192 };
9293
93 #endif
94 #endif // BRAINF_H
None //===-- BrainFDriver.cpp - BrainF compiler driver -----------------------===//
0 //===-- BrainFDriver.cpp - BrainF compiler driver -------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
44 // This file is distributed under the University of Illinois Open Source
55 // License. See LICENSE.TXT for details.
66 //
7 //===--------------------------------------------------------------------===//
7 //===----------------------------------------------------------------------===//
88 //
99 // This program converts the BrainF language into LLVM assembly,
1010 // which it can then run using the JIT or output as BitCode.
2121 //
2222 // lli prog.bf.bc #Run generated BitCode
2323 //
24 //===--------------------------------------------------------------------===//
24 //===----------------------------------------------------------------------===//
2525
2626 #include "BrainF.h"
27 #include "llvm/ADT/APInt.h"
2728 #include "llvm/Bitcode/ReaderWriter.h"
2829 #include "llvm/ExecutionEngine/ExecutionEngine.h"
2930 #include "llvm/ExecutionEngine/GenericValue.h"
31 #include "llvm/IR/BasicBlock.h"
3032 #include "llvm/IR/Constants.h"
33 #include "llvm/IR/DerivedTypes.h"
34 #include "llvm/IR/Function.h"
35 #include "llvm/IR/Instructions.h"
36 #include "llvm/IR/LLVMContext.h"
37 #include "llvm/IR/Module.h"
38 #include "llvm/IR/Value.h"
3139 #include "llvm/IR/Verifier.h"
40 #include "llvm/Support/Casting.h"
3241 #include "llvm/Support/CommandLine.h"
3342 #include "llvm/Support/FileSystem.h"
3443 #include "llvm/Support/ManagedStatic.h"
3544 #include "llvm/Support/TargetSelect.h"
3645 #include "llvm/Support/raw_ostream.h"
46 #include
47 #include
3748 #include
3849 #include
50 #include
51 #include
52 #include
53 #include
54
3955 using namespace llvm;
4056
4157 //Command line options
5167
5268 static cl::opt
5369 JIT("jit", cl::desc("Run program Just-In-Time"));
54
5570
5671 //Add main function so can be fully compiled
5772 void addMainFunction(Module *mod) {
2222 //
2323 //===----------------------------------------------------------------------===//
2424
25 #include "llvm/ADT/APInt.h"
2526 #include "llvm/IR/Verifier.h"
27 #include "llvm/ExecutionEngine/ExecutionEngine.h"
2628 #include "llvm/ExecutionEngine/GenericValue.h"
27 #include "llvm/ExecutionEngine/Interpreter.h"
29 #include "llvm/IR/Argument.h"
30 #include "llvm/IR/BasicBlock.h"
2831 #include "llvm/IR/Constants.h"
2932 #include "llvm/IR/DerivedTypes.h"
33 #include "llvm/IR/Function.h"
34 #include "llvm/IR/InstrTypes.h"
3035 #include "llvm/IR/Instructions.h"
3136 #include "llvm/IR/LLVMContext.h"
3237 #include "llvm/IR/Module.h"
38 #include "llvm/IR/Type.h"
39 #include "llvm/Support/Casting.h"
3340 #include "llvm/Support/TargetSelect.h"
3441 #include "llvm/Support/raw_ostream.h"
42 #include
43 #include
44 #include
45 #include
46 #include
3547
3648 using namespace llvm;
3749
7587 Sub = BinaryOperator::CreateSub(ArgX, Two, "arg", RecurseBB);
7688 CallInst *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB);
7789 CallFibX2->setTailCall();
78
7990
8091 // fib(x-1)+fib(x-2)
8192 Value *Sum = BinaryOperator::CreateAdd(CallFibX1, CallFibX2,
3434 //===----------------------------------------------------------------------===//
3535
3636 #include "llvm/ADT/STLExtras.h"
37 #include "llvm/ExecutionEngine/ExecutionEngine.h"
3738 #include "llvm/ExecutionEngine/GenericValue.h"
38 #include "llvm/ExecutionEngine/Interpreter.h"
39 #include "llvm/IR/Argument.h"
40 #include "llvm/IR/BasicBlock.h"
3941 #include "llvm/IR/Constants.h"
4042 #include "llvm/IR/DerivedTypes.h"
43 #include "llvm/IR/Function.h"
4144 #include "llvm/IR/IRBuilder.h"
4245 #include "llvm/IR/Instructions.h"
4346 #include "llvm/IR/LLVMContext.h"
4447 #include "llvm/IR/Module.h"
48 #include "llvm/IR/Type.h"
49 #include "llvm/Support/Casting.h"
4550 #include "llvm/Support/ManagedStatic.h"
4651 #include "llvm/Support/TargetSelect.h"
4752 #include "llvm/Support/raw_ostream.h"
53 #include
54 #include
55 #include
56 #include
4857
4958 using namespace llvm;
5059
5160 int main() {
52
5361 InitializeNativeTarget();
5462
5563 LLVMContext Context;
1313 #ifndef LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1414 #define LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1515
16 #include "llvm/ADT/STLExtras.h"
1617 #include "llvm/ExecutionEngine/ExecutionEngine.h"
17 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
18 #include "llvm/ExecutionEngine/RuntimeDyld.h"
19 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
1820 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
21 #include "llvm/ExecutionEngine/Orc/JITSymbol.h"
1922 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2023 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2124 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
25 #include "llvm/IR/DataLayout.h"
2226 #include "llvm/IR/Mangler.h"
2327 #include "llvm/Support/DynamicLibrary.h"
28 #include "llvm/Support/raw_ostream.h"
29 #include "llvm/Target/TargetMachine.h"
30 #include
31 #include
32 #include
33 #include
2434
2535 namespace llvm {
2636 namespace orc {
2737
2838 class KaleidoscopeJIT {
2939 private:
30
3140 std::unique_ptr TM;
3241 const DataLayout DL;
3342 ObjectLinkingLayer<> ObjectLayer;
3443 IRCompileLayer CompileLayer;
3544
3645 public:
37
3846 typedef decltype(CompileLayer)::ModuleSetHandleT ModuleHandle;
3947
4048 KaleidoscopeJIT()
7684
7785 };
7886
79 } // End namespace orc.
80 } // End namespace llvm
87 } // end namespace orc
88 } // end namespace llvm
8189
8290 #endif // LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1313 #ifndef LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1414 #define LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1515
16 #include "llvm/ADT/iterator_range.h"
17 #include "llvm/ADT/STLExtras.h"
1618 #include "llvm/ExecutionEngine/ExecutionEngine.h"
19 #include "llvm/ExecutionEngine/JITSymbolFlags.h"
1720 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
21 #include "llvm/ExecutionEngine/RuntimeDyld.h"
22 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
1823 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
24 #include "llvm/ExecutionEngine/Orc/JITSymbol.h"
1925 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2026 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2127 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
28 #include "llvm/IR/DataLayout.h"
2229 #include "llvm/IR/Mangler.h"
2330 #include "llvm/Support/DynamicLibrary.h"
31 #include "llvm/Support/raw_ostream.h"
32 #include "llvm/Target/TargetMachine.h"
33 #include
34 #include
35 #include
36 #include
2437
2538 namespace llvm {
2639 namespace orc {
6982 }
7083
7184 private:
72
7385 std::string mangle(const std::string &Name) {
7486 std::string MangledName;
7587 {
107119 std::vector ModuleHandles;
108120 };
109121
110 } // End namespace orc.
111 } // End namespace llvm
122 } // end namespace orc
123 } // end namespace llvm
112124
113125 #endif // LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1313 //===----------------------------------------------------------------------===//
1414
1515 #include "llvm/Bitcode/ReaderWriter.h"
16 #include "llvm/IR/BasicBlock.h"
1617 #include "llvm/IR/Constants.h"
1718 #include "llvm/IR/DerivedTypes.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/InstrTypes.h"
21 #include "llvm/IR/Instruction.h"
1822 #include "llvm/IR/Instructions.h"
1923 #include "llvm/IR/LLVMContext.h"
2024 #include "llvm/IR/Module.h"
25 #include "llvm/IR/Type.h"
2126 #include "llvm/Support/raw_ostream.h"
27
2228 using namespace llvm;
2329
2430 int main() {
1515 // wakes them up. This complicated work is performed so that all three threads
1616 // call into the JIT at the same time (or the best possible approximation of the
1717 // same time). This test had assertion errors until I got the locking right.
18
18 //
19 //===----------------------------------------------------------------------===//
20
21 #include "llvm/ADT/APInt.h"
1922 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ExecutionEngine/ExecutionEngine.h"
2024 #include "llvm/ExecutionEngine/GenericValue.h"
21 #include "llvm/ExecutionEngine/Interpreter.h"
25 #include "llvm/IR/Argument.h"
26 #include "llvm/IR/BasicBlock.h"
2227 #include "llvm/IR/Constants.h"
2328 #include "llvm/IR/DerivedTypes.h"
29 #include "llvm/IR/Function.h"
30 #include "llvm/IR/InstrTypes.h"
31 #include "llvm/IR/Instruction.h"
2432 #include "llvm/IR/Instructions.h"
2533 #include "llvm/IR/LLVMContext.h"
2634 #include "llvm/IR/Module.h"
35 #include "llvm/IR/Type.h"
36 #include "llvm/Support/Casting.h"
2737 #include "llvm/Support/TargetSelect.h"
38 #include
39 #include
40 #include
41 #include
2842 #include
43 #include
44 #include
2945 #include
3046
3147 using namespace llvm;