goblint / cil

C Intermediate Language
https://goblint.github.io/cil/
Other
133 stars 20 forks source link

Support for parsing extended assembly code including `asm goto` #161

Open WernerDrasche opened 10 months ago

WernerDrasche commented 10 months ago

See #81

WernerDrasche commented 9 months ago
WernerDrasche commented 9 months ago

The dummyInstr can be safely deleted from cil.mli I think, as after grepping for it inside gobling-analyzer and goblint-cil no matches were found. Otherwise I have no clue on how to implement a dummy instruction using either set | vardecl | call.

michael-schwarz commented 9 months ago

It would be good to include additional tests for the new features.

I think has not been addressed yet, if I see correctly?

michael-schwarz commented 9 months ago

The dummyInstr can be safely deleted from cil.mli I think, as after grepping for it inside gobling-analyzer and goblint-cil no matches were found. Otherwise I have no clue on how to implement a dummy instruction using either set | vardecl | call.

I think it would still be useful to keep it, as there are other users of goblint-cil. Maybe you can add a vardecl instruction for a new dummy variable? I think this is the best option.

michael-schwarz commented 9 months ago

Also, feel free to mark suggestions that you have implemented and there's nothing more to discuss as resolved, that makes it easier for us to keep track of what remains still TODO.

michael-schwarz commented 9 months ago

The currently still failing task is CC=gcc make test/asm_goto3.

michael-schwarz commented 9 months ago

The error message is

Entering directory '/home/michael/Documents/goblint-cil/cil'
cd ./small1; /home/michael/Documents/goblint-cil/cil/_build/default/test/../bin/cilly --mode=GNUCC --decil --save-temps  --strictcheck --stats --nomerge --commPrintLn \
       -c -std=gnu90 -D_GNUCC -Wall -g -ggdb -D_DEBUG -S -o asm_goto3.s asm_goto3.c
First CIL check
Timings:
TOTAL                           0.001 s
  parse                           0.000 s
  convert to CIL                  0.000 s
  printCIL                        0.000 s
Timing used
Memory statistics: total=5.10MB, max=1.02MB, minor=4.93MB, major=0.91MB, promoted=0.74MB
    minor collections=4  major collections=0 compactions=0
./asm_goto3.cil.c: In function ‘code’:
./asm_goto3.cil.c:15:30: error: expected identifier before ‘)’ token
   __asm__  goto   ("nop": : : : );
                              ^
Makefile:175: recipe for target 'test/asm_goto3' failed
make: *** [test/asm_goto3] Error 1
michael-schwarz commented 9 months ago
/* Generated by Goblint-CIL v. %%VERSION_NUM%% */
/* print_CIL_Input is false */

//#line  3 "testharness.h"
extern int printf(char const   *format  , ...) ;
//#line  12
extern void exit(int  ) ;
//#line  3 "asm_goto3.c"
void code(void) 
{ 

  {
//#line  5
  __asm__  goto   ("nop": : : : );
//#line  7
  printf((char const   *)"Success\n");
//#line  7
  exit(0);
}
}

This the produced C program.

michael-schwarz commented 9 months ago

And the error message is

gcc small1/asm_goto3.cil.c
small1/asm_goto3.cil.c: In function ‘code’:
small1/asm_goto3.cil.c:15:33: error: expected identifier before ‘)’ token
   __asm__  goto   ("nop": : : : );
                                 ^