Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion aps2scala/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CPP=g++
CPPFLAGS=-Wall -g -Wno-unused-variable -DUSING_CXX -DAPS2SCALA -I../parse -I../analyze -I../codegen -I../utilities

APS2SCALAOBJS = aps2scala.o dump-scala.o implement.o dyn-impl.o static-impl.o static-scc-impl.o
APS2SCALAOBJS = aps2scala.o dump-scala.o implement.o dyn-impl.o static-impl.o static-scc-impl.o farrow-impl.o synth-util.o
APS2SCALALIBS = ../lib/aps-lib.o ../lib/aps-ag.a ../utilities/utilities.o
aps2scala : ${APS2SCALAOBJS} ${APS2SCALALIBS}
${CPP} ${CPPFLAGS} ${APS2SCALAOBJS} ${APS2SCALALIBS} -o aps2scala
Expand All @@ -17,6 +17,12 @@ static-impl.o : ../codegen/static-impl.cc
static-scc-impl.o : ../codegen/static-scc-impl.cc
${CPP} -c ${CPPFLAGS} $< -o $@

farrow-impl.o : ../codegen/farrow-impl.cc ../codegen/synth-util.h
${CPP} -c ${CPPFLAGS} $< -o $@

synth-util.o : ../codegen/synth-util.cc ../codegen/synth-util.h
${CPP} -c ${CPPFLAGS} $< -o $@

implement.o : ../codegen/implement.cc
${CPP} -c ${CPPFLAGS} $< -o $@

Expand Down
17 changes: 15 additions & 2 deletions aps2scala/aps2scala.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void usage() {
fprintf(stderr," -V increase verbosity of generation code\n");
fprintf(stderr," -G add Debug calls for every function\n");
fprintf(stderr," -C SCC chunk static scheduling\n");
fprintf(stderr," -F0, --synth-pure-farrow generate original Farrow SYNTH evaluation\n");
fprintf(stderr," -p path set the APSPATH (overriding env. variable)\n");
exit(1);
}
Expand All @@ -40,6 +41,7 @@ extern int aps_yyparse(void);
Implementation* impl;
bool static_schedule = false;
bool is_tree_only_program = false;
bool farrow_implementation = false;

static void* program_is_tree_only(void *scope, void *node) {
if (ABSTRACT_APS_tnode_phylum(node) == KEYDeclaration) {
Expand Down Expand Up @@ -82,6 +84,10 @@ int main(int argc,char **argv) {
static_schedule = true;
static_scc_schedule = true;
continue;
} else if (streq(argv[i],"-F0") || streq(argv[i],"--synth-pure-farrow")) {
farrow_implementation = true;
anc_analysis = true;
continue;
} else if (streq(argv[i],"-V") || streq(argv[i],"--verbose")) {
++verbose;
continue;
Expand Down Expand Up @@ -110,8 +116,14 @@ int main(int argc,char **argv) {
type_Program(p);
traverse_Program(program_is_tree_only, p, p);
aps_check_error("type");
if (static_schedule) {
impl = static_scc_schedule ? static_scc_impl : static_impl;
if (static_schedule || farrow_implementation) {
if (farrow_implementation) {
impl = farrow_impl;
} else if (static_scc_schedule) {
impl = static_scc_impl;
} else {
impl = static_impl;
}
analyze_Program(p);
aps_check_error("analysis");
if (!impl) {
Expand All @@ -121,6 +133,7 @@ int main(int argc,char **argv) {
} else {
impl = dynamic_impl;
}
impl->validate_program(p);
char* outfilename = str2cat(argv[i],".scala");

std::ofstream out(outfilename);
Expand Down
22 changes: 20 additions & 2 deletions aps2scala/dump-scala.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ void dump_scala_Declaration(Declaration decl,ostream& oss)
++nesting_level;

STATE *s = (STATE*)Declaration_info(decl)->analysis_state;
if (static_scc_schedule && s != NULL)
if ((static_scc_schedule || anc_analysis) && s != NULL)
{
activate_static_circular = s->loop_required;
}
Expand Down Expand Up @@ -2455,6 +2455,11 @@ void dump_Expression(Expression e, ostream& o)
dump_collect_Actuals(infer_expr_type(e),funcall_actuals(e),o);
return;
}

if (auto* synth = dynamic_cast<SynthImplementation*>(impl)) {
if (synth->try_dump_funcall(e, o)) return;
}

bool dump_anchor_actual = false;
if (should_include_ast_for_objects()) {
Expression fexpr = funcall_f(e);
Expand Down Expand Up @@ -2691,7 +2696,7 @@ string operator+(string s, int i)
string indent(int nl) { return string(indent_multiple*nl,' '); }

bool check_surrounding_decl(void* node, KEYTYPE_Declaration decl_key, Declaration* result_decl) {
while (node != NULL) {
while (node != NULL && ABSTRACT_APS_tnode_phylum(node) != KEY_ABSTRACT_APS_None) {
if (ABSTRACT_APS_tnode_phylum(node) == KEYDeclaration) {
Declaration decl = (Declaration)node;
if (Declaration_KEY(decl) == decl_key) {
Expand All @@ -2705,3 +2710,16 @@ bool check_surrounding_decl(void* node, KEYTYPE_Declaration decl_key, Declaratio
*result_decl = NULL;
return false;
}

bool check_surrounding_node(void* node, KEYTYPE_ABSTRACT_APS_Phylum ast_key, void** result_node) {
while (node != NULL && ABSTRACT_APS_tnode_phylum(node) != KEY_ABSTRACT_APS_None) {
if (ABSTRACT_APS_tnode_phylum(node) == ast_key) {
*result_node = node;
return true;
}
node = tnode_parent(node);
}

*result_node = NULL;
return false;
}
3 changes: 3 additions & 0 deletions codegen/dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ inline ostream& operator<<(ostream&os, INSTANCE*i) {

extern string operator+(string, int);

bool check_surrounding_decl(void* node, KEYTYPE_Declaration decl_key, Declaration* result_decl);
bool check_surrounding_node(void* node, KEYTYPE_ABSTRACT_APS_Phylum ast_key, void** result_node);

#ifndef APS2SCALA
// special C++ generation code
// sending to oss copies to cpps, ...
Expand Down
Loading
Loading