def get_compiled_mfsim(self, tree, file):
        BasicBlock.id_counter = 1
        ir = self.get_ir(tree)
        ir = Program(functions=ir.functions,
                     config=CompilerCLI([
                         "-d", "-inline", "-t", "mfsim", "-i", file, "-o",
                         "output/"
                     ]).config,
                     symbol_table=ir.symbol_table,
                     bb_graph=ir.graph,
                     name=file,
                     calls=ir.calls)
        pm = PassManager(ir)
        pm.run_analysis()
        pm.run_transformations()
        prog = pm.program

        target = MFSimTarget(prog)
        target.transform()
        return str([
            target.num_cgs, target.num_transfers, target.num_dags,
            target.num_detects, target.num_dispense, target.num_dispose,
            target.num_edges, target.num_heats, target.num_mixes,
            target.num_splits, target.expid
        ])
Esempio n. 2
0
    def get_volume(self, tree, file):
        ir = self.get_ir(tree)
        ir = Program(functions=ir.functions, config=CompilerCLI(["-d", "-tv", "-i", file, "-o", "output/"]).config,
                       symbol_table=ir.symbol_table, bb_graph=ir.graph, name=file, calls=ir.calls)
        pm = PassManager(ir)
        pm.run_analysis()
        pm.run_transformations()
        prog = pm.program

        return prog.analysis['volume_tracking']
Esempio n. 3
0
    def get_compiled_ir(self, tree):
        # This resets the basic block counter right before we
        # traverse the IR visitor.  This makes testing for
        # basic block id deterministic and independent of
        # the order in which tests are run.
        BasicBlock.id_counter = 1
        ir = self.get_ir(tree)

        expander = SIMDExpansion()
        target = IRTarget(expander.transform(Program(functions=ir.functions, symbol_table=ir.symbol_table,
                                  bb_graph=ir.graph, name="TEST_FILE", calls=ir.calls,
                                  config=CompilerCLI(["-d", "-t", "ir", "-i", "TEST_FILE"]).config)))
        target.transform()
        return target
Esempio n. 4
0
    def translate(self, filename: str) -> Program:
        """
        Translates the program from the AST into the corresponding IR.
        :param filename: name of file to parse.
        :return:
        """
        file_stream = FileStream(filename)
        lexer = BSLexer(file_stream)
        stream = CommonTokenStream(lexer)
        parser = BSParser(stream)
        tree = parser.program()

        # We can rely on Python's shallow copy and pass by reference semantics
        # to create only one object and allow all the passes to update it.
        symbol_table = SymbolTable()
        identifier = self.config.identify.get_identifier()

        # Order matters, don't mess with the order, it should be Header, Symbol, Method.
        visitor_passes = [
            HeaderVisitor(symbol_table, identifier),
            SymbolTableVisitor(symbol_table, identifier),
            MethodVisitor(symbol_table),
            IRVisitor(symbol_table)
        ]

        for visitor in visitor_passes:
            if self.config.debug:
                self.log.debug("Running {} pass.".format(visitor.visitor_name))
            visitor.visit(tree)

        ir = visitor_passes[-1]
        self.program = Program(functions=ir.functions,
                               config=self.config,
                               symbol_table=ir.symbol_table,
                               bb_graph=ir.graph,
                               name=self.config.input_file,
                               calls=ir.calls)

        self.visit_type_check(tree, ir.symbol_table)

        if self.config.write_cfg:
            for root in self.program.functions:
                self.program.write['{}_basic_block_graph'.format(
                    root)] = Writable(
                        self.program.name, "{}/{}_{}_basic_blocks.dot".format(
                            self.config.output, self.program.name,
                            root), self.program.functions[root]['graph'],
                        WritableType.GRAPH)
        return self.program