[LLVMdev] LLVM assembly without basic block

Basile STARYNKEVITCH basile at starynkevitch.net
Fri Jun 29 22:59:51 PDT 2007


Seung Jae Lee wrote:
> Thank you for reminding me the notion of the basic block.
> Of course, I know all the assembly takes the form of BBs and is divided into units of BB.
> OK. It looks better for me to explain what I wanted to do more clear from the first.
> 
> Actually, I am working on emitting out an assembly of VM by using LLVM. LLVM assembly looks similar with this VM assembly except BB. The VM assembly does not have the explicit concept of BB. (I know this is quite foreign.) 
> For this reason, this assembly looks like more HLL. ('for' statement is a mnemonic for looping in this assembly. :-( ) 
> For example, the VM assembly looks like the following for the simple C code I showed you before. (I write it again, for your convenience.)
> ----------------------------------------------------------
> void f_loop(long* c, long sz) {
> 
>    long i;
> 
>    for (i = 0; i < sz; i++)
>    {
>       long offset = i * sz;
>       long* out = c + offset;
>       out[i] = 0;
>    }
> }
> ----------------------------------------------------------
> The assembly is shown like this:
> ----------------------------------------------------------
> Enter f_loop; c,sz
> reg i
> reg temp1:1
> nfor l0;sz;i
>         reg out, offset
>         reg temp0
>         multiply i,sz;offset
>         add offset<<2,c;out
>         add i<<2,out;temp0
>         write temp0;0;4;;
> end l0
> exit f_loop
> ----------------------------------------------------------
> Even if the case that there are more loops, this VM assembly does not divide the function into BBs 'cause there is no concept of BB.

Then you have to reconstruct the basic blocks, probably by taking into account the branches in your pseudo assembly code 
and the labels. Hence you'll develop a translator from your assembly language to LLVM.

You could also patch the tool generating your assembly code so that its generate LLVM language. This could be simpler.

Or you could use other code generators like GNU lightning.

Or your might generate C code.


-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faïencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***





More information about the llvm-dev mailing list