From 13ad9b5d0898a9e2247c0e0506b7056a41394710 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 8 Aug 2015 21:47:20 +0300 Subject: [PATCH] Allow to dump ARTIQ/LLVM IR for stitched code. --- artiq/coredevice/core.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/artiq/coredevice/core.py b/artiq/coredevice/core.py index 7367f0529..ce9ae391b 100644 --- a/artiq/coredevice/core.py +++ b/artiq/coredevice/core.py @@ -32,10 +32,19 @@ class Core: stitcher = Stitcher(engine=engine) stitcher.stitch_call(function, args, kwargs) - module = Module(stitcher) - library = OR1KTarget().compile_and_link([module]) + module = Module(stitcher) + target = OR1KTarget() - return library, stitcher.rpc_map + if os.getenv('ARTIQ_DUMP_IR'): + print("====== ARTIQ IR DUMP ======", file=sys.stderr) + for function in module.artiq_ir: + print(function, file=sys.stderr) + + if os.getenv('ARTIQ_DUMP_LLVM'): + print("====== LLVM IR DUMP ======", file=sys.stderr) + print(module.build_llvm_ir(target), file=sys.stderr) + + return target.compile_and_link([module]), stitcher.rpc_map except diagnostic.Error as error: print("\n".join(error.diagnostic.render(colored=True)), file=sys.stderr) raise CompileError() from error