1 --- llvm-12.0.0.src/tools/clang/tools/extra/clangd/quality/CompletionModel.cmake.orig 2021-04-06 18:38:18.000000000 +0200
2 +++ llvm-12.0.0.src/tools/clang/tools/extra/clangd/quality/CompletionModel.cmake 2021-04-18 18:45:47.412730844 +0200
4 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header
5 # will define a C++ class called ${cpp_class} - which may be a
6 # namespace-qualified class name.
7 +set(model_compiler ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)
8 function(gen_decision_forest model filename cpp_class)
9 - set(model_compiler ${CMAKE_SOURCE_DIR}/../clang-tools-extra/clangd/quality/CompletionModelCodegen.py)
11 set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
12 set(header_file ${output_dir}/${filename}.h)
13 diff -urN llvm-12.0.0.src.orig/tools/lld/MachO/mach-o/compact_unwind_encoding.h llvm-12.0.0.src/tools/lld/MachO/mach-o/compact_unwind_encoding.h
14 --- llvm-12.0.0.src.orig/tools/lld/MachO/mach-o/compact_unwind_encoding.h 1970-01-01 01:00:00.000000000 +0100
15 +++ llvm-12.0.0.src/tools/lld/MachO/mach-o/compact_unwind_encoding.h 2021-04-16 16:24:55.701577683 +0200
17 +//===------------------ mach-o/compact_unwind_encoding.h ------------------===//
19 +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
20 +// See https://llvm.org/LICENSE.txt for license information.
21 +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
24 +// Darwin's alternative to DWARF based unwind encodings.
26 +//===----------------------------------------------------------------------===//
29 +#ifndef __COMPACT_UNWIND_ENCODING__
30 +#define __COMPACT_UNWIND_ENCODING__
35 +// Compilers can emit standard DWARF FDEs in the __TEXT,__eh_frame section
36 +// of object files. Or compilers can emit compact unwind information in
37 +// the __LD,__compact_unwind section.
39 +// When the linker creates a final linked image, it will create a
40 +// __TEXT,__unwind_info section. This section is a small and fast way for the
41 +// runtime to access unwind info for any given function. If the compiler
42 +// emitted compact unwind info for the function, that compact unwind info will
43 +// be encoded in the __TEXT,__unwind_info section. If the compiler emitted
44 +// DWARF unwind info, the __TEXT,__unwind_info section will contain the offset
45 +// of the FDE in the __TEXT,__eh_frame section in the final linked image.
47 +// Note: Previously, the linker would transform some DWARF unwind infos into
48 +// compact unwind info. But that is fragile and no longer done.
52 +// The compact unwind endoding is a 32-bit value which encoded in an
53 +// architecture specific way, which registers to restore from where, and how
54 +// to unwind out of the function.
56 +typedef uint32_t compact_unwind_encoding_t;
59 +// architecture independent bits
61 + UNWIND_IS_NOT_FUNCTION_START = 0x80000000,
62 + UNWIND_HAS_LSDA = 0x40000000,
63 + UNWIND_PERSONALITY_MASK = 0x30000000,
74 +// 2-bit: personality index
76 +// 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=DWARF
78 +// 15-bits (5*3-bits per reg) register permutation
79 +// 8-bits for stack offset
82 +// 3-bits stack adjust
83 +// 3-bits register count
84 +// 10-bits register permutation
87 + UNWIND_X86_MODE_MASK = 0x0F000000,
88 + UNWIND_X86_MODE_EBP_FRAME = 0x01000000,
89 + UNWIND_X86_MODE_STACK_IMMD = 0x02000000,
90 + UNWIND_X86_MODE_STACK_IND = 0x03000000,
91 + UNWIND_X86_MODE_DWARF = 0x04000000,
93 + UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF,
94 + UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000,
96 + UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000,
97 + UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000,
98 + UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
99 + UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
101 + UNWIND_X86_DWARF_SECTION_OFFSET = 0x00FFFFFF,
105 + UNWIND_X86_REG_NONE = 0,
106 + UNWIND_X86_REG_EBX = 1,
107 + UNWIND_X86_REG_ECX = 2,
108 + UNWIND_X86_REG_EDX = 3,
109 + UNWIND_X86_REG_EDI = 4,
110 + UNWIND_X86_REG_ESI = 5,
111 + UNWIND_X86_REG_EBP = 6,
115 +// For x86 there are four modes for the compact unwind encoding:
116 +// UNWIND_X86_MODE_EBP_FRAME:
117 +// EBP based frame where EBP is push on stack immediately after return address,
118 +// then ESP is moved to EBP. Thus, to unwind ESP is restored with the current
119 +// EPB value, then EBP is restored by popping off the stack, and the return
120 +// is done by popping the stack once more into the pc.
121 +// All non-volatile registers that need to be restored must have been saved
122 +// in a small range in the stack that starts EBP-4 to EBP-1020. The offset/4
123 +// is encoded in the UNWIND_X86_EBP_FRAME_OFFSET bits. The registers saved
124 +// are encoded in the UNWIND_X86_EBP_FRAME_REGISTERS bits as five 3-bit entries.
125 +// Each entry contains which register to restore.
126 +// UNWIND_X86_MODE_STACK_IMMD:
127 +// A "frameless" (EBP not used as frame pointer) function with a small
128 +// constant stack size. To return, a constant (encoded in the compact
129 +// unwind encoding) is added to the ESP. Then the return is done by
130 +// popping the stack into the pc.
131 +// All non-volatile registers that need to be restored must have been saved
132 +// on the stack immediately after the return address. The stack_size/4 is
133 +// encoded in the UNWIND_X86_FRAMELESS_STACK_SIZE (max stack size is 1024).
134 +// The number of registers saved is encoded in UNWIND_X86_FRAMELESS_STACK_REG_COUNT.
135 +// UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
136 +// saved and their order.
137 +// UNWIND_X86_MODE_STACK_IND:
138 +// A "frameless" (EBP not used as frame pointer) function large constant
139 +// stack size. This case is like the previous, except the stack size is too
140 +// large to encode in the compact unwind encoding. Instead it requires that
141 +// the function contains "subl $nnnnnnnn,ESP" in its prolog. The compact
142 +// encoding contains the offset to the nnnnnnnn value in the function in
143 +// UNWIND_X86_FRAMELESS_STACK_SIZE.
144 +// UNWIND_X86_MODE_DWARF:
145 +// No compact unwind encoding is available. Instead the low 24-bits of the
146 +// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
147 +// This mode is never used in object files. It is only generated by the
148 +// linker in final linked images which have only DWARF unwind info for a
151 +// The permutation encoding is a Lehmer code sequence encoded into a
152 +// single variable-base number so we can encode the ordering of up to
153 +// six registers in a 10-bit space.
155 +// The following is the algorithm used to create the permutation encoding used
156 +// with frameless stacks. It is passed the number of registers to be saved and
157 +// an array of the register numbers saved.
159 +//uint32_t permute_encode(uint32_t registerCount, const uint32_t registers[6])
161 +// uint32_t renumregs[6];
162 +// for (int i=6-registerCount; i < 6; ++i) {
163 +// int countless = 0;
164 +// for (int j=6-registerCount; j < i; ++j) {
165 +// if ( registers[j] < registers[i] )
168 +// renumregs[i] = registers[i] - countless -1;
170 +// uint32_t permutationEncoding = 0;
171 +// switch ( registerCount ) {
173 +// permutationEncoding |= (120*renumregs[0] + 24*renumregs[1]
174 +// + 6*renumregs[2] + 2*renumregs[3]
178 +// permutationEncoding |= (120*renumregs[1] + 24*renumregs[2]
179 +// + 6*renumregs[3] + 2*renumregs[4]
183 +// permutationEncoding |= (60*renumregs[2] + 12*renumregs[3]
184 +// + 3*renumregs[4] + renumregs[5]);
187 +// permutationEncoding |= (20*renumregs[3] + 4*renumregs[4]
191 +// permutationEncoding |= (5*renumregs[4] + renumregs[5]);
194 +// permutationEncoding |= (renumregs[5]);
197 +// return permutationEncoding;
209 +// 2-bit: personality index
211 +// 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=DWARF
213 +// 15-bits (5*3-bits per reg) register permutation
214 +// 8-bits for stack offset
216 +// 8-bits stack size
217 +// 3-bits stack adjust
218 +// 3-bits register count
219 +// 10-bits register permutation
222 + UNWIND_X86_64_MODE_MASK = 0x0F000000,
223 + UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000,
224 + UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000,
225 + UNWIND_X86_64_MODE_STACK_IND = 0x03000000,
226 + UNWIND_X86_64_MODE_DWARF = 0x04000000,
228 + UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF,
229 + UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000,
231 + UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000,
232 + UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000,
233 + UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
234 + UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
236 + UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
240 + UNWIND_X86_64_REG_NONE = 0,
241 + UNWIND_X86_64_REG_RBX = 1,
242 + UNWIND_X86_64_REG_R12 = 2,
243 + UNWIND_X86_64_REG_R13 = 3,
244 + UNWIND_X86_64_REG_R14 = 4,
245 + UNWIND_X86_64_REG_R15 = 5,
246 + UNWIND_X86_64_REG_RBP = 6,
249 +// For x86_64 there are four modes for the compact unwind encoding:
250 +// UNWIND_X86_64_MODE_RBP_FRAME:
251 +// RBP based frame where RBP is push on stack immediately after return address,
252 +// then RSP is moved to RBP. Thus, to unwind RSP is restored with the current
253 +// EPB value, then RBP is restored by popping off the stack, and the return
254 +// is done by popping the stack once more into the pc.
255 +// All non-volatile registers that need to be restored must have been saved
256 +// in a small range in the stack that starts RBP-8 to RBP-2040. The offset/8
257 +// is encoded in the UNWIND_X86_64_RBP_FRAME_OFFSET bits. The registers saved
258 +// are encoded in the UNWIND_X86_64_RBP_FRAME_REGISTERS bits as five 3-bit entries.
259 +// Each entry contains which register to restore.
260 +// UNWIND_X86_64_MODE_STACK_IMMD:
261 +// A "frameless" (RBP not used as frame pointer) function with a small
262 +// constant stack size. To return, a constant (encoded in the compact
263 +// unwind encoding) is added to the RSP. Then the return is done by
264 +// popping the stack into the pc.
265 +// All non-volatile registers that need to be restored must have been saved
266 +// on the stack immediately after the return address. The stack_size/8 is
267 +// encoded in the UNWIND_X86_64_FRAMELESS_STACK_SIZE (max stack size is 2048).
268 +// The number of registers saved is encoded in UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT.
269 +// UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
270 +// saved and their order.
271 +// UNWIND_X86_64_MODE_STACK_IND:
272 +// A "frameless" (RBP not used as frame pointer) function large constant
273 +// stack size. This case is like the previous, except the stack size is too
274 +// large to encode in the compact unwind encoding. Instead it requires that
275 +// the function contains "subq $nnnnnnnn,RSP" in its prolog. The compact
276 +// encoding contains the offset to the nnnnnnnn value in the function in
277 +// UNWIND_X86_64_FRAMELESS_STACK_SIZE.
278 +// UNWIND_X86_64_MODE_DWARF:
279 +// No compact unwind encoding is available. Instead the low 24-bits of the
280 +// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
281 +// This mode is never used in object files. It is only generated by the
282 +// linker in final linked images which have only DWARF unwind info for a
291 +// 2-bit: personality index
293 +// 4-bits: 4=frame-based, 3=DWARF, 2=frameless
295 +// 12-bits of stack size
297 +// 4-bits D reg pairs saved
298 +// 5-bits X reg pairs saved
300 +// 24-bits offset of DWARF FDE in __eh_frame section
303 + UNWIND_ARM64_MODE_MASK = 0x0F000000,
304 + UNWIND_ARM64_MODE_FRAMELESS = 0x02000000,
305 + UNWIND_ARM64_MODE_DWARF = 0x03000000,
306 + UNWIND_ARM64_MODE_FRAME = 0x04000000,
308 + UNWIND_ARM64_FRAME_X19_X20_PAIR = 0x00000001,
309 + UNWIND_ARM64_FRAME_X21_X22_PAIR = 0x00000002,
310 + UNWIND_ARM64_FRAME_X23_X24_PAIR = 0x00000004,
311 + UNWIND_ARM64_FRAME_X25_X26_PAIR = 0x00000008,
312 + UNWIND_ARM64_FRAME_X27_X28_PAIR = 0x00000010,
313 + UNWIND_ARM64_FRAME_D8_D9_PAIR = 0x00000100,
314 + UNWIND_ARM64_FRAME_D10_D11_PAIR = 0x00000200,
315 + UNWIND_ARM64_FRAME_D12_D13_PAIR = 0x00000400,
316 + UNWIND_ARM64_FRAME_D14_D15_PAIR = 0x00000800,
318 + UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK = 0x00FFF000,
319 + UNWIND_ARM64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
321 +// For arm64 there are three modes for the compact unwind encoding:
322 +// UNWIND_ARM64_MODE_FRAME:
323 +// This is a standard arm64 prolog where FP/LR are immediately pushed on the
324 +// stack, then SP is copied to FP. If there are any non-volatile registers
325 +// saved, then are copied into the stack frame in pairs in a contiguous
326 +// range right below the saved FP/LR pair. Any subset of the five X pairs
327 +// and four D pairs can be saved, but the memory layout must be in register
329 +// UNWIND_ARM64_MODE_FRAMELESS:
330 +// A "frameless" leaf function, where FP/LR are not saved. The return address
331 +// remains in LR throughout the function. If any non-volatile registers
332 +// are saved, they must be pushed onto the stack before any stack space is
333 +// allocated for local variables. The stack sized (including any saved
334 +// non-volatile registers) divided by 16 is encoded in the bits
335 +// UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK.
336 +// UNWIND_ARM64_MODE_DWARF:
337 +// No compact unwind encoding is available. Instead the low 24-bits of the
338 +// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
339 +// This mode is never used in object files. It is only generated by the
340 +// linker in final linked images which have only DWARF unwind info for a
348 +////////////////////////////////////////////////////////////////////////////////
350 +// Relocatable Object Files: __LD,__compact_unwind
352 +////////////////////////////////////////////////////////////////////////////////
355 +// A compiler can generated compact unwind information for a function by adding
356 +// a "row" to the __LD,__compact_unwind section. This section has the
357 +// S_ATTR_DEBUG bit set, so the section will be ignored by older linkers.
358 +// It is removed by the new linker, so never ends up in final executables.
359 +// This section is a table, initially with one row per function (that needs
360 +// unwind info). The table columns and some conceptual entries are:
362 +// range-start pointer to start of function/range
364 +// compact-unwind-encoding 32-bit encoding
365 +// personality-function or zero if no personality function
366 +// lsda or zero if no LSDA data
368 +// The length and encoding fields are 32-bits. The other are all pointer sized.
370 +// In x86_64 assembly, these entry would look like:
372 +// .section __LD,__compact_unwind,regular,debug
374 +// #compact unwind for _foo
376 +// .set L1,LfooEnd-_foo
382 +// #compact unwind for _bar
384 +// .set L2,LbarEnd-_bar
387 +// .quad __gxx_personality
388 +// .quad except_tab1
391 +// Notes: There is no need for any labels in the the __compact_unwind section.
392 +// The use of the .set directive is to force the evaluation of the
393 +// range-length at assembly time, instead of generating relocations.
395 +// To support future compiler optimizations where which non-volatile registers
396 +// are saved changes within a function (e.g. delay saving non-volatiles until
397 +// necessary), there can by multiple lines in the __compact_unwind table for one
398 +// function, each with a different (non-overlapping) range and each with
399 +// different compact unwind encodings that correspond to the non-volatiles
400 +// saved at that range of the function.
402 +// If a particular function is so wacky that there is no compact unwind way
403 +// to encode it, then the compiler can emit traditional DWARF unwind info.
404 +// The runtime will use which ever is available.
406 +// Runtime support for compact unwind encodings are only available on 10.6
407 +// and later. So, the compiler should not generate it when targeting pre-10.6.
412 +////////////////////////////////////////////////////////////////////////////////
414 +// Final Linked Images: __TEXT,__unwind_info
416 +////////////////////////////////////////////////////////////////////////////////
419 +// The __TEXT,__unwind_info section is laid out for an efficient two level lookup.
420 +// The header of the section contains a coarse index that maps function address
421 +// to the page (4096 byte block) containing the unwind info for that function.
424 +#define UNWIND_SECTION_VERSION 1
425 +struct unwind_info_section_header
427 + uint32_t version; // UNWIND_SECTION_VERSION
428 + uint32_t commonEncodingsArraySectionOffset;
429 + uint32_t commonEncodingsArrayCount;
430 + uint32_t personalityArraySectionOffset;
431 + uint32_t personalityArrayCount;
432 + uint32_t indexSectionOffset;
433 + uint32_t indexCount;
434 + // compact_unwind_encoding_t[]
435 + // uint32_t personalities[]
436 + // unwind_info_section_header_index_entry[]
437 + // unwind_info_section_header_lsda_index_entry[]
440 +struct unwind_info_section_header_index_entry
442 + uint32_t functionOffset;
443 + uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page
444 + uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range
447 +struct unwind_info_section_header_lsda_index_entry
449 + uint32_t functionOffset;
450 + uint32_t lsdaOffset;
454 +// There are two kinds of second level index pages: regular and compressed.
455 +// A compressed page can hold up to 1021 entries, but it cannot be used
456 +// if too many different encoding types are used. The regular page holds
460 +struct unwind_info_regular_second_level_entry
462 + uint32_t functionOffset;
463 + compact_unwind_encoding_t encoding;
466 +#define UNWIND_SECOND_LEVEL_REGULAR 2
467 +struct unwind_info_regular_second_level_page_header
469 + uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR
470 + uint16_t entryPageOffset;
471 + uint16_t entryCount;
475 +#define UNWIND_SECOND_LEVEL_COMPRESSED 3
476 +struct unwind_info_compressed_second_level_page_header
478 + uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED
479 + uint16_t entryPageOffset;
480 + uint16_t entryCount;
481 + uint16_t encodingsPageOffset;
482 + uint16_t encodingsCount;
483 + // 32-bit entry array
487 +#define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF)
488 +#define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF)