/* makeimp.c Author: Jay Han (jayhan@cs.washington.edu) Date: 3/22/94 This program automatically generates imp-spiral launch code. Features: - Any number of points, any number of processes, in any size of core - Automatically computes imp-step - Two methods: jmp/add or binary - Works under both '88 and '94 Draft standards - Redefinable labels Bugs: - Does not generate ultimately optimized code in some cases *******************************************************************************/ #include #include #include #define LABELS 4 #define LABELSIZE 16 long i, p=0; int std=94, *labels; char labelname[LABELS][LABELSIZE] = {"launch", "imp", "step", "lbl"}; #define L_LAUNCH 0 #define L_IMP 1 #define L_STEP 2 #define L_LABEL 3 #define launch (labelname[L_LAUNCH]) #define imp (labelname[L_IMP]) #define step (labelname[L_STEP]) #define label (labelname[L_LABEL]) void makelabel (long l) { if (labels[l]) printf ("%s%ld\t", label, l); else printf ("\t"); } void makeimp (long s, long q, int g) { long n, z; if (g == 0) { z = q%(1<>= 1; if (n == 1) { makelabel (q); printf ("jmp\t1\t\t; Idle 1 cycle\n"); } else { if (std == 88) { makelabel (q); printf ("djn\t0,\t#%ld\t; Idle %ld cycles\n", n, n); } else { makelabel (q); printf ("djn.b\t0,\t#%ld\t; Idle %ld cycles\n", n, n); } } if (g-n == 0) { z = (q<>1, (q<<1)+1, g-1); } } char *progname; void error (void) { fprintf (stderr, "Syntax: %s [s #] [a|b] [p|x #] [r #] [l XXX=YYY]\n", progname); fprintf (stderr, " Options: Default:\n"); fprintf (stderr, "imp imp-number -- mandatory --\n"); fprintf (stderr, "s # coresize 55440\n"); fprintf (stderr, "a|b mode: jmp/add or binary binary\n"); fprintf (stderr, "p # number of processes same as imp-number\n"); fprintf (stderr, "x # number of layers (p=x*imp) 1\n"); fprintf (stderr, "r # redcode standard 94\n"); fprintf (stderr, "l # change label XXX to YYY launch imp step lbl\n"); exit (-1); } int main (int argc, char *argv[]) { long m=55440, r, c, n, x, q, s=0, t=1; int j, k; char mode='b', *l; progname = argv[0]; if (argc == 1) error(); for (j=1; j= p) { fprintf (stderr, "%ld is not an imp-number for coresize %ld!\n", p, m); exit (-1); } x = (m*n+1)/p; printf ("; %ld-process %ld-point spiral (coresize %ld, '%d standard)\n", s, p, m, std); printf ("%s\tequ\t%ld\n", step, x); s--; for (q=0, i=0; s; s/=2, i++) q = (q * 2) | (s % 2); printf ("%s\n", launch); switch (mode) { case 'b': labels = (int*) calloc (2<>= 1; } printf ("\tspl\t2\n"); if (std == 88) { printf ("\tjmp\t@0,\t%s\n", imp); printf ("\tadd\t#%s,\t-1\n", step); } else { printf ("\tjmp\t%s\n", imp); printf ("\tadd.a\t#%s,\t-1\n", step); } printf ("\tdat\t#0,\t#0\t; This must be a DAT\n"); break; default: exit (-1); } if (std == 88) printf ("%s\tmov\t0,\t%s\n", imp, step); else printf ("%s\tmov.i\t0,\t%s\n", imp, step); return 0; }