Displaying 10 results from an estimated 10 matches for "puts_kernel".
2004 Apr 02
2
[LLVMdev] Function pointers
OK, I solved it all ( so far :) ), mixing in some load-instructions and called on the result of that, which worked.
Here is the skeleton-code:
%kernel = type { int ()* }
int puts_kernel(){...}
; main()
%theKernel = malloc %kernel
%puts_kernelPTR = getelementptr %kernel* %theKernel, long 1, ubyte 0
store int ()* %puts_kernel, int ()** %puts_kernelPTR
%tmp.11 = load int ()** %puts_kernelPTR
%tmp.2 = call int %tmp.11()
free %kernel* %theKernel
:-)
Anders...
2004 Apr 02
0
[LLVMdev] Function pointers
On Fri, 2 Apr 2004, Anders Alexandersson wrote:
> OK, I solved it all ( so far :) ), mixing in some load-instructions and
> called on the result of that, which worked.
>
> Here is the skeleton-code:
>
> %kernel = type { int ()* }
>
> int puts_kernel(){...}
>
> ; main()
>
> %theKernel = malloc %kernel
> %puts_kernelPTR = getelementptr %kernel* %theKernel, long 1, ubyte 0
>
> store int ()* %puts_kernel, int ()** %puts_kernelPTR
> %tmp.11 = load int ()** %puts_kernelPTR
>
> %tmp.2 = call int %tmp.11()
>
> free...
2004 May 03
2
[LLVMdev] Problems with getelementptr
...ant to get a pointer to a classFunction via a pointer to the map.
I can't get that function pointer!
How shall I think to get the traversing right (see code below)? Is it something with the fact that I am using only pointers in my structs?
Best regards
Anders
; My user defined function
int %puts_kernel(sbyte* %string)
{
%tmp.0 = call int (sbyte*, ...)* %printf( sbyte* %string )
ret int 0
}
;the map and the class. The class is called "Kernel".
"myKernelMap" = type {int (sbyte*)*}
"Kernel" = type {"myKernelMap"*}
;Allocating...OK
"myKe...
2004 Apr 02
0
[LLVMdev] Function pointers
I solved that one by substituting alloca into malloc, and forwarded the problem to actually calling the %puts_kernel function via my newly created function pointer.
This works:
%tmp.1 = call int %puts_kernel()
This:
%tmp.2 = call int %puts_kernelPTR()
issues error:
"Reference to an invalid definition: 'puts_kernelPTR' of type 'int () *'"
How do I call the function using the functi...
2004 May 11
2
[LLVMdev] Problems accessing structs
...w.
Regards
Anders
-----
"Hello KernelConst" = internal constant [14 x sbyte ] c"Hello Kernel\0A\00"
"myKernelMap" = type {int (sbyte*)*, int ()*}
"Kernel" = type {"myKernelMap"*}
declare int %printf(sbyte*, ...)
declare int %getchar(...)
int %puts_kernel(sbyte* %string)
{
%tmp0 = call int (sbyte*, ...)* %printf(sbyte* %string)
ret int 0
}
int %getchar_kernel()
{
%tmp0 = call int (...)* %getchar()
ret int 0
}
"Kernel"* "createKernel"()
{
"myKernelMapInstance" = malloc "myKernelMap"
"myKernel" = mal...
2004 May 03
0
[LLVMdev] Problems with getelementptr
....
Okay...
> I can't get that function pointer!
>
> How shall I think to get the traversing right (see code below)? Is it
> something with the fact that I am using only pointers in my structs?
>
> Best regards
> Anders
>
> ; My user defined function
> declare int %puts_kernel(sbyte* %string)
>
> ;the map and the class. The class is called "Kernel".
> "myKernelMap" = type {int (sbyte*)*}
Okay, this declares a structure that has a single pointer-to-function
element in it.
> "Kernel" = type {"myKernelMap"*}
This is a s...
2004 May 11
0
[LLVMdev] Problems accessing structs
...ernelConst" = internal constant [14 x sbyte ] c"Hello Kernel\0A\00"
>
> "myKernelMap" = type {int (sbyte*)*, int ()*}
> "Kernel" = type {"myKernelMap"*}
>
> declare int %printf(sbyte*, ...)
> declare int %getchar(...)
>
> int %puts_kernel(sbyte* %string)
> {
> %tmp0 = call int (sbyte*, ...)* %printf(sbyte* %string)
> ret int 0
> }
>
> int %getchar_kernel()
> {
> %tmp0 = call int (...)* %getchar()
> ret int 0
> }
>
> "Kernel"* "createKernel"()
> {
> "myKernelMapInst...
2004 Apr 02
0
[LLVMdev] Function pointers
So, here comes the next question:)
Now the program compiles, but crashes when run, "Segmentation fault".
%kernel = type { int ()* }
int %puts_kernel()
{
ret int 0
}
int %main() {
%theKernel = alloca %kernel
%puts_kernelPTR = getelementptr %kernel* %theKernel, long 1, ubyte 0
store int ()* %puts_kernel, int ()** %puts_kernelPTR
ret int 0
}
I want to learn how to achieve the mechanisms in this C code:
#include <stdio.h>...
2004 May 11
1
[LLVMdev] Follow-up on: Dynamic updates of current executed code
...be made in LLVM code. Here is a detailed simplistic example in pseudocode of what we want to do:
First Ruby code is entered at run-time, received as a string, parsed and compiled into the following code:
%--------------
; External function
declare int %printf(sbyte*, ...)
; Custom function
int %puts_kernel( sbyte* %string )
{
%tmp.0 = call int (sbyte*, ...)* %printf( sbyte* %string )
ret int 0
}
%-------------
This code is represented in the string variable
%dynamically_compiled_function_code below:
%----------
%dynamically_compiled_function_code = internal constant [LENGTH x sbyte] c"--Strin...
2004 Apr 20
2
[LLVMdev] Dynamic updates of current executed code
...ed simplistic example in pseudocode of what we want to do:
First Ruby code is entered at run-time, received as a string, parsed and compiled into the following code:
%-----------------------------------------------------
; External function
declare int %printf(sbyte*, ...)
; Custom function
int %puts_kernel( sbyte* %string )
{
%tmp.0 = call int (sbyte*, ...)* %printf( sbyte* %string )
ret int 0
}
%-----------------------------------------------------
This code is represented in the string variable
%dynamically_compiled_function_code below:
%-----------------------------------------...