Added support for intrinsics.
As access to intrinsics is not exposed by LLVM-C API, a custom C++ library
exposing those hase been added - llvm_c_ext. Smalltalk binds to this library
in addition to LLVM's.
In a future this library will expose whatever C++ API will be needed
in scope of this project. However, it's designed to usable standalone, i.e.,
it contains no Smalltalk-specic code.
--- a/.hgignore Mon Aug 10 10:33:42 2015 +0100
+++ b/.hgignore Mon Aug 10 19:26:29 2015 +0100
@@ -14,3 +14,7 @@
java/libs-src/*.jar
*-Test.xml
st.chg
+
+# llvm_c_ext build by-products
+*.a
+llvm_c_ext/test/test_intrinsics
--- a/LLVM.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVM.st Mon Aug 10 19:26:29 2015 +0100
@@ -38,6 +38,22 @@
This license is provisional and may (will) change in
a future.
"
+!
+
+documentation
+"
+ This class contains all callouts to libLLVM-x.y.z.so. To internal use only!!
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
! !
!LLVM class methodsFor:'accessing'!
--- a/LLVMBuilder.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVMBuilder.st Mon Aug 10 19:26:29 2015 +0100
@@ -71,69 +71,6 @@
"Created: / 10-08-2015 / 09:03:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!LLVMBuilder methodsFor:'assertions'!
-
-assertIsBasicBlockValue:value
- <resource: #skipInDebuggersWalkback>
-
- self assert:value isLLVMValue.
- self assert:value isBasicBlockValue
-
- "Created: / 08-08-2015 / 02:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-assertIsIntegerOrIntegerVectorValue:value
- <resource: #skipInDebuggersWalkback>
-
- self assert:(value class == LLVMValue) message:'value is not an LLVMValue'.
- self assert:(value isIntegerOrIntegerVectorValue)
-
- "Modified (format): / 08-08-2015 / 02:41:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-assertIsString:aString
- <resource: #skipInDebuggersWalkback>
-
- self assert:aString isSingleByteString description:'string is not a valid LLVM name (twine)'
-
- "Created: / 07-08-2015 / 18:38:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 08-08-2015 / 02:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-assertIsType: type
- <resource: #skipInDebuggersWalkback>
-
- self assert: type isLLVMType message: 'value is not an LLVMType'.
-
- "Created: / 10-08-2015 / 06:26:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-assertIsValue: value
- <resource: #skipInDebuggersWalkback>
-
- self assert: value isLLVMValue message: 'value is not an LLVMValue'.
-
- "Created: / 08-08-2015 / 03:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-assertIsValue: value ofType: type
- <resource: #skipInDebuggersWalkback>
-
- self assert: value isLLVMValue message: 'value is not an LLVMValue'.
- self assert: value type = type message: 'value has incorrect type'
-
- "Created: / 08-08-2015 / 02:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-assertIsValueOfSameType:value1 as:value2
- <resource: #skipInDebuggersWalkback>
-
- self assert: value1 type = value2 type message:'types of values differ!!'
-
- "Created: / 07-08-2015 / 18:37:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-08-2015 / 02:57:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
!LLVMBuilder methodsFor:'initialization & release'!
dispose
@@ -142,6 +79,27 @@
"Modified (comment): / 08-07-2015 / 22:39:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!LLVMBuilder methodsFor:'instructions - aggregates'!
+
+extractvalue: value at: index
+ ^ self extractvalue: value at: index as: ''
+
+ "Created: / 10-08-2015 / 17:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+extractvalue: value at: index as: name
+
+
+ self assertIsValue: value.
+ self assert: ((value type kind == LLVMStructTypeKind) or:[ value type kind == LLVMArrayTypeKind ]) message: 'value is not a struct or an array'.
+ self assert: index isInteger message: 'index is not an integer'.
+
+ ^ LLVM BuildExtractValue: self _: value _: index _: name.
+
+
+ "Created: / 10-08-2015 / 17:39:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!LLVMBuilder methodsFor:'instructions - binary'!
add:value1 _:value2
@@ -354,10 +312,10 @@
gep: pointer at: integerOrArrayOfIntegers as: name
| indices |
- self assert: (pointer isKindOf: LLVMValue).
+ self assertIsValue: pointer ofKind: LLVMPointerTypeKind.
self assert: (integerOrArrayOfIntegers isInteger
or:[ integerOrArrayOfIntegers isSequenceable and:[ integerOrArrayOfIntegers allSatisfy:[:e|e isInteger] ] ]).
- self assert: (name isSingleByteString).
+ self assertIsString: name.
integerOrArrayOfIntegers isInteger ifTrue:[
indices := LLVMObjectArray with: (LLVMConstant uint32: integerOrArrayOfIntegers)
] ifFalse:[
@@ -369,6 +327,7 @@
^ LLVM BuildGEP: self _: pointer _: indices _: indices size _: name.
"Created: / 05-08-2015 / 20:58:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 17:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
load: pointer
@@ -397,45 +356,24 @@
!LLVMBuilder methodsFor:'instructions - other'!
-call: function with: arg1
- ^ self call: function withArguments: (Array with: arg1) as: ''.
+call: function _: args
+ ^ self call: function _: args as: ''.
- "Created: / 17-07-2015 / 12:48:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-call: function with: arg1 with: arg2
- ^ self call: function withArguments: (Array with: arg1 with: arg2) as: ''.
-
- "Created: / 17-07-2015 / 12:48:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 10-08-2015 / 18:53:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-call: function with: arg1 with: arg2 with: arg3
- ^ self call: function withArguments: (Array with: arg1 with: arg2 with: arg3) as: ''.
-
- "Created: / 17-07-2015 / 12:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-call: function withArguments: arguments
- ^ self call: function withArguments: arguments as: ''.
-
- "Created: / 17-07-2015 / 12:47:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-call: function withArguments: arguments as: name
+call: function _: arguments as: name
| argumentsArray argumentsSize |
- self assert: (function isKindOf: LLVMFunction).
- self assert: (arguments isCollection).
- arguments do:[:argument |
- self assert: (argument isKindOf:LLVMValue).
- ].
- self assert: name isSingleByteString.
+ self assertIsFunctionValue: function.
+ self assertIsValueArray: arguments.
+ self assertIsString: name.
argumentsSize := arguments size.
argumentsArray := arguments asLLVMObjectArray.
^ LLVM BuildCall: self _: function _: argumentsArray _: argumentsSize _: name
- "Created: / 17-07-2015 / 11:09:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 10-08-2015 / 18:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMBuilder methodsFor:'instructions - terminators'!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LLVMCEXT.st Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,104 @@
+"
+ Copyright (C) 2015-now Jan Vrany
+
+ This code is not an open-source (yet). You may use this code
+ for your own experiments and projects, given that:
+
+ * all modification to the code will be sent to the
+ original author for inclusion in future releases
+ * this is not used in any commercial software
+
+ This license is provisional and may (will) change in
+ a future.
+"
+"{ Package: 'jv:llvm_s' }"
+
+"{ NameSpace: Smalltalk }"
+
+Object subclass:#LLVMCEXT
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'LLVM-S-Internal'
+!
+
+!LLVMCEXT class methodsFor:'documentation'!
+
+copyright
+"
+ Copyright (C) 2015-now Jan Vrany
+
+ This code is not an open-source (yet). You may use this code
+ for your own experiments and projects, given that:
+
+ * all modification to the code will be sent to the
+ original author for inclusion in future releases
+ * this is not used in any commercial software
+
+ This license is provisional and may (will) change in
+ a future.
+"
+!
+
+documentation
+"
+ This class contains call out to LLVM C API extensions library
+ (which is part of llvm-s bindings).
+
+ This library exposes important LLVM C++ API tp C users, including:
+ * access to intrinsics
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+! !
+
+!LLVMCEXT class methodsFor:'accessing'!
+
+libraryName
+ | pkgDir |
+ pkgDir := Smalltalk getPackageDirectoryForPackage: #jv:llvm_s.
+ pkgDir isNil ifTrue:[
+ self error: 'Cannot find package directory for jv:llvm_c. Check #packagePath'.
+ ].
+ OperatingSystem isUNIXlike ifTrue:[
+ ^ (pkgDir / 'llvm_c_ext' / 'lib' / 'libLLVM-C-EXT.so') pathName
+ ].
+ self error:'Unsupported operating system'
+
+ "Created: / 10-08-2015 / 16:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!LLVMCEXT class methodsFor:'primitives'!
+
+GetIntrinsicByName: mod _: name _: count _: types
+ "@param mod: LLVMValueRef
+ @param name: const char *
+ @param count: int32
+ @param types: LLVMTypeRef*
+ @return: LLVMValue
+ "
+
+ <cdecl: LLVMFunction "LLVMGetIntrinsicByName" ( LLVMModule charPointer int32 pointer ) >
+ self primitiveFailed
+
+ "Created: / 10-08-2015 / 17:02:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!LLVMCEXT class methodsFor:'documentation'!
+
+version
+ ^ 'Path: jv/llvm_s/LLVMCEXT.st, Version: 1.0, User: jv, Time: 2015-08-10T19:13:47.892+01'
+!
+
+version_HG
+ ^ 'Path: jv/llvm_s/LLVMCEXT.st, Version: 1.0, User: jv, Time: 2015-08-10T19:13:47.892+01'
+! !
+
--- a/LLVMExamples.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVMExamples.st Mon Aug 10 19:26:29 2015 +0100
@@ -122,8 +122,8 @@
callerFunction := module addFunctionNamed: 'sum_caller' type: callerFunctionType.
asm := callerFunction builder.
- asm ret: (asm call: calleeFunction with: (callerFunction parameterAt: 1) with: (callerFunction parameterAt: 2)).
- self assert: (module dumpString =
+ asm ret: (asm call: calleeFunction _: { (callerFunction parameterAt: 1) . (callerFunction parameterAt: 2) }).
+ self assert: (module dumpString =
'; ModuleID = ''example2_function_call''
define i64 @sum(i64, i64) {
@@ -149,7 +149,7 @@
"
"Created: / 17-07-2015 / 12:45:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-08-2015 / 04:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 18:58:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
example3_hello_world
@@ -174,7 +174,7 @@
mainFunction := module addFunctionNamed: 'main' type: mainFunctionType.
asm := mainFunction builder.
- asm call: printfFunction with: (asm gep: helloWorldString at: #(0 0)).
+ asm call: printfFunction _: { asm gep: helloWorldString at: #(0 0) }.
asm ret: (LLVMConstant sint32: 0).
"
module writeBitcodeToFile: '/tmp/main.bc'
@@ -190,7 +190,7 @@
"
"Created: / 03-08-2015 / 10:28:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-08-2015 / 04:34:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 18:58:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
example4_cond
@@ -303,5 +303,97 @@
"
"Created: / 10-08-2015 / 09:46:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+example5_factorial_with_overflow
+ "
+ Simple factorial using recursive algorithm.
+ This one checks for overflow, if overflow happens,
+ return -1
+ "
+
+ | module
+ functionType function asm
+ "Variables" result i
+ "Blocks" entry loop loopBody1 loopBody2 exit overflow
+ smulWithOverflow
+ smulWithOverflowValue
+ jit externalFunction |
+
+ module := LLVMModule newWithName: testSelector.
+
+ functionType := LLVMType function: { LLVMType intptr } returning: LLVMType intptr.
+ function := module addFunctionNamed: 'factorial' type: functionType.
+
+ asm := LLVMBuilder new.
+ entry := function entry.
+ loop := function addBasicBlockNamed: 'loop'.
+ loopBody1 := function addBasicBlockNamed: 'loopBody1'.
+ loopBody2 := function addBasicBlockNamed: 'loopBody2'.
+ exit := function addBasicBlockNamed: 'exit'.
+ overflow := function addBasicBlockNamed: 'overflow'.
+
+ "/ Generate function setup
+ "/
+ "/ function f(v) {
+ "/ var result;
+ "/ var i;
+ "/ result = 0;
+ "/ i := v;
+ asm block: entry.
+ result := asm alloca: LLVMType intptr as: 'result'.
+ i := asm alloca: LLVMType intptr as: 'i'.
+ asm store: (function parameterAt: 1) _: i.
+ asm store: (function parameterAt: 1) _: result.
+ asm br: loop.
+
+ "/ Generate loop that computes the factorial
+ "/
+ "/ while ( i > 1 ) {
+ "/ result = result * i if overflow goto overflow;
+ "/ i = i - 1.
+ "/ }
+ "/
+ "/ First, get the llvm.smul.with.overflow intrinsic:
+ smulWithOverflow := module getIntrinsicNamed: 'llvm.smul.with.overflow' types: { LLVMType intptr }.
+
+ "/ Now code the loop
+ asm block: loop.
+ asm if: (asm icmp: (asm load: i) _: (LLVMConstant sintptr:1) cond: LLVMIntSGT) then: loopBody1 else: exit.
+ asm block: loopBody1.
+ smulWithOverflowValue := asm call: smulWithOverflow _: { (asm load: result) . (asm load: i) }.
+ asm if: (asm extractvalue: smulWithOverflowValue at: 1) then: overflow else: loopBody2.
+ asm block: loopBody2.
+ asm store: (asm extractvalue: smulWithOverflowValue at: 0) _: result.
+ asm store: (asm sub: (asm load: i) _: (LLVMConstant sintptr:1)) _: i.
+ asm br: loop.
+
+ "/ Generate return from function
+ "/
+ "/ return result;
+ "/
+ asm block: exit.
+ asm ret: (asm load: result).
+
+ "/ Generate overflow handler
+ "/ overflow:
+ "/ return -1;
+ "/
+ asm block: overflow.
+ asm ret: (LLVMConstant sintptr: -1).
+
+
+ jit := LLVMExecutionEngine newForModule: module.
+ externalFunction := jit externalOfFunction: function.
+
+ self assert: (externalFunction callWith: 5) == 120.
+ self assert: (externalFunction callWith: 1) == 1.
+ self assert: (externalFunction callWith: 120) == -1.
+
+ "sly LLVMExamples example3_cond
+ "
+
+ "Created: / 10-08-2015 / 17:12:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 18:58:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
--- a/LLVMFunction.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVMFunction.st Mon Aug 10 19:26:29 2015 +0100
@@ -131,3 +131,11 @@
"Created: / 11-07-2015 / 10:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!LLVMFunction methodsFor:'testing'!
+
+isLLVMFunction
+ ^ true
+
+ "Created: / 10-08-2015 / 19:02:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/LLVMModule.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVMModule.st Mon Aug 10 19:26:29 2015 +0100
@@ -59,25 +59,26 @@
!LLVMModule methodsFor:'adding & removing'!
addFunctionNamed: name type: type
- self assert: name isSingleByteString.
+ self assertIsString: name.
self assert: type kind == LLVMFunctionTypeKind.
^ LLVM AddFunction: self _: name _: type.
"Created: / 07-07-2015 / 21:59:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 17:07:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
addGlobalNamed: name type: type value: value
| global |
- self assert: name isSingleByteString.
- self assert:(type isKindOf: LLVMType).
- self assert:(value isKindOf: LLVMValue).
- self assert:(value type kind == type kind).
+ self assertIsString: name.
+ self assertIsType: type.
+ self assertIsValue: value ofType: type.
global := LLVM AddGlobal: self _: type _: name.
LLVM SetInitializer: global _: value.
^ global
"Created: / 03-08-2015 / 16:41:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 17:07:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
addGlobalNamed: name value: value
@@ -101,6 +102,14 @@
^ LLVM AddMethod: self _: name _: type.
"Created: / 11-07-2015 / 09:37:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+getIntrinsicNamed: name types: types
+ self assertIsString: name.
+ self assertIsTypeArray: types.
+ ^ LLVMCEXT GetIntrinsicByName: self _: name _: types size _: types asLLVMObjectArray.
+
+ "Created: / 10-08-2015 / 17:06:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!LLVMModule methodsFor:'debugging'!
@@ -151,11 +160,12 @@
^ (self newInspector2Tab)
label:'Assembly';
- priority:50;
+ priority:49;
text: [ String streamContents:[:s | self writeAssemblyOn: s] ];
yourself
"Created: / 05-08-2015 / 23:47:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-08-2015 / 17:49:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
inspector2TabIR
--- a/LLVMModuleProvider.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVMModuleProvider.st Mon Aug 10 19:26:29 2015 +0100
@@ -48,3 +48,10 @@
"Modified: / 08-07-2015 / 22:40:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!LLVMModuleProvider class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- a/LLVMObject.st Mon Aug 10 10:33:42 2015 +0100
+++ b/LLVMObject.st Mon Aug 10 19:26:29 2015 +0100
@@ -18,7 +18,7 @@
ExternalAddress subclass:#LLVMObject
instanceVariableNames:''
classVariableNames:''
- poolDictionaries:''
+ poolDictionaries:'LLVMTypeKind'
category:'LLVM-S-Internal'
!
@@ -40,3 +40,105 @@
"
! !
+!LLVMObject methodsFor:'assertions'!
+
+assertIsBasicBlockValue:value
+ <resource: #skipInDebuggersWalkback>
+
+ self assert:value isLLVMValue.
+ self assert:value isBasicBlockValue
+
+ "Created: / 08-08-2015 / 02:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsFunctionValue: value
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: value isLLVMFunction message: 'value is not an LLVMFunction'.
+
+ "Created: / 10-08-2015 / 18:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsIntegerOrIntegerVectorValue:value
+ <resource: #skipInDebuggersWalkback>
+
+ self assert:(value class == LLVMValue) message:'value is not an LLVMValue'.
+ self assert:(value isIntegerOrIntegerVectorValue)
+
+ "Modified (format): / 08-08-2015 / 02:41:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsString:aString
+ <resource: #skipInDebuggersWalkback>
+
+ self assert:aString isSingleByteString description:'string is not a valid LLVM name (twine)'
+
+ "Created: / 07-08-2015 / 18:38:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 08-08-2015 / 02:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsType: type
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: type isLLVMType message: 'value is not an LLVMType'.
+
+ "Created: / 10-08-2015 / 06:26:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsTypeArray: types
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: types isSequenceable message: 'types is not a sequenceable collection'.
+ types do:[:type |
+ self assertIsType: type.
+ ].
+
+ "Created: / 10-08-2015 / 17:08:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsValue: value
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: value isLLVMValue message: 'value is not an LLVMValue'.
+
+ "Created: / 08-08-2015 / 03:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsValue: value ofKind: kind
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: value isLLVMValue message: 'value is not an LLVMValue'.
+ self assert: value type kind = kind message: 'value has incorrect kind'
+
+ "Created: / 10-08-2015 / 17:40:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsValue: value ofType: type
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: value isLLVMValue message: 'value is not an LLVMValue'.
+ self assert: value type = type message: 'value has incorrect type'
+
+ "Created: / 08-08-2015 / 02:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsValueArray: values
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: values isSequenceable message: 'values is not a sequenceable collection'.
+ values do:[:value |
+ self assertIsValue: value.
+ ].
+
+ "Created: / 10-08-2015 / 18:56:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertIsValueOfSameType:value1 as:value2
+ <resource: #skipInDebuggersWalkback>
+
+ self assert: value1 type = value2 type message:'types of values differ!!'
+
+ "Created: / 07-08-2015 / 18:37:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 08-08-2015 / 02:57:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/Make.proto Mon Aug 10 10:33:42 2015 +0100
+++ b/Make.proto Mon Aug 10 19:26:29 2015 +0100
@@ -63,8 +63,13 @@
all:: preMake classLibRule postMake
-pre_objs::
+pre_objs:: build_llvm_c_ext
+
+.phony: build_llvm_c_ext
+
+build_llvm_c_ext:
+ $(MAKE) -C llvm_c_ext
@@ -130,6 +135,7 @@
$(OUTDIR)LLVMAtomicRMWBinOp.$(O) LLVMAtomicRMWBinOp.$(H): LLVMAtomicRMWBinOp.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMAttribute.$(O) LLVMAttribute.$(H): LLVMAttribute.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMByteOrdering.$(O) LLVMByteOrdering.$(H): LLVMByteOrdering.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
+$(OUTDIR)LLVMCEXT.$(O) LLVMCEXT.$(H): LLVMCEXT.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)LLVMCallConv.$(O) LLVMCallConv.$(H): LLVMCallConv.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMConfig.$(O) LLVMConfig.$(H): LLVMConfig.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)LLVMConstant.$(O) LLVMConstant.$(H): LLVMConstant.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
@@ -138,7 +144,6 @@
$(OUTDIR)LLVMIntPredicate.$(O) LLVMIntPredicate.$(H): LLVMIntPredicate.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMLandingPadClauseTy.$(O) LLVMLandingPadClauseTy.$(H): LLVMLandingPadClauseTy.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMLinkage.$(O) LLVMLinkage.$(H): LLVMLinkage.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
-$(OUTDIR)LLVMObject.$(O) LLVMObject.$(H): LLVMObject.st $(INCLUDE_TOP)/stx/libbasic/ExternalAddress.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)LLVMObjectArray.$(O) LLVMObjectArray.$(H): LLVMObjectArray.st $(INCLUDE_TOP)/stx/libbasic/ArrayedCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/Collection.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalBytes.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SequenceableCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/UninterpretedBytes.$(H) $(STCHDR)
$(OUTDIR)LLVMOpcode.$(O) LLVMOpcode.$(H): LLVMOpcode.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMRealPredicate.$(O) LLVMRealPredicate.$(H): LLVMRealPredicate.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
@@ -147,6 +152,7 @@
$(OUTDIR)LLVMVerifierFailureAction.$(O) LLVMVerifierFailureAction.$(H): LLVMVerifierFailureAction.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMVisibility.$(O) LLVMVisibility.$(H): LLVMVisibility.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)jv_llvm_s.$(O) jv_llvm_s.$(H): jv_llvm_s.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR)
+$(OUTDIR)LLVMObject.$(O) LLVMObject.$(H): LLVMObject.st $(INCLUDE_TOP)/jv/llvm_s/LLVMTypeKind.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalAddress.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)LLVMBasicBlock.$(O) LLVMBasicBlock.$(H): LLVMBasicBlock.st $(INCLUDE_TOP)/jv/llvm_s/LLVMObject.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalAddress.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)LLVMContext.$(O) LLVMContext.$(H): LLVMContext.st $(INCLUDE_TOP)/jv/llvm_s/LLVMObject.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalAddress.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)LLVMDiagnosticInfo.$(O) LLVMDiagnosticInfo.$(H): LLVMDiagnosticInfo.st $(INCLUDE_TOP)/jv/llvm_s/LLVMObject.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalAddress.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/Make.spec Mon Aug 10 10:33:42 2015 +0100
+++ b/Make.spec Mon Aug 10 19:26:29 2015 +0100
@@ -56,6 +56,7 @@
LLVMAtomicRMWBinOp \
LLVMAttribute \
LLVMByteOrdering \
+ LLVMCEXT \
LLVMCallConv \
LLVMConfig \
LLVMConstant \
@@ -64,7 +65,6 @@
LLVMIntPredicate \
LLVMLandingPadClauseTy \
LLVMLinkage \
- LLVMObject \
LLVMObjectArray \
LLVMOpcode \
LLVMRealPredicate \
@@ -73,6 +73,7 @@
LLVMVerifierFailureAction \
LLVMVisibility \
jv_llvm_s \
+ LLVMObject \
LLVMBasicBlock \
LLVMContext \
LLVMDiagnosticInfo \
@@ -103,6 +104,7 @@
$(OUTDIR_SLASH)LLVMAtomicRMWBinOp.$(O) \
$(OUTDIR_SLASH)LLVMAttribute.$(O) \
$(OUTDIR_SLASH)LLVMByteOrdering.$(O) \
+ $(OUTDIR_SLASH)LLVMCEXT.$(O) \
$(OUTDIR_SLASH)LLVMCallConv.$(O) \
$(OUTDIR_SLASH)LLVMConfig.$(O) \
$(OUTDIR_SLASH)LLVMConstant.$(O) \
@@ -111,7 +113,6 @@
$(OUTDIR_SLASH)LLVMIntPredicate.$(O) \
$(OUTDIR_SLASH)LLVMLandingPadClauseTy.$(O) \
$(OUTDIR_SLASH)LLVMLinkage.$(O) \
- $(OUTDIR_SLASH)LLVMObject.$(O) \
$(OUTDIR_SLASH)LLVMObjectArray.$(O) \
$(OUTDIR_SLASH)LLVMOpcode.$(O) \
$(OUTDIR_SLASH)LLVMRealPredicate.$(O) \
@@ -120,6 +121,7 @@
$(OUTDIR_SLASH)LLVMVerifierFailureAction.$(O) \
$(OUTDIR_SLASH)LLVMVisibility.$(O) \
$(OUTDIR_SLASH)jv_llvm_s.$(O) \
+ $(OUTDIR_SLASH)LLVMObject.$(O) \
$(OUTDIR_SLASH)LLVMBasicBlock.$(O) \
$(OUTDIR_SLASH)LLVMContext.$(O) \
$(OUTDIR_SLASH)LLVMDiagnosticInfo.$(O) \
--- a/abbrev.stc Mon Aug 10 10:33:42 2015 +0100
+++ b/abbrev.stc Mon Aug 10 19:26:29 2015 +0100
@@ -6,6 +6,7 @@
LLVMAtomicRMWBinOp LLVMAtomicRMWBinOp jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMAttribute LLVMAttribute jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMByteOrdering LLVMByteOrdering jv:llvm_s 'LLVM-S-Core-Constants' 0
+LLVMCEXT LLVMCEXT jv:llvm_s 'LLVM-S-Internal' 0
LLVMCallConv LLVMCallConv jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMConfig LLVMConfig jv:llvm_s 'LLVM-S-Internal' 0
LLVMConstant LLVMConstant jv:llvm_s 'LLVM-S-Core' 0
@@ -14,7 +15,6 @@
LLVMIntPredicate LLVMIntPredicate jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMLandingPadClauseTy LLVMLandingPadClauseTy jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMLinkage LLVMLinkage jv:llvm_s 'LLVM-S-Core-Constants' 0
-LLVMObject LLVMObject jv:llvm_s 'LLVM-S-Internal' 0
LLVMObjectArray LLVMObjectArray jv:llvm_s 'LLVM-S-Core' 0
LLVMOpcode LLVMOpcode jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMRealPredicate LLVMRealPredicate jv:llvm_s 'LLVM-S-Core-Constants' 0
@@ -23,11 +23,12 @@
LLVMVerifierFailureAction LLVMVerifierFailureAction jv:llvm_s 'LLVM-S-Core-Constants' 0
LLVMVisibility LLVMVisibility jv:llvm_s 'LLVM-S-Core-Constants' 0
jv_llvm_s jv_llvm_s jv:llvm_s '* Projects & Packages *' 3
+LLVMExamples LLVMExamples jv:llvm_s 'LLVM-S-Core-Examples' 1
+LLVMObject LLVMObject jv:llvm_s 'LLVM-S-Internal' 0
LLVMBasicBlock LLVMBasicBlock jv:llvm_s 'LLVM-S-Core' 0
LLVMContext LLVMContext jv:llvm_s 'LLVM-S-Core' 0
LLVMDiagnosticInfo LLVMDiagnosticInfo jv:llvm_s 'LLVM-S-Core' 0
LLVMDisposableObject LLVMDisposableObject jv:llvm_s 'LLVM-S-Internal' 0
-LLVMExamples LLVMExamples jv:llvm_s 'LLVM-S-Core-Examples' 1
LLVMMCJITCompilerOptions LLVMMCJITCompilerOptions jv:llvm_s 'LLVM-S-Core' 0
LLVMPassRegistry LLVMPassRegistry jv:llvm_s 'LLVM-S-Core' 0
LLVMTargetLibraryInfo LLVMTargetLibraryInfo jv:llvm_s 'LLVM-S-Core' 0
--- a/bc.mak Mon Aug 10 10:33:42 2015 +0100
+++ b/bc.mak Mon Aug 10 19:26:29 2015 +0100
@@ -77,6 +77,7 @@
$(OUTDIR)LLVMAtomicRMWBinOp.$(O) LLVMAtomicRMWBinOp.$(H): LLVMAtomicRMWBinOp.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMAttribute.$(O) LLVMAttribute.$(H): LLVMAttribute.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMByteOrdering.$(O) LLVMByteOrdering.$(H): LLVMByteOrdering.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
+$(OUTDIR)LLVMCEXT.$(O) LLVMCEXT.$(H): LLVMCEXT.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)LLVMCallConv.$(O) LLVMCallConv.$(H): LLVMCallConv.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMConfig.$(O) LLVMConfig.$(H): LLVMConfig.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)LLVMConstant.$(O) LLVMConstant.$(H): LLVMConstant.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
@@ -85,7 +86,6 @@
$(OUTDIR)LLVMIntPredicate.$(O) LLVMIntPredicate.$(H): LLVMIntPredicate.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMLandingPadClauseTy.$(O) LLVMLandingPadClauseTy.$(H): LLVMLandingPadClauseTy.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMLinkage.$(O) LLVMLinkage.$(H): LLVMLinkage.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
-$(OUTDIR)LLVMObject.$(O) LLVMObject.$(H): LLVMObject.st $(INCLUDE_TOP)\stx\libbasic\ExternalAddress.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)LLVMObjectArray.$(O) LLVMObjectArray.$(H): LLVMObjectArray.st $(INCLUDE_TOP)\stx\libbasic\ArrayedCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\Collection.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalBytes.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SequenceableCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\UninterpretedBytes.$(H) $(STCHDR)
$(OUTDIR)LLVMOpcode.$(O) LLVMOpcode.$(H): LLVMOpcode.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMRealPredicate.$(O) LLVMRealPredicate.$(H): LLVMRealPredicate.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
@@ -94,6 +94,7 @@
$(OUTDIR)LLVMVerifierFailureAction.$(O) LLVMVerifierFailureAction.$(H): LLVMVerifierFailureAction.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)LLVMVisibility.$(O) LLVMVisibility.$(H): LLVMVisibility.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)jv_llvm_s.$(O) jv_llvm_s.$(H): jv_llvm_s.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR)
+$(OUTDIR)LLVMObject.$(O) LLVMObject.$(H): LLVMObject.st $(INCLUDE_TOP)\jv\llvm_s\LLVMTypeKind.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalAddress.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)LLVMBasicBlock.$(O) LLVMBasicBlock.$(H): LLVMBasicBlock.st $(INCLUDE_TOP)\jv\llvm_s\LLVMObject.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalAddress.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)LLVMContext.$(O) LLVMContext.$(H): LLVMContext.st $(INCLUDE_TOP)\jv\llvm_s\LLVMObject.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalAddress.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)LLVMDiagnosticInfo.$(O) LLVMDiagnosticInfo.$(H): LLVMDiagnosticInfo.st $(INCLUDE_TOP)\jv\llvm_s\LLVMObject.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalAddress.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/extensions.st Mon Aug 10 10:33:42 2015 +0100
+++ b/extensions.st Mon Aug 10 19:26:29 2015 +0100
@@ -26,6 +26,16 @@
!Object methodsFor:'testing'!
+isLLVMFunction
+ "Return true, if receiver represents an LLVM value representing a function"
+
+ ^ false
+
+ "Created: / 10-08-2015 / 19:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'testing'!
+
isLLVMType
"Return true, if receiver represents an LLVM type"
--- a/jv_llvm_s.st Mon Aug 10 10:33:42 2015 +0100
+++ b/jv_llvm_s.st Mon Aug 10 19:26:29 2015 +0100
@@ -105,6 +105,29 @@
)
! !
+!jv_llvm_s class methodsFor:'description - compilation'!
+
+additionalRules_make_dot_proto
+ "allows for additional rules to be added to the make.proto file."
+
+ ^ '
+.phony: build_llvm_c_ext
+
+build_llvm_c_ext:
+ $(MAKE) -C llvm_c_ext
+'
+
+ "Created: / 10-08-2015 / 19:25:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+additionalTargets_make_dot_proto
+ "allows for additional targets to be added to the make.proto file."
+
+ ^ 'build_llvm_c_ext'
+
+ "Created: / 10-08-2015 / 19:24:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!jv_llvm_s class methodsFor:'description - contents'!
classNamesAndAttributes
@@ -120,6 +143,7 @@
LLVMAtomicRMWBinOp
LLVMAttribute
LLVMByteOrdering
+ LLVMCEXT
LLVMCallConv
LLVMConfig
LLVMConstant
@@ -128,7 +152,6 @@
LLVMIntPredicate
LLVMLandingPadClauseTy
LLVMLinkage
- LLVMObject
LLVMObjectArray
LLVMOpcode
LLVMRealPredicate
@@ -137,11 +160,12 @@
LLVMVerifierFailureAction
LLVMVisibility
#'jv_llvm_s'
+ (LLVMExamples autoload)
+ LLVMObject
LLVMBasicBlock
LLVMContext
LLVMDiagnosticInfo
LLVMDisposableObject
- (LLVMExamples autoload)
LLVMMCJITCompilerOptions
LLVMPassRegistry
LLVMTargetLibraryInfo
@@ -173,6 +197,7 @@
Object asLLVMValueOfType:
Object isLLVMType
Object isLLVMValue
+ Object isLLVMFunction
)
! !
--- a/libInit.cc Mon Aug 10 10:33:42 2015 +0100
+++ b/libInit.cc Mon Aug 10 19:26:29 2015 +0100
@@ -32,6 +32,7 @@
_LLVMAtomicRMWBinOp_Init(pass,__pRT__,snd);
_LLVMAttribute_Init(pass,__pRT__,snd);
_LLVMByteOrdering_Init(pass,__pRT__,snd);
+_LLVMCEXT_Init(pass,__pRT__,snd);
_LLVMCallConv_Init(pass,__pRT__,snd);
_LLVMConfig_Init(pass,__pRT__,snd);
_LLVMConstant_Init(pass,__pRT__,snd);
@@ -40,7 +41,6 @@
_LLVMIntPredicate_Init(pass,__pRT__,snd);
_LLVMLandingPadClauseTy_Init(pass,__pRT__,snd);
_LLVMLinkage_Init(pass,__pRT__,snd);
-_LLVMObject_Init(pass,__pRT__,snd);
_LLVMObjectArray_Init(pass,__pRT__,snd);
_LLVMOpcode_Init(pass,__pRT__,snd);
_LLVMRealPredicate_Init(pass,__pRT__,snd);
@@ -49,6 +49,7 @@
_LLVMVerifierFailureAction_Init(pass,__pRT__,snd);
_LLVMVisibility_Init(pass,__pRT__,snd);
_jv_137llvm_137s_Init(pass,__pRT__,snd);
+_LLVMObject_Init(pass,__pRT__,snd);
_LLVMBasicBlock_Init(pass,__pRT__,snd);
_LLVMContext_Init(pass,__pRT__,snd);
_LLVMDiagnosticInfo_Init(pass,__pRT__,snd);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/.cproject Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.so.debug.1530599687">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.so.debug.1530599687" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/LLVM C API Extensions"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/LLVM C API Extensions/Debug"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="LLVM-C-EXT" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="so" artifactName="LLVM-C-EXT" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.so.debug.1530599687" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.so.debug.1530599687." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.992304984" name="Linux GCC" nonInternalBuilderId="cdt.managedbuild.target.gnu.builder.so.debug" superClass="cdt.managedbuild.toolchain.gnu.so.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.so.debug.775544274" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.so.debug"/>
+ <builder id="cdt.managedbuild.target.gnu.builder.so.debug.815687926" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.so.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.2128453546" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.166509465" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug">
+ <option id="gnu.cpp.compiler.so.debug.option.optimization.level.1670438573" name="Optimization Level" superClass="gnu.cpp.compiler.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.so.debug.option.debugging.level.1886577773" name="Debug Level" superClass="gnu.cpp.compiler.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.877645702" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value=""${workspace_loc:/LLVM C API Extensions/include}""/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include"/>
+ </option>
+ <option id="gnu.cpp.compiler.option.preprocessor.def.1537013795" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+ <listOptionValue builtIn="false" value="__STDC_CONSTANT_MACROS"/>
+ <listOptionValue builtIn="false" value="__STDC_LIMIT_MACROS=1"/>
+ <listOptionValue builtIn="false" value="_GNU_SOURCE=1"/>
+ <listOptionValue builtIn="false" value="NDEBUG=1"/>
+ </option>
+ <option id="gnu.cpp.compiler.option.optimization.flags.1137352585" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" value="-g -fomit-frame-pointer -std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fPIC -ffunction-sections -fdata-sections -Wcast-qual" valueType="string"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1597913403" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.371564189" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.so.debug.option.optimization.level.575241098" name="Optimization Level" superClass="gnu.c.compiler.so.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.so.debug.option.debugging.level.166571313" name="Debug Level" superClass="gnu.c.compiler.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.1060938595" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value=""${workspace_loc:/LLVM C API Extensions/include}""/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include"/>
+ </option>
+ <option id="gnu.c.compiler.option.preprocessor.def.symbols.969084918" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
+ <listOptionValue builtIn="false" value="__STDC_CONSTANT_MACROS=1"/>
+ <listOptionValue builtIn="false" value="__STDC_LIMIT_MACROS=1"/>
+ <listOptionValue builtIn="false" value="_GNU_SOURCE=1"/>
+ <listOptionValue builtIn="false" value="NDEBUG=1"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1590538526" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.so.debug.1316900442" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug">
+ <option defaultValue="true" id="gnu.c.link.so.debug.option.shared.193147682" name="Shared (-shared)" superClass="gnu.c.link.so.debug.option.shared" valueType="boolean"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.242908506" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug">
+ <option defaultValue="true" id="gnu.cpp.link.so.debug.option.shared.884887674" name="Shared (-shared)" superClass="gnu.cpp.link.so.debug.option.shared" valueType="boolean"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.124056005" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.so.debug.323150157" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug">
+ <option id="gnu.both.asm.option.include.paths.19107808" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include"/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/LLVM C API Extensions/include}""/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.701395900" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry excluding="lib" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="lib"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.so.release.896881102">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.so.release.896881102" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings>
+ <externalSetting>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/LLVM C API Extensions"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/LLVM C API Extensions/Release"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="LLVM C API Extensions" srcPrefixMapping="" srcRootPath=""/>
+ </externalSetting>
+ </externalSettings>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.so.release.896881102" name="Release" parent="cdt.managedbuild.config.gnu.so.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.so.release.896881102." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.so.release.840430136" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.so.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.so.release.649115788" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.so.release"/>
+ <builder buildPath="${workspace_loc:/LLVM C API Extensions}/Release" id="cdt.managedbuild.target.gnu.builder.so.release.1421656324" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.so.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1158294310" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1700622584" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release">
+ <option id="gnu.cpp.compiler.so.release.option.optimization.level.1433157086" name="Optimization Level" superClass="gnu.cpp.compiler.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.so.release.option.debugging.level.874180479" name="Debug Level" superClass="gnu.cpp.compiler.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.378677997" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include/llvm"/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include/llvm-c"/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/LLVM C API Extensions/include}""/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include"/>
+ </option>
+ <option id="gnu.cpp.compiler.option.preprocessor.def.1877184595" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+ <listOptionValue builtIn="false" value="__STDC_CONSTANT_MACROS"/>
+ <listOptionValue builtIn="false" value="__STDC_LIMIT_MACROS=1"/>
+ <listOptionValue builtIn="false" value="-DNDEBUG=1"/>
+ <listOptionValue builtIn="false" value="_GNU_SOURCE=1"/>
+ <listOptionValue builtIn="false" value="NDEBUG=1"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1549308588" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.so.release.692181494" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.so.release.option.optimization.level.1972981918" name="Optimization Level" superClass="gnu.c.compiler.so.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.so.release.option.debugging.level.362563017" name="Debug Level" superClass="gnu.c.compiler.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.899316118" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include/llvm"/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include/llvm-c"/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/LLVM C API Extensions/include}""/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include"/>
+ </option>
+ <option id="gnu.c.compiler.option.preprocessor.def.symbols.48367111" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
+ <listOptionValue builtIn="false" value="__STDC_CONSTANT_MACROS"/>
+ <listOptionValue builtIn="false" value="__STDC_LIMIT_MACROS=1"/>
+ <listOptionValue builtIn="false" value="-DNDEBUG=1"/>
+ <listOptionValue builtIn="false" value="_GNU_SOURCE=1"/>
+ <listOptionValue builtIn="false" value="NDEBUG=1"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1999352707" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.so.release.418584338" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release">
+ <option defaultValue="true" id="gnu.c.link.so.release.option.shared.737255595" name="Shared (-shared)" superClass="gnu.c.link.so.release.option.shared" valueType="boolean"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.699353097" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release">
+ <option defaultValue="true" id="gnu.cpp.link.so.release.option.shared.81535390" name="Shared (-shared)" superClass="gnu.cpp.link.so.release.option.shared" valueType="boolean"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.952421607" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.so.release.1540571238" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release">
+ <option id="gnu.both.asm.option.include.paths.1574881544" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include/llvm"/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include/llvm-c"/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/LLVM C API Extensions/include}""/>
+ <listOptionValue builtIn="false" value="/usr/lib/llvm-3.8/include"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1137754014" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry excluding="lib" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="lib"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="LLVM C API Extensions.cdt.managedbuild.target.gnu.so.659226694" name="Shared Library" projectType="cdt.managedbuild.target.gnu.so"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.debug.1530599687;cdt.managedbuild.config.gnu.so.debug.1530599687.;cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.166509465;cdt.managedbuild.tool.gnu.cpp.compiler.input.1597913403">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.896881102;cdt.managedbuild.config.gnu.so.release.896881102.;cdt.managedbuild.tool.gnu.c.compiler.so.release.692181494;cdt.managedbuild.tool.gnu.c.compiler.input.1999352707">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.debug.1530599687;cdt.managedbuild.config.gnu.so.debug.1530599687.;cdt.managedbuild.tool.gnu.c.compiler.so.debug.371564189;cdt.managedbuild.tool.gnu.c.compiler.input.1590538526">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.so.release.896881102;cdt.managedbuild.config.gnu.so.release.896881102.;cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1700622584;cdt.managedbuild.tool.gnu.cpp.compiler.input.1549308588">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/LLVM C API Extensions"/>
+ </configuration>
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/LLVM C API Extensions"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+</cproject>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/.project Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>LLVM C API Extensions</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/Makefile Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,9 @@
+all:
+ $(MAKE) -C lib
+
+test:
+ $(MAKE) -C test
+
+clean:
+ $(MAKE) -C lib clean
+ $(MAKE) -C test clean
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/include/llvm-c-ext/Intrinsics.h Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,28 @@
+/*
+ * Intrinsics.h
+ *
+ * Created on: Aug 10, 2015
+ * Author: jv
+ */
+
+#ifndef INCLUDE_LLVM_C_EXT_INTRINSICS_H_
+#define INCLUDE_LLVM_C_EXT_INTRINSICS_H_
+
+#include <llvm-c/Core.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Create or insert an LLVM Function declaration for an intrinsic with given name, and return it.
+ * If there's no intrinsic with given name, return NULL.
+ *
+ * @pa
+ */
+LLVMValueRef LLVMGetIntrinsicByName(LLVMModuleRef mod, const char* name, const int count, const LLVMTypeRef* types);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* INCLUDE_LLVM_C_EXT_INTRINSICS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/lib/Intrinsics.cpp Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,52 @@
+/*
+ * Intrinsics.cpp
+ *
+ * Created on: Aug 10, 2015
+ * Author: Jan Vrany
+ */
+
+#ifndef LLVM_C_EXT_INTRINSICS_H
+#define LLVM_C_EXT_INTRINSICS_H
+
+#include <cstring>
+
+#include <llvm/ADT/ArrayRef.h>
+#include <llvm/IR/Intrinsics.h>
+#include <llvm/IR/Module.h>
+#include <llvm-c-ext/Intrinsics.h>
+
+
+static const char* const intrinsic_names[] = {
+#define GET_INTRINSIC_NAME_TABLE
+#include "llvm/IR/Intrinsics.gen"
+#undef GET_INTRINSIC_NAME_TABLE
+};
+
+
+LLVMValueRef LLVMGetIntrinsicByName(LLVMModuleRef mod, const char* name, const int count, const LLVMTypeRef* types) {
+ llvm::Intrinsic::ID id = llvm::Intrinsic::not_intrinsic;
+ llvm::Function* f;
+
+ for (int intrinIdx = 0; intrinIdx < (sizeof(intrinsic_names) / sizeof(const char*)); intrinIdx++) {
+ if (strcmp(name, intrinsic_names[intrinIdx]) == 0) {
+ llvm::Type* typesUnwrapped[count];
+ for (int typeIdx = 0; typeIdx < count; typeIdx++) {
+ typesUnwrapped[typeIdx] = llvm::unwrap(types[typeIdx]);
+ }
+ llvm::ArrayRef<llvm::Type*> typesArray(typesUnwrapped, count);
+ f = llvm::Intrinsic::getDeclaration(llvm::unwrap(mod), (llvm::Intrinsic::ID)(intrinIdx + 1), typesArray);
+ return llvm::wrap(f);
+ }
+ }
+ return NULL;
+}
+
+#endif /* !defined(LLVM_C_EXT_INTRINSICS_H) */
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/lib/Makefile Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,34 @@
+SOURCES = $(wildcard *.cpp)
+OBJECTS = $(patsubst %.cpp,%.o,$(SOURCES))
+LIBRARY = libLLVM-C-EXT.so
+ARCHIVE = libLLVM-C-EXT.a
+
+
+LLVM_CONFIG=llvm-config-3.8
+
+CXXFLAGS_LLVM = $(shell $(LLVM_CONFIG) --cxxflags) -O0
+LDFLAGS_LLVM = $(shell $(LLVM_CONFIG) --ldflags)
+LIBS_LLVM = $(shell $(LLVM_CONFIG) --libs) $(shell $(LLVM_CONFIG) --system-libs)
+
+CXXFLAGS=$(CXXFLAGS_LLVM) -I ../include
+LDFLAGS=$(LDFLAGS_LLVM)
+LIBS=$(LIBS_LLVM)
+
+
+all: $(LIBRARY) $(ARCHIVE)
+
+%.o: %.cpp
+ $(CXX) -c $(CXXFLAGS) -o $@ $<
+
+%.E: %.cpp
+ $(CXX) -E $(CXXFLAGS) -o $@ $<
+
+
+$(LIBRARY): $(OBJECTS)
+ $(CXX) $(LDFLAGS) -shared -o $(LIBRARY) $(OBJECTS) $(LIBS)
+
+$(ARCHIVE): $(OBJECTS)
+ $(AR) r $(ARCHIVE) $(OBJECTS)
+
+clean:
+ rm -f $(OBJECTS) $(LIBRARY) $(ARCHIVE)
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/test/Makefile Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,30 @@
+SOURCES = $(wildcard *.c)
+BINARIES = $(patsubst %.c,%,$(SOURCES))
+
+
+LLVM_CONFIG=llvm-config-3.8
+
+CFLAGS_LLVM = $(shell $(LLVM_CONFIG) --cflags)
+LDFLAGS_LLVM = $(shell $(LLVM_CONFIG) --ldflags)
+LIBS_LLVM = $(shell $(LLVM_CONFIG) --libs) $(shell $(LLVM_CONFIG) --system-libs)
+
+CFLAGS_LLVM_C_EXT = -I../include
+LDFLAGS_LLVM_C_EXT = -L../lib -Wl,-rpath,../lib/
+LIBS_LLVM_C_EXT = -lLLVM-C-EXT
+
+
+CFLAGS=$(CFLAGS_LLVM_C_EXT) $(CFLAGS_LLVM)
+LDFLAGS= $(LDFLAGS_LLVM_C_EXT) $(LDFLAGS_LLVM)
+LIBS=$(LIBS_LLVM_C_EXT) $(LIBS_LLVM) -lstdc++
+
+
+all: $(BINARIES)
+
+%.o: %.c
+ $(CXX) -c $(CFLAGS) -o $@ $<
+
+%: %.o
+ $(CC) $(LDFLAGS) -o $@ $< $(LIBS)
+
+clean:
+ rm -f $(BINARIES)
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/llvm_c_ext/test/test_intrinsics.c Mon Aug 10 19:26:29 2015 +0100
@@ -0,0 +1,28 @@
+/*
+ * test_intrinsics.c
+ *
+ * Created on: Aug 10, 2015
+ * Author: jv
+ */
+
+#include <stdio.h>
+#include <llvm-c/Core.h>
+#include <llvm-c-ext/Intrinsics.h>
+
+int main(int argc, char** argv) {
+ char* name = "llvm.returnaddress";
+ LLVMTypeRef types[1];
+
+ types[0] = LLVMInt32Type();
+
+ LLVMModuleRef module = LLVMModuleCreateWithName(argv[0]);
+ LLVMValueRef intrinsic_decl = LLVMGetIntrinsicByName(module, name, (sizeof(types) / sizeof(LLVMTypeRef)), types );
+
+ LLVMDumpModule(module);
+ LLVMDisposeModule(module);
+
+ return 0;
+}
+
+
+