Backend to start with

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.

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.

Are you looking to add a new target that is similar to SPARC? Or are you looking to extend the current SPARC backend to output alternative assembly format? If it is the later, you would want to look at the X86 backend.

Evan