From 1716a4bec8bf8b76852aa49761b542959561ff3e Mon Sep 17 00:00:00 2001 From: Matthew Willis Date: Tue, 30 Jun 2009 11:57:24 +0900 Subject: [PATCH] remove llvm.bindings, made obsolete by llvm.wrappers and friends --- extra/llvm/bindings/bindings-tests.factor | 32 --------- extra/llvm/bindings/bindings.factor | 79 ----------------------- 2 files changed, 111 deletions(-) delete mode 100644 extra/llvm/bindings/bindings-tests.factor delete mode 100644 extra/llvm/bindings/bindings.factor diff --git a/extra/llvm/bindings/bindings-tests.factor b/extra/llvm/bindings/bindings-tests.factor deleted file mode 100644 index 59eaf270f9..0000000000 --- a/extra/llvm/bindings/bindings-tests.factor +++ /dev/null @@ -1,32 +0,0 @@ -USING: accessors alien compiler.units kernel -llvm.bindings llvm.core tools.test words ; - -IN: scratchpad - -: add-abi ( x y -- x+y ) ! to be filled in by llvm - drop ; - -: llvm-add ( x y -- x+y ) - "test" [ - { - { [ 32 LLVMIntType ] "add" } - { [ 32 LLVMIntType ] "x" } - { [ 32 LLVMIntType ] "y" } - } [ - "entry" [ - builder value>> "x" get-param "y" get-param "sum" LLVMBuildAdd - builder value>> swap LLVMBuildRet drop - ] with-builder - ] with-function - - - ] with-module - - [ - "add" find-function global>pointer - [ "int" { "int" "int" } "cdecl" alien-indirect ] curry \ add-abi swap - (( x y -- x+y )) [ define-declared ] with-compilation-unit - add-abi ! call our new word - ] with-engine ; inline - -[ 7 ] [ 3 4 llvm-add ] unit-test \ No newline at end of file diff --git a/extra/llvm/bindings/bindings.factor b/extra/llvm/bindings/bindings.factor deleted file mode 100644 index 390b55aa37..0000000000 --- a/extra/llvm/bindings/bindings.factor +++ /dev/null @@ -1,79 +0,0 @@ -USING: accessors alien.c-types alien.strings arrays -central destructors kernel llvm.core llvm.engine -quotations sequences specialized-arrays.alien ; - -IN: llvm.bindings - -: llvm-throw ( char** -- ) - [ alien>string ] [ LLVMDisposeMessage ] bi throw ; - -DISPOSABLE-CENTRAL: module -CENTRAL: function -DISPOSABLE-CENTRAL: builder -DISPOSABLE-CENTRAL: engine - -: ( alien class -- disposable ) new swap >>value ; - -TUPLE: LLVMModule value disposed ; -M: LLVMModule dispose* value>> LLVMDisposeModule ; - -: ( name -- module ) - LLVMModuleCreateWithName LLVMModule ; - -TUPLE: LLVMModuleProvider value disposed ; -M: LLVMModuleProvider dispose* value>> LLVMDisposeModuleProvider ; - -: ( -- module-provider ) - module t >>disposed value>> LLVMCreateModuleProviderForExistingModule - LLVMModuleProvider ; - -: (add-block) ( name -- basic-block ) - function swap LLVMAppendBasicBlock ; - -TUPLE: LLVMBuilder value disposed ; -M: LLVMBuilder dispose* value>> LLVMDisposeBuilder ; - -: ( name -- builder ) - (add-block) LLVMCreateBuilder [ swap LLVMPositionBuilderAtEnd ] keep - LLVMBuilder ; - -TUPLE: LLVMExecutionEngine value disposed ; -M: LLVMExecutionEngine dispose* value>> LLVMDisposeExecutionEngine ; - -: ( -- engine ) - [ - dup value>> f f - [ swapd 0 swap LLVMCreateJITCompiler drop ] 2keep - *void* [ llvm-throw ] when* *void* LLVMExecutionEngine - swap t >>disposed drop - ] with-disposal ; - -: resolve-type ( callable/alien -- type ) - dup callable? [ call( -- type ) ] when ; - -: ( args -- type ) - [ resolve-type ] map - unclip swap [ >void*-array ] keep length 0 LLVMFunctionType ; - -: >>cc ( function calling-convention -- function ) - dupd LLVMSetFunctionCallConv ; - -: params>> ( function -- array ) - dup LLVMCountParams "LLVMValueRef" [ LLVMGetParams ] keep - byte-array>void*-array >array ; - -: get-param ( name -- value ) - function params>> swap [ swap LLVMGetValueName = ] curry find nip ; - -: set-param-names ( names function -- ) - params>> swap [ LLVMSetValueName ] 2each ; - -: ( args -- function ) - module value>> over first second pick - [ first ] map LLVMAddFunction LLVMCCallConv >>cc tuck - [ rest [ second ] map ] dip set-param-names ; - -: global>pointer ( value -- alien ) engine value>> swap LLVMGetPointerToGlobal ; - -: find-function ( name -- fn ) - engine value>> swap f [ LLVMFindFunction drop ] keep *void* ; \ No newline at end of file