@@ -230,12 +230,16 @@ def run(cmd):
230
230
ac_types_dir = os .environ .get ('AC_TYPES_DIR' )
231
231
ac_types_include = [f"-I{ ac_types_dir } /include" ] if ac_types_dir else []
232
232
233
+ sc_types_dir = os .environ .get ('SC_TYPES_DIR' )
234
+ sc_types_include = [f"-I{ sc_types_dir } /include" ] if sc_types_dir else []
235
+
233
236
backend_c_flags = {
234
237
'ac' : ['-DASL_AC' ] + ac_types_include ,
235
238
'c23' : ['-DASL_C23' ],
236
239
'interpreter' : [],
237
240
'fallback' : ['-DASL_FALLBACK' ],
238
241
'orig' : ['-DASL_FALLBACK' ],
242
+ 'sc' : ['-DASL_SC' ] + sc_types_include ,
239
243
}
240
244
241
245
def get_c_flags (asli , backend ):
@@ -259,6 +263,7 @@ def get_c_flags(asli, backend):
259
263
'interpreter' : [],
260
264
'fallback' : [],
261
265
'orig' : [],
266
+ 'sc' : ["-lsystemc" ],
262
267
}
263
268
264
269
def get_ld_flags (asli , backend ):
@@ -273,6 +278,11 @@ def get_ld_flags(asli, backend):
273
278
rootdir = os .path .dirname (bindir )
274
279
path = os .path .join (rootdir , "runtime/libASL.a" )
275
280
ld_flags = [path ]
281
+ if backend == "sc" :
282
+ sc_types_dir = os .environ .get ('SC_TYPES_DIR' )
283
+ if not sc_types_dir :
284
+ raise EnvironmentError ("SC_TYPES_DIR environment variable must be set for SystemC backend" )
285
+ ld_flags .append (f"-L{ sc_types_dir } /lib" )
276
286
ld_flags .extend (backend_ld_flags [backend ])
277
287
return ld_flags
278
288
@@ -289,6 +299,7 @@ def mk_script(args, output_directory):
289
299
'c23' : f'generate_c_new { ffi } --runtime=c23' ,
290
300
'fallback' : f'generate_c_new { ffi } --runtime=fallback' ,
291
301
'orig' : 'generate_c' ,
302
+ 'sc' : f'generate_c_new { ffi } --runtime=sc' ,
292
303
}
293
304
generate_c = backend_generator [args .backend ]
294
305
@@ -397,6 +408,8 @@ def compile_and_link(use_cxx, c_files, extra_c, exe_file, working_directory, c_f
397
408
cc = [ "clang-16" ]
398
409
elif subprocess .run (['which' , 'clang' ], capture_output = True ).returncode == 0 :
399
410
cc = [ "clang" ]
411
+ elif use_cxx :
412
+ cc = [ "g++" ]
400
413
else :
401
414
cc = [ "gcc" ]
402
415
if use_cxx :
@@ -479,7 +492,7 @@ def main() -> int:
479
492
parser .add_argument ("--instrument-unknown" , help = "instrument assignments of UNKNOWN" , action = argparse .BooleanOptionalAction )
480
493
parser .add_argument ("--wrap-variables" , help = "wrap global variables into functions" , action = argparse .BooleanOptionalAction )
481
494
parser .add_argument ("-O0" , help = "perform minimal set of transformations" , action = argparse .BooleanOptionalAction )
482
- parser .add_argument ("--backend" , help = "select backend (default: orig)" , choices = ['ac' , 'c23' , 'interpreter' , 'fallback' , 'orig' ], default = 'orig' )
495
+ parser .add_argument ("--backend" , help = "select backend (default: orig)" , choices = ['ac' , 'c23' , 'interpreter' , 'fallback' , 'orig' , 'sc' ], default = 'orig' )
483
496
parser .add_argument ("--print-c-flags" , help = "print the C flags needed to use the selected ASL C runtime" , action = argparse .BooleanOptionalAction )
484
497
parser .add_argument ("--print-ld-flags" , help = "print the Linker flags needed to use the selected ASL C runtime" , action = argparse .BooleanOptionalAction )
485
498
parser .add_argument ("--build" , help = "compile and link the ASL code" , action = 'store_true' )
@@ -507,7 +520,7 @@ def main() -> int:
507
520
if args .backend == "interpreter" and not args .run :
508
521
print ("Error: must specify --run with asli backend" )
509
522
exit (1 )
510
- if args .backend in ['ac' ]: args .generate_cxx = True
523
+ if args .backend in ['ac' , 'sc' ]: args .generate_cxx = True
511
524
if args .const_ref and not args .generate_cxx :
512
525
print ("Error: must specify --generate-cxx with --const-ref" )
513
526
exit (1 )
0 commit comments