Skip to content

Commit 278be39

Browse files
authored
Merge pull request #18 from akyrtzi/import-new-llvm
[llvm] Import new LLVM support files
2 parents 094eeca + 949c024 commit 278be39

File tree

210 files changed

+11431
-3451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+11431
-3451
lines changed

Utilities/import-llvm

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# NOTE: We have slightly modified copies of some of the files, to reduce the
66
# dependency surface area, so if you run this to update the sources, please
7-
# examine the diffs to remove things that don't make sense.
7+
# examine the diffs to remove things that don't make sense and update 'llvm-patch.diff'.
88

99
import errno
1010
import optparse
@@ -19,7 +19,7 @@ ADT_imports = ['EpochTracker', 'iterator', 'iterator_range', 'Hashing', 'None',
1919
'Statistic', 'StringExtras', 'STLExtras', 'AllocatorList', 'Triple']
2020

2121
# ADT basic data structures.
22-
ADT_imports += ['APFloat', 'APInt', 'APSInt', 'ArrayRef', 'PointerIntPair', 'SetVector', 'StringRef', 'StringSwitch',
22+
ADT_imports += ['APFloat', 'APInt', 'APSInt', 'ArrayRef', 'bit', 'PointerIntPair', 'SetVector', 'StringRef', 'StringSwitch',
2323
'Twine', 'IntrusiveRefCntPtr', 'ilist', 'ilist_base', 'ilist_node', 'ilist_node_base',
2424
'ilist_node_options', 'ilist_iterator', 'simple_ilist', 'OptionSet', 'PointerUnion']
2525

@@ -35,11 +35,11 @@ ADT_imports += ['edit_distance']
3535
# Support types and infrastructure.
3636
Support_imports = [
3737
'AlignOf', 'Allocator', 'Atomic', 'CBindingWrapping', 'Casting', 'Capacity', 'CommandLine', 'Compiler',
38-
'Endian', 'Errno', 'ErrorHandling', 'Errc', 'ErrorOr', 'Error', 'Format',
38+
'Endian', 'Errno', 'ErrorHandling', 'Errc', 'ErrorOr', 'Error', 'Format', 'FormatAdapters',
3939
'ManagedStatic', 'MathExtras', 'Mutex', 'MutexGuard', 'Memory',
4040
'MemoryBuffer', 'PointerLikeTypeTraits', 'Recycler', 'SwapByteOrder',
4141
'Timer', 'TimeValue', 'Threading', 'Unicode', 'UniqueLock', 'Unix', 'WindowsError',
42-
'Valgrind', 'circular_raw_ostream', 'raw_ostream', 'type_traits', 'JSON']
42+
'Valgrind', 'circular_raw_ostream', 'raw_ostream', 'Signposts', 'type_traits', 'JSON']
4343

4444
# Stuff we don't want, but have to pull in.
4545
Support_imports += [
@@ -49,23 +49,24 @@ Support_imports += [
4949
'MemAlloc', 'Chrono', 'FormatProviders', 'FormatVariadic', 'FormatCommon',
5050
'FormatVariadicDetails', 'NativeFormatting', 'DJB', 'ReverseIteration', 'MD5',
5151
'SmallVectorMemoryBuffer', 'WithColor', 'Options', 'PrettyStackTrace', 'Watchdog',
52-
'TargetParser', 'ARMBuildAttributes', 'ARMTargetParser.def', 'AArch64TargetParser.def', 'X86TargetParser.def', 'LineIterator']
52+
'TargetParser', 'ARMBuildAttributes', 'ARMTargetParser', 'AArch64TargetParser',
53+
'ARMTargetParser.def', 'AArch64TargetParser.def', 'X86TargetParser.def', 'LineIterator']
5354

5455
# Dependencies from llvm-c needed by Support.
55-
C_imports = ['Types', 'DataTypes', 'Support', 'ErrorHandling']
56+
C_imports = ['Types', 'DataTypes', 'Support', 'Error', 'ErrorHandling']
5657

5758
# Support data structures.
5859
Support_imports += ['YAMLParser', 'YAMLTraits']
5960

6061
# Source files to exclude.
61-
Support_source_excludes = set(['Host'])
62+
Support_source_excludes = set([])
6263

6364
llvm_srcroot = None
64-
sourcekit_srcroot = None
65+
indexstoredb_srcroot = None
6566

6667
def note(msg):
6768
msg = msg.replace(llvm_srcroot, "<LLVM>")
68-
msg = msg.replace(sourcekit_srcroot, "<INDEXSTOREDB>")
69+
msg = msg.replace(indexstoredb_srcroot, "<INDEXSTOREDB>")
6970
print >>sys.stderr, "note: %s" % (msg,)
7071

7172
def mkdir_p(path):
@@ -133,32 +134,32 @@ def main():
133134
if len(args) != 1:
134135
parser.error("unexpected number of arguments")
135136

136-
global llvm_srcroot, sourcekit_srcroot
137+
global llvm_srcroot, indexstoredb_srcroot
137138
llvm_srcroot, = args
138-
sourcekit_srcroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
139+
indexstoredb_srcroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
139140

140141
def import_header(dir, name):
141142
src = os.path.join(llvm_srcroot, 'include', 'llvm', dir, name)
142143
if os.path.exists(src):
143-
dst = os.path.join(sourcekit_srcroot, 'include', 'llvm', dir, name)
144+
dst = os.path.join(indexstoredb_srcroot, 'include', 'llvm', dir, name)
144145
mkdir_p(os.path.dirname(dst))
145146
copyfile(src, dst)
146147

147148
def import_c_header(name):
148149
src = os.path.join(llvm_srcroot, 'include', 'llvm-c', name)
149150
if os.path.exists(src):
150-
dst = os.path.join(sourcekit_srcroot, 'include', 'llvm-c', name)
151+
dst = os.path.join(indexstoredb_srcroot, 'include', 'llvm-c', name)
151152
mkdir_p(os.path.dirname(dst))
152153
copyfile(src, dst)
153154

154155
def import_source(dir, name):
155156
src = os.path.join(llvm_srcroot, 'lib', dir, name)
156157
if os.path.exists(src):
157-
dst = os.path.join(sourcekit_srcroot, 'lib', 'LLVMSupport', dir, name)
158+
dst = os.path.join(indexstoredb_srcroot, 'lib', 'LLVMSupport', dir, name)
158159
mkdir_p(os.path.dirname(dst))
159160
copyfile(src, dst)
160161

161-
print "note: importing from %r to %r" % (llvm_srcroot, sourcekit_srcroot)
162+
print "note: importing from %r to %r" % (llvm_srcroot, indexstoredb_srcroot)
162163

163164
for name in ADT_imports:
164165
import_header('ADT', name+'.h')
@@ -175,6 +176,8 @@ def main():
175176
import_source('Support', name+'.cpp')
176177
import_source('Support', os.path.join('Unix', name+'.h'))
177178
import_source('Support', os.path.join('Unix', name+'.inc'))
179+
import_source('Support', os.path.join('Windows', name+'.h'))
180+
import_source('Support', os.path.join('Windows', name+'.inc'))
178181

179182
for name in C_imports:
180183
import_c_header(name + '.h')
@@ -183,17 +186,23 @@ def main():
183186
print "Adding prefix header includes"
184187

185188
base_dirs = [
186-
os.path.join(sourcekit_srcroot, 'include', 'llvm'),
187-
os.path.join(sourcekit_srcroot, 'include', 'llvm-c'),
188-
os.path.join(sourcekit_srcroot, 'lib', 'LLVMSupport'),
189+
os.path.join(indexstoredb_srcroot, 'include', 'llvm'),
190+
os.path.join(indexstoredb_srcroot, 'include', 'llvm-c'),
191+
os.path.join(indexstoredb_srcroot, 'lib', 'LLVMSupport'),
189192
]
190193

191-
include_dir = os.path.join(sourcekit_srcroot, 'include')
194+
include_dir = os.path.join(indexstoredb_srcroot, 'include')
192195

193196
for base in base_dirs:
194197
for root, dirs, files in os.walk(base):
195198
for file in files:
196199
maybe_add_prefix(os.path.join(root, file), include_dir)
197200

201+
print ""
202+
print "Applying patch"
203+
204+
patch_path = os.path.join(indexstoredb_srcroot, 'Utilities', 'llvm-patch.diff'),
205+
subprocess.call("patch -p1 < '%s'" % patch_path, shell=True)
206+
198207
if __name__ == '__main__':
199208
main()

Utilities/llvm-patch.diff

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git a/lib/LLVMSupport/Support/AArch64TargetParser.cpp b/lib/LLVMSupport/Support/AArch64TargetParser.cpp
2+
index faf8385c..8772d213 100644
3+
--- a/lib/LLVMSupport/Support/AArch64TargetParser.cpp
4+
+++ b/lib/LLVMSupport/Support/AArch64TargetParser.cpp
5+
@@ -31,7 +31,7 @@ unsigned AArch64::getDefaultFPU(StringRef CPU, AArch64::ArchKind AK) {
6+
return StringSwitch<unsigned>(CPU)
7+
#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
8+
.Case(NAME, ARM::DEFAULT_FPU)
9+
-#include "../../include/llvm/Support/AArch64TargetParser.def"
10+
+#include "llvm/Support/AArch64TargetParser.def"
11+
.Default(ARM::FK_INVALID);
12+
}
13+
14+
@@ -44,7 +44,7 @@ unsigned AArch64::getDefaultExtensions(StringRef CPU, AArch64::ArchKind AK) {
15+
.Case(NAME, AArch64ARCHNames[static_cast<unsigned>(ArchKind::ID)] \
16+
.ArchBaseExtensions | \
17+
DEFAULT_EXT)
18+
-#include "../../include/llvm/Support/AArch64TargetParser.def"
19+
+#include "llvm/Support/AArch64TargetParser.def"
20+
.Default(AArch64::AEK_INVALID);
21+
}
22+
23+
@@ -55,7 +55,7 @@ AArch64::ArchKind AArch64::getCPUArchKind(StringRef CPU) {
24+
return StringSwitch<AArch64::ArchKind>(CPU)
25+
#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
26+
.Case(NAME, ArchKind::ID)
27+
-#include "../../include/llvm/Support/AArch64TargetParser.def"
28+
+#include "llvm/Support/AArch64TargetParser.def"
29+
.Default(ArchKind::INVALID);
30+
}
31+
32+
--- a/include/llvm/Support/YAMLTraits.h
33+
+++ b/include/llvm/Support/YAMLTraits.h
34+
@@ -18,7 +18,6 @@
35+
#include "llvm/Support/AlignOf.h"
36+
#include "llvm/Support/Allocator.h"
37+
#include "llvm/Support/Endian.h"
38+
-#include "llvm/Support/Regex.h"
39+
#include "llvm/Support/SourceMgr.h"
40+
#include "llvm/Support/YAMLParser.h"
41+
#include "llvm/Support/raw_ostream.h"

include/llvm-c/DataTypes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\
22
|* *|
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. *|
3+
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4+
|* Exceptions. *|
5+
|* See https://llvm.org/LICENSE.txt for license information. *|
6+
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
77
|* *|
88
|*===----------------------------------------------------------------------===*|
99
|* *|

include/llvm-c/Error.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*===------- llvm-c/Error.h - llvm::Error class C Interface -------*- C -*-===*\
2+
|* *|
3+
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4+
|* Exceptions. *|
5+
|* See https://llvm.org/LICENSE.txt for license information. *|
6+
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7+
|* *|
8+
|*===----------------------------------------------------------------------===*|
9+
|* *|
10+
|* This file defines the C interface to LLVM's Error class. *|
11+
|* *|
12+
\*===----------------------------------------------------------------------===*/
13+
14+
#ifndef LLVM_C_ERROR_H
15+
#define LLVM_C_ERROR_H
16+
17+
#include "llvm/Config/indexstoredb-prefix.h"
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
#define LLVMErrorSuccess 0
24+
25+
/**
26+
* Opaque reference to an error instance. Null serves as the 'success' value.
27+
*/
28+
typedef struct LLVMOpaqueError *LLVMErrorRef;
29+
30+
/**
31+
* Error type identifier.
32+
*/
33+
typedef const void *LLVMErrorTypeId;
34+
35+
/**
36+
* Returns the type id for the given error instance, which must be a failure
37+
* value (i.e. non-null).
38+
*/
39+
LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
40+
41+
/**
42+
* Dispose of the given error without handling it. This operation consumes the
43+
* error, and the given LLVMErrorRef value is not usable once this call returns.
44+
* Note: This method *only* needs to be called if the error is not being passed
45+
* to some other consuming operation, e.g. LLVMGetErrorMessage.
46+
*/
47+
void LLVMConsumeError(LLVMErrorRef Err);
48+
49+
/**
50+
* Returns the given string's error message. This operation consumes the error,
51+
* and the given LLVMErrorRef value is not usable once this call returns.
52+
* The caller is responsible for disposing of the string by calling
53+
* LLVMDisposeErrorMessage.
54+
*/
55+
char *LLVMGetErrorMessage(LLVMErrorRef Err);
56+
57+
/**
58+
* Dispose of the given error message.
59+
*/
60+
void LLVMDisposeErrorMessage(char *ErrMsg);
61+
62+
/**
63+
* Returns the type id for llvm StringError.
64+
*/
65+
LLVMErrorTypeId LLVMGetStringErrorTypeId();
66+
67+
#ifdef __cplusplus
68+
}
69+
#endif
70+
71+
#endif

include/llvm-c/ErrorHandling.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\
22
|* *|
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. *|
3+
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4+
|* Exceptions. *|
5+
|* See https://llvm.org/LICENSE.txt for license information. *|
6+
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
77
|* *|
88
|*===----------------------------------------------------------------------===*|
99
|* *|

include/llvm-c/Support.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*===-- llvm-c/Support.h - Support C Interface --------------------*- C -*-===*\
22
|* *|
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. *|
3+
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4+
|* Exceptions. *|
5+
|* See https://llvm.org/LICENSE.txt for license information. *|
6+
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
77
|* *|
88
|*===----------------------------------------------------------------------===*|
99
|* *|

include/llvm-c/Types.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*===-- llvm-c/Support.h - C Interface Types declarations ---------*- C -*-===*\
22
|* *|
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. *|
3+
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4+
|* Exceptions. *|
5+
|* See https://llvm.org/LICENSE.txt for license information. *|
6+
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
77
|* *|
88
|*===----------------------------------------------------------------------===*|
99
|* *|
@@ -89,6 +89,20 @@ typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
8989
*/
9090
typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
9191

92+
/**
93+
* Represents an LLVM Named Metadata Node.
94+
*
95+
* This models llvm::NamedMDNode.
96+
*/
97+
typedef struct LLVMOpaqueNamedMDNode *LLVMNamedMDNodeRef;
98+
99+
/**
100+
* Represents an entry in a Global Object's metadata attachments.
101+
*
102+
* This models std::pair<unsigned, MDNode *>
103+
*/
104+
typedef struct LLVMOpaqueValueMetadataEntry LLVMValueMetadataEntry;
105+
92106
/**
93107
* Represents an LLVM basic block builder.
94108
*
@@ -149,6 +163,11 @@ typedef struct LLVMOpaqueModuleFlagEntry LLVMModuleFlagEntry;
149163
*/
150164
typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef;
151165

166+
/**
167+
* @see llvm::object::Binary
168+
*/
169+
typedef struct LLVMOpaqueBinary *LLVMBinaryRef;
170+
152171
/**
153172
* @}
154173
*/

0 commit comments

Comments
 (0)