p.print(" " + DYNMSGHEADER + " = construct_dyn_hdr(0, " + size + ", 0, " + (layout.getTile(self)).getY() + ", " + (layout.getTile(self)).getX() + ", " + (layout.getTile(downstream)).getY() + "," + (layout.getTile(downstream)).getX() + ");\n");
if (layout.isAssigned(downstream)) { p.print(" " + DYNMSGHEADER + " = construct_dyn_hdr(0, " + size + ", 0, " + (layout.getTile(self)).getY() + ", " + (layout.getTile(self)).getX() + ", " + (layout.getTile(downstream)).getY() + "," + (layout.getTile(downstream)).getX() + ");\n"); } else {    assert false : "dynamic file writers not supported yet"; }
    public void visitFilter(SIRFilter self,                            SIRFilterIter iter) {        //       System.out.println(self.getName());                //Entry point of the visitor        //do not print the raw header if compiling        //for uniprocessor        if (!KjcOptions.standalone)             p.print("#include <raw.h>\n");        p.print("#include <stdlib.h>\n");        p.print("#include <math.h>\n\n");        //if we are number gathering and this is the sink, generate the dummy        //vars for the assignment of the print expression.        if (KjcOptions.numbers > 0) {            p.print("volatile int dummyInt;\n");            p.print("volatile float dummyFloat;\n");        }                if (KjcOptions.altcodegen && !KjcOptions.decoupled){            p.print(getNetRegsDecls());            //print("unsigned " + DYNMSGHEADER + ";\n");        }                            if (KjcOptions.decoupled) {            p.print("volatile float " + Util.CSTOFPVAR + ";\n");            p.print("volatile float " + Util.CSTIFPVAR + ";\n");            p.print("volatile int " + Util.CSTOINTVAR + ";\n");            p.print("volatile int " + Util.CSTIINTVAR + ";\n");            p.print("volatile float " + Util.CGNOFPVAR + ";\n");            p.print("volatile float " + Util.CGNIFPVAR + ";\n");            p.print("volatile int " + Util.CGNOINTVAR + ";\n");            p.print("volatile int " + Util.CGNIINTVAR + ";\n");        }                if (SpaceDynamicBackend.FILTER_DEBUG_MODE) {            p.print("void static_send_print(");            if (self.getOutputType() == CStdType.Void)                p.print("int f) {\n");                        else                 p.print(self.getOutputType() + " f) {\n");            if (self.getOutputType().isFloatingPoint())                 p.print("print_float(f);\n");            else                 p.print("print_int(f);\n");            p.print("static_send(f);\n");            p.print("}\n\n");        }                p.print("#include \"structs.h\"\n");        //print the extern for the function to init the         //switch, do not do this if we are compiling for        //a uniprocessor        if (!KjcOptions.standalone) {            p.print("void raw_init();\n");            p.print("void raw_init2();\n");        }                        //not used any more        //print("unsigned int " + FLOAT_HEADER_WORD + ";\n");        //print("unsigned int " + INT_HEADER_WORD + ";\n");               //Visit fields declared in the filter class        JFieldDeclaration[] fields = self.getFields();        for (int i = 0; i < fields.length; i++)           fields[i].accept(this);                //visit methods of filter, print the declaration first        setDeclOnly(true);        JMethodDeclaration[] methods = self.getMethods();        for (int i =0; i < methods.length; i++)            methods[i].accept(this);        //now print the functions with body        setDeclOnly(false);        for (int i =0; i < methods.length; i++) {            methods[i].accept(this);            }                //if we are generating raw code print the begin        //method for the simulator        if (!KjcOptions.standalone) {            p.print("void begin(void) {\n");        }        else {            //otherwise print a normal main()            p.print("int main() {\n");        }                //for the first filter/tile we encounter we are going to         //create a magic instruction that tells the number-gathering        //stuff that everything is done snake booting, so if this is true        if (!gen_magc_done_boot && KjcOptions.numbers > 0) {            gen_magc_done_boot = true;            p.print("  __asm__ volatile (\"magc $0, $0, 5\");\n");        }                //not used at this time        //print(FLOAT_HEADER_WORD +         //" = construct_dyn_hdr(3, 1, 0, 0, 0, 3, 0);\n");        //print(INT_HEADER_WORD +         //" = construct_dyn_hdr(3, 1, 1, 0, 0, 3, 0);\n");                //if we are using the dynamic network create the dynamic network        //header to be used for all outgoing messages        if (dynamicOutput) {            FlatNode downstream =                 ssg.getStreamGraph().getParentSSG(flatNode).getNext(flatNode);                        if (downstream != null) {                int size = Util.getTypeSize(ssg.getOutputType(flatNode));		assert size < 31 : "Type size too large to fit in single dynamic network packet";                /*System.out.println(flatNode + " " + layout.getTile(flatNode) +                                    " dynamically sends to + " + downstream + " " +                                    layout.getTile(downstream) + ", size = " + size);                */                p.print(" " + DYNMSGHEADER + " = construct_dyn_hdr(0, " +                      size + ", 0, " +                      (layout.getTile(self)).getY() + ", " +                      (layout.getTile(self)).getX() + ", " +                       (layout.getTile(downstream)).getY() + "," +                      (layout.getTile(downstream)).getX() + ");\n");            }        }                //if we are using the magic network,         //use a magic instruction to initialize the magic fifos        if (KjcOptions.magic_net)            p.print("  __asm__ volatile (\"magc $0, $0, 1\");\n");                //initialize the dummy network receive value        if (KjcOptions.decoupled) {            if (self.getInputType().isFloatingPoint())                 p.print("  " + Util.CSTIFPVAR + " = 1.0;\n");            else                 p.print("  " + Util.CSTIINTVAR + " = 1;\n");        }        //call the raw_init() function for the static network        //only if we are not using a uniprocessor or the        //magic network        if (!(KjcOptions.standalone || KjcOptions.magic_net || KjcOptions.decoupled ||              IMEMEstimation.TESTING_IMEM)) {            p.print("  raw_init();\n");            p.print("  raw_init2();\n");        }        //execute the raw main function        p.print(RawExecutionCode.rawMain + "();\n");        //return 0 if we are generating normal c code        if (KjcOptions.standalone)             p.print("  return 0;\n");        p.print("}\n");        createFile();    }