ruby-llvm 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ = LLVM
2
+
3
+ Author:: Jeremy Voorhis
4
+ Contributors:: Evan Phoenix
5
+ Copyright:: Copyright (c) 2010 Jeremy Voorhis
6
+ License:: BSD 3-clause (see LICENSE)
7
+
8
+ This package contains Ruby bindings to the LLVM api, enabling users to make use
9
+ of LLVM's optimization passes and JIT compilation for implementing compiled
10
+ DSLs, callback functions, or fast Ruby method implementations.
11
+
12
+ ruby-llvm has been tested on the following Ruby interpreters:
13
+
14
+ * MRI 1.8.7
15
+ * MRI 1.9.1
16
+ * JRuby 1.4.0
17
+
18
+ If using MRI, then at least ffi >= 0.5.4 is required.
19
+
20
+ == Requirements
21
+ * LLVM 2.7, compiled with --shared-library
22
+
23
+ == About version numbers
24
+
25
+ The first two digits of ruby-llvm's version number refer to the required major
26
+ and minor version of LLVM. The third digit refers to the ruby-llvm release
27
+ itself. Because LLVM's api changes often, this coupling between LLVM and
28
+ ruby-llvm versions is necessary.
@@ -0,0 +1,15 @@
1
+ require 'ffi'
2
+
3
+ module LLVM
4
+ module C
5
+ extend ::FFI::Library
6
+ # load required libraries
7
+ ffi_lib 'LLVM-2.7'
8
+ end
9
+
10
+ NATIVE_INT_SIZE = case FFI::Platform::ARCH
11
+ when "x86_64" then 64
12
+ # PPC, other arches?
13
+ else 32
14
+ end
15
+ end
@@ -0,0 +1,46 @@
1
+ require 'llvm'
2
+ require 'llvm/core'
3
+ require 'llvm/target'
4
+
5
+ module LLVM
6
+ module C
7
+ enum :verifier_failure_action, [
8
+ :abort_process,
9
+ :print_message,
10
+ :return_status
11
+ ]
12
+
13
+ attach_function :LLVMVerifyModule, [:pointer, :verifier_failure_action, :pointer], :int
14
+ attach_function :LLVMVerifyFunction, [:pointer, :verifier_failure_action], :int
15
+ end
16
+
17
+ class Module
18
+ def verify
19
+ do_verification(:return_status)
20
+ end
21
+
22
+ def verify!
23
+ do_verification(:abort_process)
24
+ end
25
+
26
+ private
27
+ def do_verification(action)
28
+ str = FFI::MemoryPointer.new(FFI.type_size(:pointer))
29
+ status = C.LLVMVerifyModule(self, action, str)
30
+ case status
31
+ when 1 then str.read_string
32
+ else nil
33
+ end
34
+ end
35
+ end
36
+
37
+ class Function
38
+ def verify(action = :abort)
39
+ str = FFI::MemoryPointer.new(FFI.type_size(:pointer))
40
+ case status = C.LLVMVerifyFunction(self, action, str)
41
+ when 1 then str.read_string
42
+ else nil
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,520 @@
1
+ require 'llvm'
2
+
3
+ module LLVM
4
+ module C
5
+ enum :attribute, [
6
+ :ext, 1 << 0,
7
+ :sext, 1 << 1,
8
+ :no_return, 1 << 2,
9
+ :in_reg, 1 << 3,
10
+ :struct_ret, 1 << 4,
11
+ :no_unwind, 1 << 5,
12
+ :no_alias, 1 << 6,
13
+ :by_val, 1 << 7,
14
+ :nest, 1 << 8,
15
+ :read_none, 1 << 9,
16
+ :read_only, 1 << 10,
17
+ :no_inline, 1 << 11,
18
+ :always_inline, 1 << 12,
19
+ :optimize_for_size, 1 << 13,
20
+ :stack_protect, 1 << 14,
21
+ :stack_protect_req, 1 << 15,
22
+ :no_capture, 1 << 21,
23
+ :no_red_zone, 1 << 22,
24
+ :no_implicit_float, 1 << 23,
25
+ :naked, 1 << 24
26
+ ]
27
+
28
+ enum :type_kind, [
29
+ :void,
30
+ :float,
31
+ :double,
32
+ :x86_fp80,
33
+ :fp128,
34
+ :ppc_fp128,
35
+ :label,
36
+ :integer,
37
+ :function,
38
+ :struct,
39
+ :array,
40
+ :pointer,
41
+ :opaque,
42
+ :vector,
43
+ :metadata
44
+ ]
45
+
46
+ enum :linkage, [
47
+ :external,
48
+ :available_externally,
49
+ :link_once_any,
50
+ :link_once_odr,
51
+ :weak_any,
52
+ :weak_odr,
53
+ :appending,
54
+ :internal,
55
+ :private,
56
+ :dll_import,
57
+ :dll_export,
58
+ :external_weak,
59
+ :ghost,
60
+ :common,
61
+ :linker_private
62
+ ]
63
+
64
+ enum :visibility, [
65
+ :default,
66
+ :hidden,
67
+ :protected
68
+ ]
69
+
70
+ enum :call_conv, [
71
+ :ccall, 0,
72
+ :fastcall, 8,
73
+ :coldcall, 9,
74
+ :x86_stdcall, 64,
75
+ :x86_fastcall, 65
76
+ ]
77
+
78
+ enum :int_predicate, [
79
+ :eq, 32,
80
+ :ne, 33,
81
+ :ugt, 34,
82
+ :uge, 35,
83
+ :ult, 36,
84
+ :ule, 37,
85
+ :sgt, 38,
86
+ :sge, 39,
87
+ :slt, 40,
88
+ :sle, 41
89
+ ]
90
+
91
+ enum :real_predicate, [
92
+ :false,
93
+ :oeq,
94
+ :ogt,
95
+ :oge,
96
+ :olt,
97
+ :ole,
98
+ :one,
99
+ :ord,
100
+ :uno,
101
+ :ueq,
102
+ :ugt,
103
+ :uge,
104
+ :ult,
105
+ :ule,
106
+ :une,
107
+ :true
108
+ ]
109
+
110
+ # Error handling
111
+ attach_function :LLVMDisposeMessage, [:pointer], :void
112
+
113
+ # Contexts
114
+ attach_function :LLVMContextCreate, [], :pointer
115
+ attach_function :LLVMGetGlobalContext, [], :pointer
116
+ attach_function :LLVMContextDispose, [:pointer], :void
117
+
118
+ # Modules
119
+ attach_function :LLVMModuleCreateWithName, [:string], :pointer
120
+ attach_function :LLVMModuleCreateWithNameInContext, [:string, :pointer], :pointer
121
+ attach_function :LLVMDisposeModule, [:pointer], :void
122
+ attach_function :LLVMGetDataLayout, [:pointer], :string
123
+ attach_function :LLVMSetDataLayout, [:pointer, :string], :void
124
+ attach_function :LLVMGetTarget, [:pointer], :string
125
+ attach_function :LLVMSetTarget, [:pointer, :string], :void
126
+ attach_function :LLVMAddTypeName, [:pointer, :string, :pointer], :int
127
+ attach_function :LLVMDeleteTypeName, [:pointer, :string], :void
128
+ attach_function :LLVMGetTypeByName, [:pointer, :string], :pointer
129
+ attach_function :LLVMDumpModule, [:pointer], :void
130
+
131
+ # Types
132
+ attach_function :LLVMGetTypeKind, [:pointer], :type_kind
133
+ attach_function :LLVMGetTypeContext, [:pointer], :pointer
134
+
135
+ # Integer types
136
+ attach_function :LLVMInt1TypeInContext, [:pointer], :pointer
137
+ attach_function :LLVMInt8TypeInContext, [:pointer], :pointer
138
+ attach_function :LLVMInt16TypeInContext, [:pointer], :pointer
139
+ attach_function :LLVMInt32TypeInContext, [:pointer], :pointer
140
+ attach_function :LLVMInt64TypeInContext, [:pointer], :pointer
141
+ attach_function :LLVMIntTypeInContext, [:pointer, :uint], :pointer
142
+
143
+ attach_function :LLVMInt1Type, [], :pointer
144
+ attach_function :LLVMInt8Type, [], :pointer
145
+ attach_function :LLVMInt16Type, [], :pointer
146
+ attach_function :LLVMInt32Type, [], :pointer
147
+ attach_function :LLVMInt64Type, [], :pointer
148
+ attach_function :LLVMIntType, [:uint], :pointer
149
+ attach_function :LLVMGetIntTypeWidth, [:pointer], :uint
150
+
151
+ # Real types
152
+ attach_function :LLVMFloatTypeInContext, [:pointer], :pointer
153
+ attach_function :LLVMDoubleTypeInContext, [:pointer], :pointer
154
+ attach_function :LLVMX86FP80TypeInContext, [:pointer], :pointer
155
+ attach_function :LLVMFP128TypeInContext, [:pointer], :pointer
156
+ attach_function :LLVMPPCFP128TypeInContext, [:pointer], :pointer
157
+
158
+ attach_function :LLVMFloatType, [], :pointer
159
+ attach_function :LLVMDoubleType, [], :pointer
160
+ attach_function :LLVMX86FP80Type, [], :pointer
161
+ attach_function :LLVMFP128Type, [], :pointer
162
+ attach_function :LLVMPPCFP128Type, [], :pointer
163
+
164
+ # Function types
165
+ attach_function :LLVMFunctionType, [:pointer, :pointer, :uint, :int], :pointer
166
+ attach_function :LLVMIsFunctionVarArg, [:pointer], :int
167
+ attach_function :LLVMGetReturnType, [:pointer], :pointer
168
+ attach_function :LLVMCountParamTypes, [:pointer], :uint
169
+ attach_function :LLVMGetParamTypes, [:pointer, :pointer], :void
170
+
171
+ # Struct types
172
+ attach_function :LLVMStructTypeInContext, [:pointer, :pointer, :uint, :int], :pointer
173
+ attach_function :LLVMStructType, [:pointer, :uint, :int], :pointer
174
+ attach_function :LLVMCountStructElementTypes, [:pointer], :uint
175
+ attach_function :LLVMGetStructElementTypes, [:pointer, :pointer], :void
176
+ attach_function :LLVMIsPackedStruct, [:pointer], :int
177
+
178
+ # Array, pointer and vector types (sequence types)
179
+ attach_function :LLVMArrayType, [:pointer, :uint], :pointer
180
+ attach_function :LLVMPointerType, [:pointer, :uint], :pointer
181
+ attach_function :LLVMVectorType, [:pointer, :uint], :pointer
182
+
183
+ attach_function :LLVMGetElementType, [:pointer], :pointer
184
+ attach_function :LLVMGetArrayLength, [:pointer], :uint
185
+ attach_function :LLVMGetPointerAddressSpace, [:pointer], :uint
186
+ attach_function :LLVMGetVectorSize, [:pointer], :uint
187
+
188
+ # All other types
189
+ attach_function :LLVMVoidTypeInContext, [:pointer], :pointer
190
+ attach_function :LLVMLabelTypeInContext, [:pointer], :pointer
191
+ attach_function :LLVMOpaqueTypeInContext, [:pointer], :pointer
192
+
193
+ attach_function :LLVMVoidType, [], :pointer
194
+ attach_function :LLVMLabelType, [], :pointer
195
+ attach_function :LLVMOpaqueType, [], :pointer
196
+
197
+ # Type handles
198
+ attach_function :LLVMCreateTypeHandle, [:pointer], :pointer
199
+ attach_function :LLVMRefineType, [:pointer, :pointer], :void
200
+ attach_function :LLVMResolveTypeHandle, [:pointer], :pointer
201
+ attach_function :LLVMDisposeTypeHandle, [:pointer], :void
202
+
203
+ # All values
204
+ attach_function :LLVMTypeOf, [:pointer], :pointer
205
+ attach_function :LLVMGetValueName, [:pointer], :string
206
+ attach_function :LLVMSetValueName, [:pointer, :string], :void
207
+ attach_function :LLVMDumpValue, [:pointer], :void
208
+
209
+ # Constants of any type
210
+ attach_function :LLVMConstNull, [:pointer], :pointer
211
+ attach_function :LLVMConstAllOnes, [:pointer], :pointer
212
+ attach_function :LLVMGetUndef, [:pointer], :pointer
213
+ attach_function :LLVMIsConstant, [:pointer], :int
214
+ attach_function :LLVMIsNull, [:pointer], :int
215
+ attach_function :LLVMIsUndef, [:pointer], :int
216
+ attach_function :LLVMConstPointerNull, [:pointer], :pointer
217
+
218
+ # Scalar constants
219
+ attach_function :LLVMConstInt, [:pointer, :ulong_long, :int], :pointer
220
+ attach_function :LLVMConstIntOfString, [:pointer, :string, :uint8], :pointer
221
+ attach_function :LLVMConstIntOfStringAndSize, [:pointer, :string, :uint, :uint8], :pointer
222
+ attach_function :LLVMConstReal, [:pointer, :double], :pointer
223
+ attach_function :LLVMConstRealOfString, [:pointer, :string], :pointer
224
+ attach_function :LLVMConstRealOfStringAndSize, [:pointer, :string, :uint], :pointer
225
+
226
+ # Composite constants
227
+ attach_function :LLVMConstStringInContext, [:pointer, :string, :uint, :int], :pointer
228
+ attach_function :LLVMConstStructInContext, [:pointer, :pointer, :uint, :int], :pointer
229
+
230
+ attach_function :LLVMConstString, [:string, :uint, :int], :pointer
231
+ attach_function :LLVMConstArray, [:pointer, :pointer, :uint], :pointer
232
+ attach_function :LLVMConstStruct, [:pointer, :uint, :int], :pointer
233
+ attach_function :LLVMConstVector, [:pointer, :uint], :pointer
234
+
235
+ # Constant expressions
236
+ attach_function :LLVMAlignOf, [:pointer], :pointer
237
+ attach_function :LLVMSizeOf, [:pointer], :pointer
238
+ attach_function :LLVMConstNeg, [:pointer], :pointer
239
+ attach_function :LLVMConstFNeg, [:pointer], :pointer
240
+ attach_function :LLVMConstNot, [:pointer], :pointer
241
+ attach_function :LLVMConstAdd, [:pointer, :pointer], :pointer
242
+ attach_function :LLVMConstNSWAdd, [:pointer, :pointer], :pointer
243
+ attach_function :LLVMConstFAdd, [:pointer, :pointer], :pointer
244
+ attach_function :LLVMConstSub, [:pointer, :pointer], :pointer
245
+ attach_function :LLVMConstFSub, [:pointer, :pointer], :pointer
246
+ attach_function :LLVMConstMul, [:pointer, :pointer], :pointer
247
+ attach_function :LLVMConstFMul, [:pointer, :pointer], :pointer
248
+ attach_function :LLVMConstUDiv, [:pointer, :pointer], :pointer
249
+ attach_function :LLVMConstSDiv, [:pointer, :pointer], :pointer
250
+ attach_function :LLVMConstExactSDiv, [:pointer, :pointer], :pointer
251
+ attach_function :LLVMConstFDiv, [:pointer, :pointer], :pointer
252
+ attach_function :LLVMConstURem, [:pointer, :pointer], :pointer
253
+ attach_function :LLVMConstSRem, [:pointer, :pointer], :pointer
254
+ attach_function :LLVMConstFRem, [:pointer, :pointer], :pointer
255
+ attach_function :LLVMConstAnd, [:pointer, :pointer], :pointer
256
+ attach_function :LLVMConstOr, [:pointer, :pointer], :pointer
257
+ attach_function :LLVMConstXor, [:pointer, :pointer], :pointer
258
+ attach_function :LLVMConstICmp, [:int, :pointer, :pointer], :pointer
259
+ attach_function :LLVMConstFCmp, [:int, :pointer, :pointer], :pointer
260
+ attach_function :LLVMConstShl, [:pointer, :pointer], :pointer
261
+ attach_function :LLVMConstLShr, [:pointer, :pointer], :pointer
262
+ attach_function :LLVMConstAShr, [:pointer, :pointer], :pointer
263
+ attach_function :LLVMConstGEP, [:pointer, :pointer, :uint], :pointer
264
+ attach_function :LLVMConstInBoundsGEP, [:pointer, :pointer, :uint], :pointer
265
+ attach_function :LLVMConstTrunc, [:pointer, :pointer], :pointer
266
+ attach_function :LLVMConstSExt, [:pointer, :pointer], :pointer
267
+ attach_function :LLVMConstZExt, [:pointer, :pointer], :pointer
268
+ attach_function :LLVMConstFPTrunc, [:pointer, :pointer], :pointer
269
+ attach_function :LLVMConstFPExt, [:pointer, :pointer], :pointer
270
+ attach_function :LLVMConstUIToFP, [:pointer, :pointer], :pointer
271
+ attach_function :LLVMConstSIToFP, [:pointer, :pointer], :pointer
272
+ attach_function :LLVMConstFPToUI, [:pointer, :pointer], :pointer
273
+ attach_function :LLVMConstFPToSI, [:pointer, :pointer], :pointer
274
+ attach_function :LLVMConstPtrToInt, [:pointer, :pointer], :pointer
275
+ attach_function :LLVMConstIntToPtr, [:pointer, :pointer], :pointer
276
+ attach_function :LLVMConstBitCast, [:pointer, :pointer], :pointer
277
+ attach_function :LLVMConstZExtOrBitCast, [:pointer, :pointer], :pointer
278
+ attach_function :LLVMConstSExtOrBitCast, [:pointer, :pointer], :pointer
279
+ attach_function :LLVMConstTruncOrBitCast, [:pointer, :pointer], :pointer
280
+ attach_function :LLVMConstPointerCast, [:pointer, :pointer], :pointer
281
+ attach_function :LLVMConstIntCast, [:pointer, :pointer, :uint], :pointer
282
+ attach_function :LLVMConstFPCast, [:pointer, :pointer], :pointer
283
+ attach_function :LLVMConstSelect, [:pointer, :pointer, :pointer], :pointer
284
+ attach_function :LLVMConstExtractElement, [:pointer, :pointer], :pointer
285
+ attach_function :LLVMConstInsertElement, [:pointer, :pointer], :pointer
286
+ attach_function :LLVMConstShuffleVector, [:pointer, :pointer, :pointer], :pointer
287
+ attach_function :LLVMConstExtractValue, [:pointer, :pointer, :uint], :pointer
288
+ attach_function :LLVMConstInsertValue, [:pointer, :pointer, :pointer, :uint], :pointer
289
+ attach_function :LLVMConstInlineAsm, [:pointer, :string, :string, :int], :pointer
290
+
291
+ # Global variables, functions and aliases (globals)
292
+ attach_function :LLVMGetGlobalParent, [:pointer], :pointer
293
+ attach_function :LLVMIsDeclaration, [:pointer], :int
294
+ attach_function :LLVMGetLinkage, [:pointer], :linkage
295
+ attach_function :LLVMSetLinkage, [:pointer, :linkage], :void
296
+ attach_function :LLVMGetSection, [:pointer], :string
297
+ attach_function :LLVMSetSection, [:pointer, :string], :void
298
+ attach_function :LLVMGetVisibility, [:pointer], :visibility
299
+ attach_function :LLVMSetVisibility, [:pointer, :visibility], :void
300
+ attach_function :LLVMGetAlignment, [:pointer], :uint
301
+ attach_function :LLVMSetAlignment, [:pointer, :uint], :void
302
+
303
+ attach_function :LLVMAddGlobal, [:pointer, :pointer, :string], :pointer
304
+ attach_function :LLVMGetNamedGlobal, [:pointer, :string], :pointer
305
+ attach_function :LLVMGetFirstGlobal, [:pointer], :pointer
306
+ attach_function :LLVMGetLastGlobal, [:pointer], :pointer
307
+ attach_function :LLVMGetNextGlobal, [:pointer], :pointer
308
+ attach_function :LLVMGetPreviousGlobal, [:pointer], :pointer
309
+ attach_function :LLVMDeleteGlobal, [:pointer], :void
310
+ attach_function :LLVMGetInitializer, [:pointer], :pointer
311
+ attach_function :LLVMSetInitializer, [:pointer, :pointer], :void
312
+ attach_function :LLVMIsThreadLocal, [:pointer], :int
313
+ attach_function :LLVMSetThreadLocal, [:pointer, :int], :void
314
+ attach_function :LLVMIsGlobalConstant, [:pointer], :int
315
+ attach_function :LLVMSetGlobalConstant, [:pointer, :int], :void
316
+
317
+ # Aliases
318
+ attach_function :LLVMAddAlias, [:pointer, :pointer, :pointer, :string], :pointer
319
+
320
+ # Function operations
321
+ attach_function :LLVMAddFunction, [:pointer, :string, :pointer], :pointer
322
+ attach_function :LLVMGetNamedFunction, [:pointer, :string], :pointer
323
+ attach_function :LLVMGetFirstFunction, [:pointer], :pointer
324
+ attach_function :LLVMGetLastFunction, [:pointer], :pointer
325
+ attach_function :LLVMGetNextFunction, [:pointer], :pointer
326
+ attach_function :LLVMGetPreviousFunction, [:pointer], :pointer
327
+ attach_function :LLVMDeleteFunction, [:pointer], :void
328
+ attach_function :LLVMGetIntrinsicID, [:pointer], :uint
329
+ attach_function :LLVMGetFunctionCallConv, [:pointer], :call_conv
330
+ attach_function :LLVMSetFunctionCallConv, [:pointer, :call_conv], :void
331
+ attach_function :LLVMGetGC, [:pointer], :string
332
+ attach_function :LLVMSetGC, [:pointer, :string], :void
333
+ attach_function :LLVMAddFunctionAttr, [:pointer, :attribute], :void
334
+ attach_function :LLVMRemoveFunctionAttr, [:pointer, :attribute], :void
335
+
336
+ # Parameters
337
+ attach_function :LLVMCountParams, [:pointer], :uint
338
+ attach_function :LLVMGetParams, [:pointer, :pointer], :void
339
+ attach_function :LLVMGetParam, [:pointer, :uint], :pointer
340
+ attach_function :LLVMGetParamParent, [:pointer], :pointer
341
+ attach_function :LLVMGetFirstParam, [:pointer], :pointer
342
+ attach_function :LLVMGetLastParam, [:pointer], :pointer
343
+ attach_function :LLVMGetNextParam, [:pointer], :pointer
344
+ attach_function :LLVMGetPreviousParam, [:pointer], :pointer
345
+ attach_function :LLVMAddAttribute, [:pointer, :attribute], :void
346
+ attach_function :LLVMRemoveAttribute, [:pointer, :attribute], :void
347
+ attach_function :LLVMSetParamAlignment, [:pointer, :uint], :void
348
+
349
+ # Basic blocks
350
+ attach_function :LLVMBasicBlockAsValue, [:pointer], :pointer
351
+ attach_function :LLVMValueIsBasicBlock, [:pointer], :int
352
+ attach_function :LLVMValueAsBasicBlock, [:pointer], :pointer
353
+ attach_function :LLVMGetBasicBlockParent, [:pointer], :pointer
354
+ attach_function :LLVMCountBasicBlocks, [:pointer], :uint
355
+ attach_function :LLVMGetBasicBlocks, [:pointer, :pointer], :void
356
+ attach_function :LLVMGetFirstBasicBlock, [:pointer], :pointer
357
+ attach_function :LLVMGetLastBasicBlock, [:pointer], :pointer
358
+ attach_function :LLVMGetNextBasicBlock, [:pointer], :pointer
359
+ attach_function :LLVMGetPreviousBasicBlock, [:pointer], :pointer
360
+ attach_function :LLVMGetEntryBasicBlock, [:pointer], :pointer
361
+
362
+ attach_function :LLVMAppendBasicBlockInContext, [:pointer, :pointer, :string], :pointer
363
+ attach_function :LLVMInsertBasicBlockInContext, [:pointer, :pointer, :string], :pointer
364
+
365
+ attach_function :LLVMAppendBasicBlock, [:pointer, :string], :pointer
366
+ attach_function :LLVMDeleteBasicBlock, [:pointer], :void
367
+
368
+ # Instructions
369
+ attach_function :LLVMGetInstructionParent, [:pointer], :pointer
370
+ attach_function :LLVMGetFirstInstruction, [:pointer], :pointer
371
+ attach_function :LLVMGetLastInstruction, [:pointer], :pointer
372
+ attach_function :LLVMGetNextInstruction, [:pointer], :pointer
373
+ attach_function :LLVMGetPreviousInstruction, [:pointer], :pointer
374
+
375
+ # Call sites
376
+ attach_function :LLVMSetInstructionCallConv, [:pointer, :call_conv], :void
377
+ attach_function :LLVMGetInstructionCallConv, [:pointer], :call_conv
378
+ attach_function :LLVMAddInstrAttribute, [:pointer, :uint, :attribute], :void
379
+ attach_function :LLVMRemoveInstrAttribute, [:pointer, :uint, :attribute], :void
380
+ attach_function :LLVMSetInstrParamAlignment, [:pointer, :uint, :uint], :void
381
+
382
+ # Call instructions
383
+ attach_function :LLVMIsTailCall, [:pointer], :int
384
+ attach_function :LLVMSetTailCall, [:pointer, :int], :void
385
+
386
+ # Phi nodes
387
+ attach_function :LLVMAddIncoming, [:pointer, :pointer, :pointer, :uint], :void
388
+ attach_function :LLVMCountIncoming, [:pointer], :uint
389
+ attach_function :LLVMGetIncomingValue, [:pointer, :uint], :pointer
390
+ attach_function :LLVMGetIncomingBlock, [:pointer, :uint], :pointer
391
+
392
+ # Instruction builders
393
+ attach_function :LLVMCreateBuilderInContext, [:pointer], :pointer
394
+ attach_function :LLVMCreateBuilder, [], :pointer
395
+ attach_function :LLVMPositionBuilder, [:pointer, :pointer, :pointer], :void
396
+ attach_function :LLVMPositionBuilderBefore, [:pointer, :pointer], :void
397
+ attach_function :LLVMPositionBuilderAtEnd, [:pointer, :pointer], :void
398
+ attach_function :LLVMGetInsertBlock, [:pointer], :pointer
399
+ attach_function :LLVMClearInsertionPosition, [:pointer], :void
400
+ attach_function :LLVMInsertIntoBuilder, [:pointer, :pointer], :void
401
+ attach_function :LLVMInsertIntoBuilderWithName, [:pointer, :pointer, :string], :void
402
+ attach_function :LLVMDisposeBuilder, [:pointer], :void
403
+
404
+ # Terminators
405
+ attach_function :LLVMBuildRetVoid, [:pointer], :pointer
406
+ attach_function :LLVMBuildRet, [:pointer, :pointer], :pointer
407
+ attach_function :LLVMBuildAggregateRet, [:pointer, :pointer, :uint], :pointer
408
+ attach_function :LLVMBuildBr, [:pointer, :pointer], :pointer
409
+ attach_function :LLVMBuildCondBr, [:pointer, :pointer, :pointer, :pointer], :pointer
410
+ attach_function :LLVMBuildSwitch, [:pointer, :pointer, :pointer, :uint], :pointer
411
+ attach_function :LLVMBuildInvoke, [:pointer, :pointer, :pointer, :uint, :pointer, :pointer, :string], :pointer
412
+ attach_function :LLVMBuildUnwind, [:pointer], :pointer
413
+ attach_function :LLVMBuildUnreachable, [:pointer], :pointer
414
+
415
+ # Switch instruction
416
+ attach_function :LLVMAddCase, [:pointer, :pointer, :pointer], :void
417
+
418
+ # Arithmetic
419
+ attach_function :LLVMBuildAdd, [:pointer, :pointer, :pointer, :string], :pointer
420
+ attach_function :LLVMBuildNSWAdd, [:pointer, :pointer, :pointer, :string], :pointer
421
+ attach_function :LLVMBuildFAdd, [:pointer, :pointer, :pointer, :string], :pointer
422
+ attach_function :LLVMBuildSub, [:pointer, :pointer, :pointer, :string], :pointer
423
+ attach_function :LLVMBuildFSub, [:pointer, :pointer, :pointer, :string], :pointer
424
+ attach_function :LLVMBuildMul, [:pointer, :pointer, :pointer, :string], :pointer
425
+ attach_function :LLVMBuildFMul, [:pointer, :pointer, :pointer, :string], :pointer
426
+ attach_function :LLVMBuildUDiv, [:pointer, :pointer, :pointer, :string], :pointer
427
+ attach_function :LLVMBuildSDiv, [:pointer, :pointer, :pointer, :string], :pointer
428
+ attach_function :LLVMBuildExactSDiv, [:pointer, :pointer, :pointer, :string], :pointer
429
+ attach_function :LLVMBuildFDiv, [:pointer, :pointer, :pointer, :string], :pointer
430
+ attach_function :LLVMBuildURem, [:pointer, :pointer, :pointer, :string], :pointer
431
+ attach_function :LLVMBuildSRem, [:pointer, :pointer, :pointer, :string], :pointer
432
+ attach_function :LLVMBuildFRem, [:pointer, :pointer, :pointer, :string], :pointer
433
+ attach_function :LLVMBuildShl, [:pointer, :pointer, :pointer, :string], :pointer
434
+ attach_function :LLVMBuildLShr, [:pointer, :pointer, :pointer, :string], :pointer
435
+ attach_function :LLVMBuildAShr, [:pointer, :pointer, :pointer, :string], :pointer
436
+ attach_function :LLVMBuildAnd, [:pointer, :pointer, :pointer, :string], :pointer
437
+ attach_function :LLVMBuildOr, [:pointer, :pointer, :pointer, :string], :pointer
438
+ attach_function :LLVMBuildXor, [:pointer, :pointer, :pointer, :string], :pointer
439
+ attach_function :LLVMBuildNeg, [:pointer, :pointer, :string], :pointer
440
+ attach_function :LLVMBuildNot, [:pointer, :pointer, :string], :pointer
441
+
442
+ # Memory
443
+ attach_function :LLVMBuildMalloc, [:pointer, :pointer, :string], :pointer
444
+ attach_function :LLVMBuildArrayMalloc, [:pointer, :pointer, :pointer, :string], :string
445
+ attach_function :LLVMBuildAlloca, [:pointer, :pointer, :string], :pointer
446
+ attach_function :LLVMBuildArrayAlloca, [:pointer, :pointer, :string], :pointer
447
+ attach_function :LLVMBuildFree, [:pointer, :pointer], :pointer
448
+ attach_function :LLVMBuildLoad, [:pointer, :pointer, :string], :pointer
449
+ attach_function :LLVMBuildStore, [:pointer, :pointer, :pointer], :pointer
450
+ attach_function :LLVMBuildGEP, [:pointer, :pointer, :pointer, :uint, :string], :pointer
451
+ attach_function :LLVMBuildInBoundsGEP, [:pointer, :pointer, :pointer, :uint, :string], :pointer
452
+ attach_function :LLVMBuildStructGEP, [:pointer, :pointer, :uint, :string], :pointer
453
+ attach_function :LLVMBuildGlobalString, [:pointer, :string, :string], :pointer
454
+ attach_function :LLVMBuildGlobalStringPtr, [:pointer, :string, :string], :pointer
455
+
456
+ # Casts
457
+ attach_function :LLVMBuildTrunc, [:pointer, :pointer, :pointer, :string], :pointer
458
+ attach_function :LLVMBuildZExt, [:pointer, :pointer, :pointer, :string], :pointer
459
+ attach_function :LLVMBuildSExt, [:pointer, :pointer, :pointer, :string], :pointer
460
+ attach_function :LLVMBuildFPToUI, [:pointer, :pointer, :pointer, :string], :pointer
461
+ attach_function :LLVMBuildFPToSI, [:pointer, :pointer, :pointer, :string], :pointer
462
+ attach_function :LLVMBuildUIToFP, [:pointer, :pointer, :string], :pointer
463
+ attach_function :LLVMBuildSIToFP, [:pointer, :pointer, :pointer, :string], :pointer
464
+ attach_function :LLVMBuildFPTrunc, [:pointer, :pointer, :pointer, :string], :pointer
465
+ attach_function :LLVMBuildFPExt, [:pointer, :pointer, :pointer, :string], :pointer
466
+ attach_function :LLVMBuildPtrToInt, [:pointer, :pointer, :pointer, :string], :pointer
467
+ attach_function :LLVMBuildIntToPtr, [:pointer, :pointer, :pointer, :string], :pointer
468
+ attach_function :LLVMBuildBitCast, [:pointer, :pointer, :pointer, :string], :pointer
469
+ attach_function :LLVMBuildZExtOrBitCast, [:pointer, :pointer, :pointer, :string], :pointer
470
+ attach_function :LLVMBuildSExtOrBitCast, [:pointer, :pointer, :pointer, :string], :pointer
471
+ attach_function :LLVMBuildTruncOrBitCast, [:pointer, :pointer, :pointer, :string], :pointer
472
+ attach_function :LLVMBuildPointerCast, [:pointer, :pointer, :pointer, :string], :pointer
473
+ attach_function :LLVMBuildIntCast, [:pointer, :pointer, :pointer, :string], :pointer
474
+ attach_function :LLVMBuildFPCast, [:pointer, :pointer, :pointer, :string], :pointer
475
+
476
+ # Comparisons
477
+ attach_function :LLVMBuildICmp, [:pointer, :int_predicate, :pointer, :pointer, :string], :pointer
478
+ attach_function :LLVMBuildFCmp, [:pointer, :real_predicate, :pointer, :pointer, :string], :pointer
479
+
480
+ # Misc
481
+ attach_function :LLVMBuildPhi, [:pointer, :pointer, :string], :pointer
482
+ attach_function :LLVMBuildCall, [:pointer, :pointer, :pointer, :uint, :string], :pointer
483
+ attach_function :LLVMBuildSelect, [:pointer, :pointer, :pointer, :pointer, :string], :pointer
484
+ attach_function :LLVMBuildVAArg, [:pointer, :pointer, :pointer, :string], :pointer
485
+ attach_function :LLVMBuildExtractElement, [:pointer, :pointer, :pointer, :string], :pointer
486
+ attach_function :LLVMBuildInsertElement, [:pointer, :pointer, :pointer, :pointer, :string], :pointer
487
+ attach_function :LLVMBuildShuffleVector, [:pointer, :pointer, :pointer, :pointer, :string], :pointer
488
+ attach_function :LLVMBuildExtractValue, [:pointer, :pointer, :uint, :string], :pointer
489
+ attach_function :LLVMBuildInsertValue, [:pointer, :pointer, :pointer, :uint, :string], :pointer
490
+
491
+ attach_function :LLVMBuildIsNull, [:pointer, :pointer, :string], :pointer
492
+ attach_function :LLVMBuildIsNotNull, [:pointer, :pointer, :string], :pointer
493
+ attach_function :LLVMBuildPtrDiff, [:pointer, :pointer, :pointer, :string], :pointer
494
+
495
+ # Module providers
496
+ attach_function :LLVMCreateModuleProviderForExistingModule, [:pointer], :pointer
497
+ attach_function :LLVMDisposeModuleProvider, [:pointer], :void
498
+
499
+ # Memory buffers
500
+ attach_function :LLVMCreateMemoryBufferWithContentsOfFile, [:string, :pointer, :pointer], :int
501
+ attach_function :LLVMCreateMemoryBufferWithSTDIN, [:pointer, :pointer], :int
502
+ attach_function :LLVMDisposeMemoryBuffer, [:pointer], :void
503
+
504
+ # Pass managers
505
+ attach_function :LLVMCreatePassManager, [], :pointer
506
+ attach_function :LLVMCreateFunctionPassManager, [:pointer], :pointer
507
+ attach_function :LLVMRunPassManager, [:pointer, :pointer], :int
508
+ attach_function :LLVMInitializeFunctionPassManager, [:pointer], :int
509
+ attach_function :LLVMRunFunctionPassManager, [:pointer, :pointer], :int
510
+ attach_function :LLVMFinalizeFunctionPassManager, [:pointer], :int
511
+ attach_function :LLVMDisposePassManager, [:pointer], :void
512
+ end
513
+
514
+ require 'llvm/core/context'
515
+ require 'llvm/core/module'
516
+ require 'llvm/core/type'
517
+ require 'llvm/core/value'
518
+ require 'llvm/core/builder'
519
+ require 'llvm/core/pass_manager'
520
+ end