llvm.org GIT mirror llvm / 7107c3b
For PR780: 1. Move IncludeFile.h to System library 2. Move IncludeFile.cpp to System library 3. #1 and #2 required to prevent cyclic library dependencies for libSystem 4. Convert all existing uses of Support/IncludeFile.h to System/IncludeFile.h 5. Add IncludeFile support to various lib/System classes. 6. Add new lib/System classes to LinkAllVMCore.h All this in an attempt to pull in lib/System to what's required for VMCore git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29287 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 14 years ago
23 changed file(s) with 65 addition(s) and 106 deletion(s). Raw diff Collapse all Expand all
3030 #define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
3131
3232 #include "llvm/Support/CallSite.h"
33 #include "llvm/Support/IncludeFile.h"
33 #include "llvm/System/IncludeFile.h"
3434
3535 namespace llvm {
3636
1616 #define LLVM_INLINEASM_H
1717
1818 #include "llvm/Value.h"
19 #include "llvm/Support/IncludeFile.h"
19 #include "llvm/System/IncludeFile.h"
2020 #include
2121
2222 namespace llvm {
2727 #include "llvm/Function.h"
2828 #include "llvm/Instructions.h"
2929 #include "llvm/Intrinsics.h"
30 #include "llvm/Support/IncludeFile.h"
30 #include "llvm/System/IncludeFile.h"
3131
3232 namespace llvm {
3333 /// IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic
1515 #ifndef LLVM_LINKALLVMCORE_H
1616 #define LLVM_LINKALLVMCORE_H
1717
18 #include "llvm/Support/IncludeFile.h"
19 #include "llvm/Support/Mangler.h"
18 #include "llvm/System/IncludeFile.h"
19
2020 #include "llvm/Module.h"
2121 #include "llvm/Instructions.h"
2222 #include "llvm/IntrinsicInst.h"
2323 #include "llvm/InlineAsm.h"
2424 #include "llvm/Analysis/Verifier.h"
25 #include "llvm/System/Memory.h"
26 #include "llvm/System/Mutex.h"
27 #include "llvm/Support/Dwarf.h"
28 #include "llvm/Support/Mangler.h"
29 #include "llvm/Support/MathExtras.h"
30 #include "llvm/Support/SlowOperationInformer.h"
2531
2632 namespace {
2733 struct ForceVMCoreLinking {
2020 #ifndef LLVM_PASS_SUPPORT_H
2121 #define LLVM_PASS_SUPPORT_H
2222
23 #include "llvm/Support/IncludeFile.h"
23 #include "llvm/System/IncludeFile.h"
2424 // No need to include Pass.h, we are being included by it!
2525
2626 namespace llvm {
1414
1515 #ifndef LLVM_SUPPORT_DWARF_H
1616 #define LLVM_SUPPORT_DWARF_H
17
18 #include "llvm/System/IncludeFile.h"
1719
1820 namespace llvm {
1921
545547
546548 } // End of namespace llvm
547549
550 FORCE_DEFINING_FILE_TO_BE_LINKED(SupportDwarf)
551
548552 #endif
+0
-65
include/llvm/Support/IncludeFile.h less more
None //===- llvm/Support/IncludeFile.h - Ensure Linking Of Library ---*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by Reid Spencer and is distributed under the
5 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the FORCE_DEFINING_FILE_TO_BE_LINKED and DEFINE_FILE_FOR
10 // macros.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SUPPORT_INCLUDEFILE_H
15 #define LLVM_SUPPORT_INCLUDEFILE_H
16
17 /// This macro is the public interface that IncludeFile.h exports. This gives
18 /// us the option to implement the "link the definition" capability in any
19 /// manner that we choose. All header files that depend on a specific .cpp
20 /// file being linked at run time should use this macro instead of the
21 /// IncludeFile class directly.
22 ///
23 /// For example, foo.h would use:
24 /// FORCE_DEFINING_FILE_TO_BE_LINKED(foo)
25 ///
26 /// And, foo.cp would use:
27 /// DEFINING_FILE_FOR(foo)
28 #define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \
29 namespace llvm { \
30 extern char name ## LinkVar; \
31 static IncludeFile name ## LinkObj ( &name ## LinkVar ); \
32 }
33
34 /// This macro is the counterpart to FORCE_DEFINING_FILE_TO_BE_LINKED. It should
35 /// be used in a .cpp file to define the name referenced in a header file that
36 /// will cause linkage of the .cpp file. It should only be used at extern level.
37 #define DEFINING_FILE_FOR(name) namespace llvm { char name ## LinkVar; }
38
39 namespace llvm {
40
41 /// This class is used in the implementation of FORCE_DEFINING_FILE_TO_BE_LINKED
42 /// macro to make sure that the implementation of a header file is included
43 /// into a tool that uses the header. This is solely
44 /// to overcome problems linking .a files and not getting the implementation
45 /// of compilation units we need. This is commonly an issue with the various
46 /// Passes but also occurs elsewhere in LLVM. We like to use .a files because
47 /// they link faster and provide the smallest executables. However, sometimes
48 /// those executables are too small, if the program doesn't reference something
49 /// that might be needed, especially by a loaded share object. This little class
50 /// helps to resolve that problem. The basic strategy is to use this class in
51 /// a header file and pass the address of a variable to the constructor. If the
52 /// variable is defined in the header file's corresponding .cpp file then all
53 /// tools/libraries that #include the header file will require the .cpp as well.
54 /// For example:
55 /// extern int LinkMyCodeStub;
56 /// static IncludeFile LinkMyModule(&LinkMyCodeStub);
57 /// @brief Class to ensure linking of corresponding object file.
58 struct IncludeFile {
59 IncludeFile(void *);
60 };
61
62 }
63
64 #endif
1313 #ifndef LLVM_SUPPORT_MANGLER_H
1414 #define LLVM_SUPPORT_MANGLER_H
1515
16 #include "llvm/Support/IncludeFile.h"
16 #include "llvm/System/IncludeFile.h"
1717 #include
1818 #include
1919 #include
1414 #define LLVM_SUPPORT_MATHEXTRAS_H
1515
1616 #include "llvm/Support/DataTypes.h"
17 #include "llvm/System/IncludeFile.h"
1718
1819 namespace llvm {
1920
305306
306307 } // End llvm namespace
307308
308 #endif
309 FORCE_DEFINING_FILE_TO_BE_LINKED(SupportIsInf)
310 FORCE_DEFINING_FILE_TO_BE_LINKED(SupportIsNAN)
311
312 #endif
3131 #include
3232 #include
3333 #include "llvm/Support/DataTypes.h"
34 #include "llvm/System/IncludeFile.h"
3435
3536 namespace llvm {
3637 class SlowOperationInformer {
6263 } // end namespace llvm
6364
6465 #endif /* SLOW_OPERATION_INFORMER_H */
66
67 FORCE_DEFINING_FILE_TO_BE_LINKED(SupportSlowOperationInformer)
None //===- llvm/Support/IncludeFile.h - Ensure Linking Of Library ---*- C++ -*-===//
0 //===- llvm/System/IncludeFile.h - Ensure Linking Of Library ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #ifndef LLVM_SUPPORT_INCLUDEFILE_H
15 #define LLVM_SUPPORT_INCLUDEFILE_H
14 #ifndef LLVM_SYSTEM_INCLUDEFILE_H
15 #define LLVM_SYSTEM_INCLUDEFILE_H
1616
1717 /// This macro is the public interface that IncludeFile.h exports. This gives
1818 /// us the option to implement the "link the definition" capability in any
1414 #define LLVM_SYSTEM_MEMORY_H
1515
1616 #include
17 #include "llvm/System/IncludeFile.h"
1718
1819 namespace llvm {
1920 namespace sys {
6970 }
7071 }
7172
73 FORCE_DEFINING_FILE_TO_BE_LINKED(SystemMemory)
74
7275 #endif
1212
1313 #ifndef LLVM_SYSTEM_MUTEX_H
1414 #define LLVM_SYSTEM_MUTEX_H
15
16 #include "llvm/System/IncludeFile.h"
1517
1618 namespace llvm
1719 {
8082 }
8183 }
8284
85 FORCE_DEFINING_FILE_TO_BE_LINKED(SystemMutex)
86
8387 #endif
99 LIBRARYNAME = LLVMSelectionDAG
1010 PARALLEL_DIRS =
1111 BUILD_ARCHIVE = 1
12 DONT_BUILD_RELINKED = 1
1213
1314 include $(LEVEL)/Makefile.common
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/Dwarf.h"
14 #include "llvm/System/IncludeFile.h"
1415
1516 #include
1617
579580 } // End of namespace dwarf.
580581
581582 } // End of namespace llvm.
583
584 DEFINING_FILE_FOR(SupportDwarf)
+0
-20
lib/Support/IncludeFile.cpp less more
None //===- lib/Support/IncludeFile.cpp - Ensure Linking Of Implementation -----===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by Reid Spencer and is distributed under the
5 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the IncludeFile constructor.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/Support/IncludeFile.h"
14
15 using namespace llvm;
16
17 // This constructor is used to ensure linking of other modules. See the
18 // llvm/Support/IncludeFile.h header for details.
19 IncludeFile::IncludeFile(void*) {}
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/Config/config.h"
10 #include "llvm/System/IncludeFile.h"
1011
1112 #if HAVE_ISINF_IN_MATH_H
1213 # include
4243 int IsInf (double d) { return isinf (d); }
4344
4445 } // end namespace llvm;
46
47 DEFINING_FILE_FOR(SupportIsInf)
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Config/config.h"
14 #include "llvm/System/IncludeFile.h"
15
1416 #if HAVE_ISNAN_IN_MATH_H
1517 # include
1618 #elif HAVE_ISNAN_IN_CMATH
3133 int IsNAN (double d) { return isnan (d); }
3234
3335 } // end namespace llvm;
36
37 DEFINING_FILE_FOR(SupportIsNAN)
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/SlowOperationInformer.h"
14 #include "llvm/System/IncludeFile.h"
1415 #include "llvm/System/Alarm.h"
1516 #include
1617 #include
6364 std::cout << ToPrint+OS.str() << std::flush;
6465 return false;
6566 }
67
68 DEFINING_FILE_FOR(SupportSlowOperationInformer)
None //===- lib/Support/IncludeFile.cpp - Ensure Linking Of Implementation -----===//
0 //===- lib/System/IncludeFile.cpp - Ensure Linking Of Implementation -----===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/Support/IncludeFile.h"
13 #include "llvm/System/IncludeFile.h"
1414
1515 using namespace llvm;
1616
1717 // This constructor is used to ensure linking of other modules. See the
18 // llvm/Support/IncludeFile.h header for details.
18 // llvm/System/IncludeFile.h header for details.
1919 IncludeFile::IncludeFile(void*) {}
1313
1414 #include "llvm/System/Memory.h"
1515 #include "llvm/Config/config.h"
16 #include "llvm/System/IncludeFile.h"
1617
1718 namespace llvm {
1819 using namespace sys;
3233 #include "Win32/Memory.inc"
3334 #endif
3435
36 DEFINING_FILE_FOR(SystemMemory)
1212
1313 #include "llvm/Config/config.h"
1414 #include "llvm/System/Mutex.h"
15 #include "llvm/System/IncludeFile.h"
1516
1617 //===----------------------------------------------------------------------===//
1718 //=== WARNING: Implementation here must contain only TRULY operating system
156157 #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in System/Mutex.cpp
157158 #endif
158159 #endif
160
161 DEFINING_FILE_FOR(SystemMutex)
104104 // returning back to the pass manager, or else the pass manager may try to
105105 // run other passes on the broken module.
106106 if (RealPass)
107 abortIfBroken();
107 return abortIfBroken();
108108 return false;
109109 }
110110
118118 // returning back to the pass manager, or else the pass manager may try to
119119 // run other passes on the broken module.
120120 if (RealPass)
121 abortIfBroken();
121 return abortIfBroken();
122122
123123 return false;
124124 }
137137 visitGlobalVariable(*I);
138138
139139 // If the module is broken, abort at this time.
140 abortIfBroken();
141 return false;
140 return abortIfBroken();
142141 }
143142
144143 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
150149 /// abortIfBroken - If the module is broken and we are supposed to abort on
151150 /// this condition, do so.
152151 ///
153 void abortIfBroken() {
152 bool abortIfBroken() {
154153 if (Broken) {
155154 msgs << "Broken module found, ";
156155 switch (action) {
161160 case PrintMessageAction:
162161 msgs << "verification continues.\n";
163162 std::cerr << msgs.str();
164 break;
163 return false;
165164 case ReturnStatusAction:
166 break;
165 msgs << "compilation terminated.\n";
166 return Broken;
167167 }
168168 }
169 return false;
169170 }
170171
171172