[LLVMdev] Backend to start with

Seung Jae Lee lee225 at uiuc.edu
Mon Feb 5 12:35:05 PST 2007


Hello.

I have a very simple code like this:

   int sum(int i, int j)
   {
       int k; 
       k = i + j;
   }
 
   #ifdef LINUX
   #include <stdio.h>                       
   #include <stdlib.h>

   int main ()
   {
       int k;
       k = sum(3,4);
    
       return k;
   }
   #endif            

If I emit this to SPARC assembly mnemonics through LLVM, it is shown as follows (as you know):

   .text
   	.align	16
   	.globl	sum
   	.type	sum, #function
   sum:
   	save -96, %o6, %o6
   	!IMPLICIT_DEF %i0
   	restore %g0, %g0, %g0
   	retl
   	nop

But, I'd like to emit the source code to the assembly like this:

   Enter sum;  i,j, _mem_sync:1
   reg k
   add i,j;k
   Exit sum;  0, _mem_sync:1

(FYI, "reg" implies "k" will be used in the following instructions. _mem_sync is FIFO for access to a memory.)

Can you recommend any step by step procedure for me so that I can accomplish this if I modify SPARC code? I am begging you easy words because I am not familiar with terminologies related to compiliation.



More information about the llvm-dev mailing list