forked from M-Labs/artiq
1
0
Fork 0

compiler: use ARTIQ_IR_NO_LOC variable to control IR dump output.

Useful e.g. in tests or for running diff on irgen output.
This commit is contained in:
whitequark 2018-05-19 16:57:30 +00:00
parent 21a0f26cd1
commit dc1c4ebf1d
3 changed files with 11 additions and 3 deletions

View File

@ -303,6 +303,7 @@ class BasicBlock(NamedValue):
:ivar instructions: (list of :class:`Instruction`) :ivar instructions: (list of :class:`Instruction`)
""" """
_dump_loc = True
def __init__(self, instructions, name=""): def __init__(self, instructions, name=""):
super().__init__(TBasicBlock(), name) super().__init__(TBasicBlock(), name)
@ -383,7 +384,7 @@ class BasicBlock(NamedValue):
# Annotated instructions # Annotated instructions
loc = None loc = None
for insn in self.instructions: for insn in self.instructions:
if loc != insn.loc: if self._dump_loc and loc != insn.loc:
loc = insn.loc loc = insn.loc
if loc is None: if loc is None:

View File

@ -1,5 +1,5 @@
import os, sys, tempfile, subprocess, io import os, sys, tempfile, subprocess, io
from artiq.compiler import types from artiq.compiler import types, ir
from llvmlite_artiq import ir as ll, binding as llvm from llvmlite_artiq import ir as ll, binding as llvm
llvm.initialize() llvm.initialize()
@ -131,6 +131,9 @@ class Target:
print("====== MODULE_SIGNATURE DUMP ======", file=sys.stderr) print("====== MODULE_SIGNATURE DUMP ======", file=sys.stderr)
print(module, file=sys.stderr) print(module, file=sys.stderr)
if os.getenv("ARTIQ_IR_NO_LOC") is not None:
ir.BasicBlock._dump_loc = False
type_printer = types.TypePrinter() type_printer = types.TypePrinter()
_dump(os.getenv("ARTIQ_DUMP_IR"), "ARTIQ IR", ".txt", _dump(os.getenv("ARTIQ_DUMP_IR"), "ARTIQ IR", ".txt",
lambda: "\n".join(fn.as_entity(type_printer) for fn in module.artiq_ir)) lambda: "\n".join(fn.as_entity(type_printer) for fn in module.artiq_ir))

View File

@ -1,8 +1,12 @@
import sys, fileinput import sys, os, fileinput
from pythonparser import diagnostic from pythonparser import diagnostic
from .. import ir
from ..module import Module, Source from ..module import Module, Source
def main(): def main():
if os.getenv("ARTIQ_IR_NO_LOC") is not None:
ir.BasicBlock._dump_loc = False
def process_diagnostic(diag): def process_diagnostic(diag):
print("\n".join(diag.render())) print("\n".join(diag.render()))
if diag.level in ("fatal", "error"): if diag.level in ("fatal", "error"):