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`)
"""
_dump_loc = True
def __init__(self, instructions, name=""):
super().__init__(TBasicBlock(), name)
@ -383,7 +384,7 @@ class BasicBlock(NamedValue):
# Annotated instructions
loc = None
for insn in self.instructions:
if loc != insn.loc:
if self._dump_loc and loc != insn.loc:
loc = insn.loc
if loc is None:

View File

@ -1,5 +1,5 @@
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
llvm.initialize()
@ -131,6 +131,9 @@ class Target:
print("====== MODULE_SIGNATURE DUMP ======", 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()
_dump(os.getenv("ARTIQ_DUMP_IR"), "ARTIQ IR", ".txt",
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 .. import ir
from ..module import Module, Source
def main():
if os.getenv("ARTIQ_IR_NO_LOC") is not None:
ir.BasicBlock._dump_loc = False
def process_diagnostic(diag):
print("\n".join(diag.render()))
if diag.level in ("fatal", "error"):