@@ -17,10 +17,16 @@ extern crate llvm_sys;
17
17
#[ macro_use]
18
18
extern crate inkwell_internal_macros;
19
19
20
+ #[ macro_use]
21
+ pub mod support;
20
22
#[ deny( missing_docs) ]
21
23
#[ cfg( not( any( feature = "llvm3-6" , feature = "llvm3-7" , feature = "llvm3-8" ) ) ) ]
22
24
pub mod attributes;
23
25
#[ deny( missing_docs) ]
26
+ #[ cfg( not( any( feature = "llvm3-6" , feature = "llvm3-7" , feature = "llvm3-8" , feature = "llvm3-9" ,
27
+ feature = "llvm4-0" , feature = "llvm5-0" , feature = "llvm6-0" ) ) ) ]
28
+ pub mod comdat;
29
+ #[ deny( missing_docs) ]
24
30
pub mod basic_block;
25
31
pub mod builder;
26
32
#[ deny( missing_docs) ]
@@ -32,7 +38,6 @@ pub mod memory_buffer;
32
38
pub mod module;
33
39
pub mod object_file;
34
40
pub mod passes;
35
- pub mod support;
36
41
pub mod targets;
37
42
pub mod types;
38
43
pub mod values;
@@ -98,110 +103,71 @@ impl From<u32> for AddressSpace {
98
103
}
99
104
100
105
// REVIEW: Maybe this belongs in some sort of prelude?
101
- /// This enum defines how to compare a `left` and `right` `IntValue`.
102
- #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
103
- pub enum IntPredicate {
104
- /// Equal
105
- EQ ,
106
- /// Not Equal
107
- NE ,
108
- /// Unsigned Greater Than
109
- UGT ,
110
- /// Unsigned Greater Than or Equal
111
- UGE ,
112
- /// Unsigned Less Than
113
- ULT ,
114
- /// Unsigned Less Than or Equal
115
- ULE ,
116
- /// Signed Greater Than
117
- SGT ,
118
- /// Signed Greater Than or Equal
119
- SGE ,
120
- /// Signed Less Than
121
- SLT ,
122
- /// Signed Less Than or Equal
123
- SLE ,
124
- }
125
-
126
- impl IntPredicate {
127
- pub ( crate ) fn as_llvm_predicate ( & self ) -> LLVMIntPredicate {
128
- match * self {
129
- IntPredicate :: EQ => LLVMIntPredicate :: LLVMIntEQ ,
130
- IntPredicate :: NE => LLVMIntPredicate :: LLVMIntNE ,
131
- IntPredicate :: UGT => LLVMIntPredicate :: LLVMIntUGT ,
132
- IntPredicate :: UGE => LLVMIntPredicate :: LLVMIntUGE ,
133
- IntPredicate :: ULT => LLVMIntPredicate :: LLVMIntULT ,
134
- IntPredicate :: ULE => LLVMIntPredicate :: LLVMIntULE ,
135
- IntPredicate :: SGT => LLVMIntPredicate :: LLVMIntSGT ,
136
- IntPredicate :: SGE => LLVMIntPredicate :: LLVMIntSGE ,
137
- IntPredicate :: SLT => LLVMIntPredicate :: LLVMIntSLT ,
138
- IntPredicate :: SLE => LLVMIntPredicate :: LLVMIntSLE ,
139
- }
106
+ enum_rename ! {
107
+ /// This enum defines how to compare a `left` and `right` `IntValue`.
108
+ IntPredicate <=> LLVMIntPredicate {
109
+ /// Equal
110
+ EQ <=> LLVMIntEQ ,
111
+ /// Not Equal
112
+ NE <=> LLVMIntNE ,
113
+ /// Unsigned Greater Than
114
+ UGT <=> LLVMIntUGT ,
115
+ /// Unsigned Greater Than or Equal
116
+ UGE <=> LLVMIntUGE ,
117
+ /// Unsigned Less Than
118
+ ULT <=> LLVMIntULT ,
119
+ /// Unsigned Less Than or Equal
120
+ ULE <=> LLVMIntULE ,
121
+ /// Signed Greater Than
122
+ SGT <=> LLVMIntSGT ,
123
+ /// Signed Greater Than or Equal
124
+ SGE <=> LLVMIntSGE ,
125
+ /// Signed Less Than
126
+ SLT <=> LLVMIntSLT ,
127
+ /// Signed Less Than or Equal
128
+ SLE <=> LLVMIntSLE ,
140
129
}
141
130
}
142
131
143
132
// REVIEW: Maybe this belongs in some sort of prelude?
144
- /// Defines how to compare a `left` and `right` `FloatValue`.
145
- #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
146
- pub enum FloatPredicate {
147
- /// Returns true if `left` == `right` and neither are NaN
148
- OEQ ,
149
- /// Returns true if `left` >= `right` and neither are NaN
150
- OGE ,
151
- /// Returns true if `left` > `right` and neither are NaN
152
- OGT ,
153
- /// Returns true if `left` <= `right` and neither are NaN
154
- OLE ,
155
- /// Returns true if `left` < `right` and neither are NaN
156
- OLT ,
157
- /// Returns true if `left` != `right` and neither are NaN
158
- ONE ,
159
- /// Returns true if neither value is NaN
160
- ORD ,
161
- /// Always returns false
162
- PredicateFalse ,
163
- /// Always returns true
164
- PredicateTrue ,
165
- /// Returns true if `left` == `right` or either is NaN
166
- UEQ ,
167
- /// Returns true if `left` >= `right` or either is NaN
168
- UGE ,
169
- /// Returns true if `left` > `right` or either is NaN
170
- UGT ,
171
- /// Returns true if `left` <= `right` or either is NaN
172
- ULE ,
173
- /// Returns true if `left` < `right` or either is NaN
174
- ULT ,
175
- /// Returns true if `left` != `right` or either is NaN
176
- UNE ,
177
- /// Returns true if either value is NaN
178
- UNO ,
179
- }
180
-
181
- impl FloatPredicate {
182
- pub ( crate ) fn as_llvm_predicate ( & self ) -> LLVMRealPredicate {
183
- match * self {
184
- FloatPredicate :: PredicateFalse => LLVMRealPredicate :: LLVMRealPredicateFalse ,
185
- FloatPredicate :: OEQ => LLVMRealPredicate :: LLVMRealOEQ ,
186
- FloatPredicate :: OGT => LLVMRealPredicate :: LLVMRealOGT ,
187
- FloatPredicate :: OGE => LLVMRealPredicate :: LLVMRealOGE ,
188
- FloatPredicate :: OLT => LLVMRealPredicate :: LLVMRealOLT ,
189
- FloatPredicate :: OLE => LLVMRealPredicate :: LLVMRealOLE ,
190
- FloatPredicate :: ONE => LLVMRealPredicate :: LLVMRealONE ,
191
- FloatPredicate :: ORD => LLVMRealPredicate :: LLVMRealORD ,
192
- FloatPredicate :: UNO => LLVMRealPredicate :: LLVMRealUNO ,
193
- FloatPredicate :: UEQ => LLVMRealPredicate :: LLVMRealUEQ ,
194
- FloatPredicate :: UGT => LLVMRealPredicate :: LLVMRealUGT ,
195
- FloatPredicate :: UGE => LLVMRealPredicate :: LLVMRealUGE ,
196
- FloatPredicate :: ULT => LLVMRealPredicate :: LLVMRealULT ,
197
- FloatPredicate :: ULE => LLVMRealPredicate :: LLVMRealULE ,
198
- FloatPredicate :: UNE => LLVMRealPredicate :: LLVMRealUNE ,
199
- FloatPredicate :: PredicateTrue => LLVMRealPredicate :: LLVMRealPredicateTrue ,
200
- }
133
+ enum_rename ! {
134
+ /// Defines how to compare a `left` and `right` `FloatValue`.
135
+ FloatPredicate <=> LLVMRealPredicate {
136
+ /// Returns true if `left` == `right` and neither are NaN
137
+ OEQ <=> LLVMRealOEQ ,
138
+ /// Returns true if `left` >= `right` and neither are NaN
139
+ OGE <=> LLVMRealOGE ,
140
+ /// Returns true if `left` > `right` and neither are NaN
141
+ OGT <=> LLVMRealOGT ,
142
+ /// Returns true if `left` <= `right` and neither are NaN
143
+ OLE <=> LLVMRealOLE ,
144
+ /// Returns true if `left` < `right` and neither are NaN
145
+ OLT <=> LLVMRealOLT ,
146
+ /// Returns true if `left` != `right` and neither are NaN
147
+ ONE <=> LLVMRealONE ,
148
+ /// Returns true if neither value is NaN
149
+ ORD <=> LLVMRealORD ,
150
+ /// Always returns false
151
+ PredicateFalse <=> LLVMRealPredicateFalse ,
152
+ /// Always returns true
153
+ PredicateTrue <=> LLVMRealPredicateTrue ,
154
+ /// Returns true if `left` == `right` or either is NaN
155
+ UEQ <=> LLVMRealUEQ ,
156
+ /// Returns true if `left` >= `right` or either is NaN
157
+ UGE <=> LLVMRealUGE ,
158
+ /// Returns true if `left` > `right` or either is NaN
159
+ UGT <=> LLVMRealUGT ,
160
+ /// Returns true if `left` <= `right` or either is NaN
161
+ ULE <=> LLVMRealULE ,
162
+ /// Returns true if `left` < `right` or either is NaN
163
+ ULT <=> LLVMRealULT ,
164
+ /// Returns true if `left` != `right` or either is NaN
165
+ UNE <=> LLVMRealUNE ,
166
+ /// Returns true if either value is NaN
167
+ UNO <=> LLVMRealUNO ,
201
168
}
202
169
}
203
170
204
-
205
171
/// Defines the optimization level used to compile a `Module`.
206
172
///
207
173
/// # Remarks
@@ -222,12 +188,12 @@ impl Default for OptimizationLevel {
222
188
}
223
189
}
224
190
225
- // REVIEW: Maybe this belongs in some sort of prelude?
226
- # [ derive ( Clone , Copy , Debug , Eq , PartialEq ) ]
227
- pub enum GlobalVisibility {
228
- Default ,
229
- Hidden ,
230
- Protected ,
191
+ enum_rename ! {
192
+ GlobalVisibility <=> LLVMVisibility {
193
+ Default <=> LLVMDefaultVisibility ,
194
+ Hidden <=> LLVMHiddenVisibility ,
195
+ Protected <=> LLVMProtectedVisibility ,
196
+ }
231
197
}
232
198
233
199
impl Default for GlobalVisibility {
@@ -237,24 +203,6 @@ impl Default for GlobalVisibility {
237
203
}
238
204
}
239
205
240
- impl GlobalVisibility {
241
- pub ( crate ) fn new ( visibility : LLVMVisibility ) -> Self {
242
- match visibility {
243
- LLVMVisibility :: LLVMDefaultVisibility => GlobalVisibility :: Default ,
244
- LLVMVisibility :: LLVMHiddenVisibility => GlobalVisibility :: Hidden ,
245
- LLVMVisibility :: LLVMProtectedVisibility => GlobalVisibility :: Protected ,
246
- }
247
- }
248
-
249
- pub ( crate ) fn as_llvm_visibility ( & self ) -> LLVMVisibility {
250
- match * self {
251
- GlobalVisibility :: Default => LLVMVisibility :: LLVMDefaultVisibility ,
252
- GlobalVisibility :: Hidden => LLVMVisibility :: LLVMHiddenVisibility ,
253
- GlobalVisibility :: Protected => LLVMVisibility :: LLVMProtectedVisibility ,
254
- }
255
- }
256
- }
257
-
258
206
#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
259
207
pub enum ThreadLocalMode {
260
208
GeneralDynamicTLSModel ,
@@ -285,11 +233,12 @@ impl ThreadLocalMode {
285
233
}
286
234
}
287
235
288
- #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
289
- pub enum DLLStorageClass {
290
- Default ,
291
- Import ,
292
- Export ,
236
+ enum_rename ! {
237
+ DLLStorageClass <=> LLVMDLLStorageClass {
238
+ Default <=> LLVMDefaultStorageClass ,
239
+ Import <=> LLVMDLLImportStorageClass ,
240
+ Export <=> LLVMDLLExportStorageClass ,
241
+ }
293
242
}
294
243
295
244
impl Default for DLLStorageClass {
@@ -298,21 +247,3 @@ impl Default for DLLStorageClass {
298
247
DLLStorageClass :: Default
299
248
}
300
249
}
301
-
302
- impl DLLStorageClass {
303
- pub ( crate ) fn new ( dll_storage_class : LLVMDLLStorageClass ) -> Self {
304
- match dll_storage_class {
305
- LLVMDLLStorageClass :: LLVMDefaultStorageClass => DLLStorageClass :: Default ,
306
- LLVMDLLStorageClass :: LLVMDLLImportStorageClass => DLLStorageClass :: Import ,
307
- LLVMDLLStorageClass :: LLVMDLLExportStorageClass => DLLStorageClass :: Export ,
308
- }
309
- }
310
-
311
- pub ( crate ) fn as_llvm_class ( & self ) -> LLVMDLLStorageClass {
312
- match * self {
313
- DLLStorageClass :: Default => LLVMDLLStorageClass :: LLVMDefaultStorageClass ,
314
- DLLStorageClass :: Import => LLVMDLLStorageClass :: LLVMDLLImportStorageClass ,
315
- DLLStorageClass :: Export => LLVMDLLStorageClass :: LLVMDLLExportStorageClass ,
316
- }
317
- }
318
- }
0 commit comments