@@ -42,7 +42,7 @@ import cllvm
42
42
///
43
43
/// var g1 = builder.addGlobal("g1", initializer: IntType.int8.constant(42))
44
44
/// g1.comdat = foo
45
- /// var g2 = builder.addGlobal("g1 ", initializer: IntType.int8.constant(42))
45
+ /// var g2 = builder.addGlobal("g2 ", initializer: IntType.int8.constant(42))
46
46
/// g2.comdat = bar
47
47
///
48
48
/// From the object file perspective, this requires the creation of two sections
@@ -57,66 +57,68 @@ public class Comdat {
57
57
}
58
58
59
59
/// The selection kind for this COMDAT section.
60
- public var selectionKind : ComdatSelectionKind {
61
- get { return ComdatSelectionKind ( llvm: LLVMGetComdatSelectionKind ( self . llvm) ) }
60
+ public var selectionKind : Comdat . SelectionKind {
61
+ get { return Comdat . SelectionKind ( llvm: LLVMGetComdatSelectionKind ( self . llvm) ) }
62
62
set { LLVMSetComdatSelectionKind ( self . llvm, newValue. llvm) }
63
63
}
64
64
}
65
65
66
- /// A `ComdatSelectionKind` describes the behavior of the linker when
67
- /// linking COMDAT sections.
68
- public enum ComdatSelectionKind {
69
- /// The linker may choose any COMDAT section with a matching key.
70
- ///
71
- /// This selection kind is the most relaxed - any section with the same key
72
- /// but not necessarily identical size or contents can be chosen. Precisely
73
- /// which section is chosen is implementation-defined.
74
- ///
75
- /// This selection kind is the default for all newly-inserted sections.
76
- case any
77
- /// The linker may choose any identically-keyed COMDAT section and requires
78
- /// all other referenced data to match its selection's referenced data.
79
- ///
80
- /// This selection kind requires that the data in each COMDAT section be
81
- /// identical in length and content. Inclusion of multiple non-identical
82
- /// COMDAT sections with the same key is an error.
83
- ///
84
- /// For global objects in LLVM, identical contents is defined to mean that
85
- /// their initializers point to the same global `IRValue`.
86
- case exactMatch
87
- /// The linker chooses the identically-keyed COMDAT section with the largest
88
- /// size, ignoring content.
89
- case largest
90
- /// The COMDAT section with this key is unique.
91
- ///
92
- /// This selection requires that no other COMDAT section have the same key
93
- /// as this section, making the choice of selection unambiguous. Inclusion
94
- /// of any other COMDAT section with the same key is an error.
95
- case noDuplicates
96
- /// The linker may choose any identically-keyed COMDAT section and requires
97
- /// all other sections to have the same size as its selection.
98
- case sameSize
66
+ extension Comdat {
67
+ /// A `Comdat.SelectionKind` describes the behavior of the linker when
68
+ /// linking COMDAT sections.
69
+ public enum SelectionKind {
70
+ /// The linker may choose any COMDAT section with a matching key.
71
+ ///
72
+ /// This selection kind is the most relaxed - any section with the same key
73
+ /// but not necessarily identical size or contents can be chosen. Precisely
74
+ /// which section is chosen is implementation-defined.
75
+ ///
76
+ /// This selection kind is the default for all newly-inserted sections.
77
+ case any
78
+ /// The linker may choose any identically-keyed COMDAT section and requires
79
+ /// all other referenced data to match its selection's referenced data.
80
+ ///
81
+ /// This selection kind requires that the data in each COMDAT section be
82
+ /// identical in length and content. Inclusion of multiple non-identical
83
+ /// COMDAT sections with the same key is an error.
84
+ ///
85
+ /// For global objects in LLVM, identical contents is defined to mean that
86
+ /// their initializers point to the same global `IRValue`.
87
+ case exactMatch
88
+ /// The linker chooses the identically-keyed COMDAT section with the largest
89
+ /// size, ignoring content.
90
+ case largest
91
+ /// The COMDAT section with this key is unique.
92
+ ///
93
+ /// This selection requires that no other COMDAT section have the same key
94
+ /// as this section, making the choice of selection unambiguous. Inclusion
95
+ /// of any other COMDAT section with the same key is an error.
96
+ case noDuplicates
97
+ /// The linker may choose any identically-keyed COMDAT section and requires
98
+ /// all other sections to have the same size as its selection.
99
+ case sameSize
99
100
100
- internal init ( llvm: LLVMComdatSelectionKind ) {
101
- switch llvm {
102
- case LLVMAnyComdatSelectionKind: self = . any
103
- case LLVMExactMatchComdatSelectionKind: self = . exactMatch
104
- case LLVMLargestComdatSelectionKind: self = . largest
105
- case LLVMNoDuplicatesComdatSelectionKind: self = . noDuplicates
106
- case LLVMSameSizeComdatSelectionKind: self = . sameSize
107
- default : fatalError ( " unknown comdat selection kind \( llvm) " )
101
+ internal init ( llvm: LLVMComdatSelectionKind ) {
102
+ switch llvm {
103
+ case LLVMAnyComdatSelectionKind: self = . any
104
+ case LLVMExactMatchComdatSelectionKind: self = . exactMatch
105
+ case LLVMLargestComdatSelectionKind: self = . largest
106
+ case LLVMNoDuplicatesComdatSelectionKind: self = . noDuplicates
107
+ case LLVMSameSizeComdatSelectionKind: self = . sameSize
108
+ default : fatalError ( " unknown comdat selection kind \( llvm) " )
109
+ }
108
110
}
109
- }
110
111
111
- private static let comdatMapping : [ ComdatSelectionKind : LLVMComdatSelectionKind ] = [
112
- . any: LLVMAnyComdatSelectionKind,
113
- . exactMatch: LLVMExactMatchComdatSelectionKind,
114
- . largest: LLVMLargestComdatSelectionKind,
115
- . noDuplicates: LLVMNoDuplicatesComdatSelectionKind,
116
- . sameSize: LLVMSameSizeComdatSelectionKind,
117
- ]
112
+ private static let comdatMapping : [ Comdat . SelectionKind : LLVMComdatSelectionKind ] = [
113
+ . any: LLVMAnyComdatSelectionKind,
114
+ . exactMatch: LLVMExactMatchComdatSelectionKind,
115
+ . largest: LLVMLargestComdatSelectionKind,
116
+ . noDuplicates: LLVMNoDuplicatesComdatSelectionKind,
117
+ . sameSize: LLVMSameSizeComdatSelectionKind,
118
+ ]
118
119
119
- fileprivate var llvm : LLVMComdatSelectionKind {
120
- return ComdatSelectionKind . comdatMapping [ self ] !
120
+ fileprivate var llvm : LLVMComdatSelectionKind {
121
+ return SelectionKind . comdatMapping [ self ] !
122
+ }
121
123
}
122
124
}
0 commit comments