LOCAL VOID pushnextargs P4C(LVAL, fcn, int, n, LVAL, args, int, i) { LVAL *newfp, next, value = NULL; /* build a new argument stack frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fcn); pusharg(cvfixnum((FIXTYPE)n)); /* push the arguments and shift the list pointers */ for (next = args; consp(next); next = cdr(next)) { switch (ntype(car(next))) { case VECTOR: value = getelement(car(next), i); break; case TVEC: value = gettvecelement(car(next), i); break; case CONS: value = car(car(next)); rplaca(next, cdr(car(next))); break; } pusharg(value); } /* establish the new stack frame */ xlfp = newfp; }
/* evalhook - call the evalhook function */ LOCAL LVAL evalhook(LVAL expr) { LVAL *newfp,olddenv,val; /* create the new call frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(getvalue(s_evalhook)); pusharg(cvfixnum((FIXTYPE)2)); pusharg(expr); pusharg(cons(xlenv,xlfenv)); xlfp = newfp; /* rebind the hook functions to nil */ olddenv = xldenv; xldbind(s_evalhook,NIL); xldbind(s_applyhook,NIL); /* call the hook function */ val = xlapply(2); /* unbind the symbols */ xlunbind(olddenv); /* return the value */ return (val); }
/* evpushargs - evaluate and push a list of arguments */ LOCAL int evpushargs(LVAL fun, LVAL args) { LVAL *newfp; int argc; /* protect the argument list */ xlprot1(args); /* build a new argument stack frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(NIL); /* will be argc */ /* evaluate and push each argument */ for (argc = 0; consp(args); args = cdr(args), ++argc) pusharg(xleval(car(args))); /* establish the new stack frame */ newfp[2] = cvfixnum((FIXTYPE)argc); xlfp = newfp; /* restore the stack */ xlpop(); /* return the number of arguments */ return (argc); }
/* dotest2 - call a test function with two arguments */ int dotest2 P3C(LVAL, arg1, LVAL, arg2, LVAL, fun) { FRAMEP newfp; /* Speedup for default case TAA MOD */ if (fun == getfunction(s_eql)) return (eql(arg1,arg2)); /* Speedup for EQ and EQUAL for hash tables */ if (fun == getfunction(s_eq)) return (arg1 == arg2); if (fun == getfunction(s_equal)) return (equal(arg1,arg2)); /* create the new call frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(cvfixnum((FIXTYPE)2)); pusharg(arg1); pusharg(arg2); xlfp = newfp; /* return the result of applying the test function */ return (xlapply(2) != NIL); }
void note_i_file (const char *fname, const char *org_fname) { const char *suffix=0; /*const char *speced=0;*/ switch (stop_at) { case STOP_AT_M: /* .i files from cilk2c have no dependencies */ case STOP_AT_CILKI: case STOP_AT_CILKC: case STOP_AT_I: break; case STOP_AT_S: suffix=".s"; /*speced="-S";*/ goto earlystop; case STOP_AT_O: suffix=".o"; /*speced="-c";*/ goto earlystop; earlystop: { const char *outfname = output_name ? output_name : replace_suffix(org_fname, suffix); pushpair(&i_files, fname, outfname); } break; case STOP_AT_END: if (current_output_x!=L_i && current_output_x!=L_none) { pusharg(cc_args, "-x"); pusharg(cc_args, xarg_of_lang(L_i)); current_output_x = L_i; } n_gcc_files++; pusharg(cc_args, fname); break; } }
/* parseargs -> parseargs // Implicit, actually a while loop | pipestate | redirinstate | rediroutstate | waitstate | NULL */ struct CmdGroup *parseargs(struct CmdGroup *cmdgroup, struct CmdNode *cmdnode){ int type; struct Pair *entry; char argname[10]; int argno = 0; while(TRUE){ switch(type = yylex()){ case EXIT: case CD: case SETVAR: type = WORD; case STRING: case WORD: sprintf(argname, "arg %d", ++argno); printparse(type, argname); if(pusharg(cmdnode, tokentext)){ break; } else{ /* ERR: memory allocation */ return cmderror(NONE, cmdgroup, "Could not allocate memory for argument '%s'\n", tokentext); } case VARIABLE: if((entry = find(vartable, tokentext))){ tokentext = entry->value; sprintf(argname, "arg %d", ++argno); printparse(WORD, argname); if(pusharg(cmdnode, tokentext)){ break; } else{ /* ERR: memory allocation */ return cmderror(NONE, cmdgroup, "Could not allocate memory for argument '%s'\n", tokentext); } } else{ /* ERR: missing variable */ return cmderror(type, cmdgroup, "Missing variable %s\n", tokentext); } case EOL: printparse(type, "EOL"); return cmdgroup; case PIPE: printparse(type, "pipe"); return pipestate(cmdgroup); case WAIT: printparse(type, "wait"); return waitstate(cmdgroup); case REDIRIN: printparse(type, "redirect stdin"); return redirinstate(cmdgroup); case REDIROUT: printparse(type, "redirect stdout"); return rediroutstate(cmdgroup); default: return cmderror(type, cmdgroup, "'%s' not allowed mid-command\n", tokentext); } } }
/* callmacro - call a read macro */ LVAL callmacro(LVAL fptr, int ch) { LVAL *newfp; /* create the new call frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(cdr(getelement(getvalue(s_rtable),ch))); pusharg(cvfixnum((FIXTYPE)2)); pusharg(fptr); pusharg(cvchar(ch)); xlfp = newfp; return (xlapply(2)); }
/* xlapp1 - apply a function of a single argument */ LVAL xlapp1 P2C(LVAL, fun, LVAL, arg) { FRAMEP newfp; /* create the new call frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(cvfixnum((FIXTYPE)1)); pusharg(arg); xlfp = newfp; /* return the result of applying the function */ return xlapply(1); }
/* can't handle quoted spaces */ void push_stringified_args (MY_ARGV argv, const char *sargs) { char *CF=strdup(sargs); char *b, *e; char old; b = CF; for (;;) { while (*b == ' ') ++b; e = b; while (*e != ' ' && *e != 0) ++e; old = *e; *e = 0; if (b != e) pusharg(argv, strdup(b)); *e = old; if (*e == 0) break; b = e + 1; } free(CF); }
static NODE * moveargs(NODE *p, int *regp) { NODE *r, **rp; int reg; if (p->n_op == CM) { p->n_left = moveargs(p->n_left, regp); r = p->n_right; rp = &p->n_right; } else { r = p; rp = &p; } reg = *regp; if (reg > R3 && r->n_op != STARG) { *rp = pusharg(r, regp); } else if (r->n_op == STARG) { *rp = movearg_struct(r, regp); } else if (DEUNSIGN(r->n_type) == LONGLONG) { *rp = movearg_64bit(r, regp); } else if (r->n_type == DOUBLE || r->n_type == LDOUBLE) { *rp = movearg_double(r, regp); } else if (r->n_type == FLOAT) { *rp = movearg_float(r, regp); } else { *rp = movearg_32bit(r, regp); } return straighten(p); }
/* dotest1 - call a test function with one argument */ int dotest1(LVAL arg, LVAL fun) { LVAL *newfp; /* create the new call frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(cvfixnum((FIXTYPE)1)); pusharg(arg); xlfp = newfp; /* return the result of applying the test function */ return (xlapply(1) != NIL); }
static void bootargs(ulong base) { int i, ac; uchar *av[32]; uchar *bootpath; uchar **lsp; /* * the sizeof(Sargs) is to make the validaddr check in * trap.c's syscall() work even when we have less than the * max number of args. */ sp = (uchar*)base + BY2PG - sizeof(Sargs); bootpath = pusharg("/boot/boot"); ac = 0; av[ac++] = pusharg("boot"); /* 4 byte word align stack */ sp = (uchar*)((ulong)sp & ~3); /* build argc, argv on stack */ sp -= (ac+1)*sizeof(sp); lsp = (uchar**)sp; for(i = 0; i < ac; i++) *lsp++ = av[i] + ((USTKTOP - BY2PG) - base); *lsp = 0; /* push argv onto stack */ sp -= BY2WD; lsp = (uchar**)sp; *lsp = sp + BY2WD + ((USTKTOP - BY2PG) - base); /* push pointer to "/boot" */ sp -= BY2WD; lsp = (uchar**)sp; *lsp = bootpath + ((USTKTOP - BY2PG) - base); /* leave space for where the initcode's caller's return PC would normally reside */ sp -= BY2WD; /* relocate stack to user's virtual addresses */ sp += (USTKTOP - BY2PG) - base; }
/* dotest1 - call a test function with one argument */ int dotest1 P3C(LVAL, arg, LVAL, fun, LVAL, kfun) { FRAMEP newfp; if (kfun != NIL) arg = xlapp1(kfun,arg); /* create the new call frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(cvfixnum((FIXTYPE)1)); pusharg(arg); xlfp = newfp; /* return the result of applying the test function */ return (xlapply(1) != NIL); }
void arginit(void) { char **av; av = (char**)argbuf; sp = argbuf + sizeof(argbuf); *av++ = pusharg("boot"); *av = 0; }
/* called from moveargs() */ static NODE * movearg_64bit(NODE *p, int *regp) { int reg = *regp; NODE *q, *r; #if ALLONGLONG == 64 /* alignment */ ++reg; reg &= ~1; *regp = reg; #endif if (reg > R3) { q = pusharg(p, regp); } else if (reg == R3) { /* half in and half out of the registers */ r = tcopy(p); if (!features(FEATURE_BIGENDIAN)) { q = block(SCONV, p, NIL, INT, 0, 0); q = movearg_32bit(q, regp); /* little-endian */ r = buildtree(RS, r, bcon(32)); r = block(SCONV, r, NIL, INT, 0, 0); r = pusharg(r, regp); /* little-endian */ } else { q = buildtree(RS, p, bcon(32)); q = block(SCONV, q, NIL, INT, 0, 0); q = movearg_32bit(q, regp); /* big-endian */ r = block(SCONV, r, NIL, INT, 0, 0); r = pusharg(r, regp); /* big-endian */ } q = straighten(block(CM, q, r, p->n_type, p->n_df, p->n_ap)); } else { q = block(REG, NIL, NIL, p->n_type, p->n_df, p->n_ap); regno(q) = R0R1 + (reg - R0); q = buildtree(ASSIGN, q, p); *regp = reg + 2; } return q; }
/* xfuncall - the built-in function 'funcall' */ LVAL xfuncall(void) { LVAL *newfp; int argc; /* build a new argument stack frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(xlgetarg()); pusharg(NIL); /* will be argc */ /* push each argument */ for (argc = 0; moreargs(); ++argc) pusharg(nextarg()); /* establish the new stack frame */ newfp[2] = cvfixnum((FIXTYPE)argc); xlfp = newfp; /* apply the function to the arguments */ return (xlapply(argc)); }
/* pushargs - push a list of arguments */ int pushargs(LVAL fun, LVAL args) { LVAL *newfp; int argc; /* build a new argument stack frame */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(NIL); /* will be argc */ /* push each argument */ for (argc = 0; consp(args); args = cdr(args), ++argc) pusharg(car(args)); /* establish the new stack frame */ newfp[2] = cvfixnum((FIXTYPE)argc); xlfp = newfp; /* return the number of arguments */ return (argc); }
void bootargs(void *base) { int i, ac; uchar *av[32]; uchar **lsp; char *cp = BOOTLINE; char buf[64]; sp = (uchar*)base + BY2PG - Ustkheadroom; ac = 0; av[ac++] = pusharg("/386/9dos"); /* when boot is changed to only use rc, this code can go away */ cp[BOOTLINELEN-1] = 0; buf[0] = 0; if(strncmp(cp, "fd", 2) == 0){ snprint(buf, sizeof buf, "local!#f/fd%lddisk", strtol(cp+2, 0, 0)); av[ac++] = pusharg(buf); } else if(strncmp(cp, "sd", 2) == 0){ snprint(buf, sizeof buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3)); av[ac++] = pusharg(buf); } else if(strncmp(cp, "ether", 5) == 0) av[ac++] = pusharg("-n"); /* 4 byte word align stack */ sp = (uchar*)((ulong)sp & ~3); /* build argc, argv on stack */ sp -= (ac+1)*sizeof(sp); lsp = (uchar**)sp; for(i = 0; i < ac; i++) *lsp++ = av[i] + ((USTKTOP - BY2PG) - (ulong)base); *lsp = 0; sp += (USTKTOP - BY2PG) - (ulong)base - sizeof(ulong); }
LVAL xlcallsubr1 P2C(subrfun, f, LVAL, x) { LVAL *oldargv, *oldsp, val; int oldargc; oldsp = xlsp; oldargc = xlargc; oldargv = xlargv; pusharg(x); xlargv = oldsp; xlargc = 1; val = (*f)(); xlargc = oldargc; xlargv = oldargv; xlsp = oldsp; return(val); }
LVAL xlapplysubr P2C(subrfun, f, LVAL, args) { LVAL *oldargv, *oldsp, val; int argc, oldargc; oldsp = xlsp; oldargc = xlargc; oldargv = xlargv; for (argc = 0; consp(args); args = cdr(args), argc++) pusharg(car(args)); xlargv = oldsp; xlargc = argc; val = (*f)(); xlargc = oldargc; xlargv = oldargv; xlsp = oldsp; return(val); }
int main(int argc, char *argv[]) { int opt; char *cmd, *opts; progname = strbsnm(argv[0]); if (argc < 2) error(EXIT_FAILURE, 0, "missing FILE"); cmd = strbsnm(argv[1]); pusharg("/bin/rc"); pusharg(argv[1]); opts = optstr(argv[1]); opterr = 0; argc--, argv++; while ((opt = getopt(argc, argv, opts)) != -1) { switch (opt) { case '?': progname = cmd; error(EXIT_FAILURE, 0, "unknown option: -%c", optopt); case ':': progname = cmd; error(EXIT_FAILURE, 0, "option requires argument: -%c", optopt); default: pusharg(optctos(opt)); if (strchr(opts, opt)[1] == ':') pusharg(optarg); } } pusharg("--"); while (optind < argc) pusharg(argv[optind++]); pusharg(NULL); setenv("cmd", cmd, 1); setenv("fn_err", "{echo >[1=2] $cmd^: $*; exit 1}", 1); setenv("fn_usage", "{echo usage: $cmd $usage}", 1); execvp(arg.v[0], arg.v); error(EXIT_FAILURE, errno, "exec: %s", arg.v[0]); return 0; }
void do_cpp2(void) { PAIRLIST cf; for (cf=cilkc_files; cf; cf=cf->rest) { MY_ARGV ma = make_my_argv(); push_stringified_args(ma, get_cc()); pusharg(ma, "-E"); pusharg(ma, "-I" CILKHEADER_DIR); # ifdef CILK_RTSBUILD_DIR pusharg(cpp1_args, "-I" CILK_RTSBUILD_DIR ); # endif pusharg(ma, "-D_REENTRANT"); pusharg(ma, "-x"); pusharg(ma, "c"); pusharg(ma, cf->a); assert(cf->b); push_stringified_args(ma, CILKC_PTHREAD_CFLAGS); VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1,print_my_argv(stderr, ma, cf->b)); if (my_system(ma, cf->b)!=0) barf("failed running cpp2"); free_my_argv(ma); } }
void do_M (void) { if (cilk_files) { /* Create dependencies for cilk programs . */ MY_ARGV ma = make_my_argv(); push_stringified_args(ma, get_cc()); pusharg(ma, stop_at_m_arg); pusharg(ma, "-xc"); pusharg(ma, "-include"); pusharg(ma, CILK_H_LOCATION); { PAIRLIST cf; for (cf=cilk_files; cf; cf=cf->rest) { assert(cf->b==0); pusharg(ma, cf->a); } } pushargs(ma, cpp1_args); push_stringified_args(ma, CILKC_PTHREAD_CFLAGS); VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1, print_my_argv(stderr, ma, 0)); if (my_system(ma, 0)!=0) barf("creating dependencies for cilk files"); free_my_argv(ma); } if (n_gcc_files>0) { MY_ARGV ma = make_my_argv(); push_stringified_args(ma, get_cc()); pusharg(ma, stop_at_m_arg); pushargs(ma, cc_args); push_stringified_args(ma, CILKC_PTHREAD_CFLAGS); VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1, print_my_argv(stderr, ma, 0)); if (my_system(ma, 0)!=0) barf("creating dependencies for cilk files"); free_my_argv(ma); } }
void do_cilk2c(void) { PAIRLIST cf; for (cf=cilki_files; cf; cf=cf->rest) { MY_ARGV ma = make_my_argv(); pusharg(ma, CILK2C_LOCATION); pusharg(ma, cf->a); assert(cf->b); pusharg(ma, "-o"); pusharg(ma, cf->b); if (cilk_hint) pusharg(ma, "-hint"); pushargs(ma, cilkc_args); VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1,print_my_argv(stderr, ma, 0)); if (my_system(ma, 0)!=0) barf("failed running cilk2c"); free_my_argv(ma); } }
void do_cpp1(void) { PAIRLIST cf; for (cf=cilk_files; cf; cf=cf->rest) { MY_ARGV ma = make_my_argv(); push_stringified_args(ma, get_cc()); pusharg(ma, "-E"); pusharg(ma, "-xc"); pusharg(ma, "-include"); pusharg(ma, CILK_H_LOCATION); pusharg(ma, cf->a); assert(cf->b); pushargs(ma, cpp1_args); push_stringified_args(ma, CILKC_PTHREAD_CFLAGS); VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1, print_my_argv(stderr, ma, cf->b)); if (my_system(ma, cf->b)!=0) barf("failed running cpp1"); free_my_argv(ma); } }
/* map - internal mapping function */ LOCAL LVAL map(int carflag, int valflag) { LVAL *newfp,fun,lists,val,last,p,x,y; int argc; /* protect some pointers */ xlstkcheck(3); xlsave(fun); xlsave(lists); xlsave(val); /* get the function to apply and the first list */ fun = xlgetarg(); lists = xlgalist(); /* initialize the result list */ val = (valflag ? NIL : lists); /* build a list of argument lists */ for (lists = last = consa(lists); moreargs(); last = cdr(last)) rplacd(last,cons(xlgalist(),NIL)); /* loop through each of the argument lists */ for (;;) { /* build an argument list from the sublists */ newfp = xlsp; pusharg(cvfixnum((FIXTYPE)(newfp - xlfp))); pusharg(fun); pusharg(NIL); argc = 0; for (x = lists; x && (y = car(x)) && consp(y); x = cdr(x)) { pusharg(carflag ? car(y) : y); rplaca(x,cdr(y)); ++argc; } /* quit if any of the lists were empty */ if (x) { xlsp = newfp; break; } /* apply the function to the arguments */ newfp[2] = cvfixnum((FIXTYPE)argc); xlfp = newfp; if (valflag) { p = consa(xlapply(argc)); if (val) rplacd(last,p); else val = p; last = p; } else xlapply(argc); } /* restore the stack */ xlpopn(3); /* return the last test expression value */ return (val); }
static void pushargs(MY_ARGV to_ma, const MY_ARGV from_ma) { unsigned int i; for (i=0; i<from_ma->argc; i++) { pusharg(to_ma, from_ma->argv[i]); } }
/* return 0 on success */ void parse_args2 (int argc, const char *argv[]) { int n_input_files = 0; cilkc_args = make_my_argv(); cc_early_args = make_my_argv(); cc_args = make_my_argv(); cpp1_args = make_my_argv(); argc--; argv++; while (argc>0) { /*printf("argv=%s\n", *argv);*/ if (match(*argv, "-cc")) { if (argc == 1) barf("Missing arg to -cc"); argc--; argv++; compiler = *argv; } else if ( match(*argv, "-E0") || match(*argv, "-E1") || match(*argv, "-E") || match(*argv, "-c") || match(*argv, "-S") || match(*argv, "-v") || match(*argv, "-v2") || match(*argv,"-v1") || match(*argv, "-cilk-profile") || match(*argv, "-cilk-debug") || match(*argv, "-cilk-span") || match(*argv, "-cilk-critical-path") || match(*argv, "-cilk-hint") || match(*argv, "-save-temps") /* leave temp files (*.cilkc, *.cilki, *.i) generated from *.cilk */ || match(*argv, "-M") /* generate Make rules */ || match(*argv, "-MM") || match(*argv, "-n") ) { /* nothing, since we already parsed those.*/ } else if (match(*argv, "-o")) { /* nothing, since we already parsed those.*/ argv++; argc--; } else if (match(*argv, "-I")) { /* Pass this and the next argument to the preprocessor (which means also cc at the end). */ if (argc==1) barf("Missing arg to %s", *argv); pusharg(cpp1_args, *argv); pusharg(cc_args, *argv); argc--; argv++; pusharg(cpp1_args, *argv); pusharg(cc_args, *argv); } else if (match(*argv, "--param")) { /* Pass this and the next argument to the compiler. */ if (argc==1) barf("Missing arg to %s", *argv); pusharg(cc_args, *argv); argc--; argv++; pusharg(cc_args, *argv); } else if (headmatch(*argv,"-D") || headmatch(*argv,"-A") || /* assertions for preprocessor */ headmatch(*argv,"-include") || headmatch(*argv,"-I") || headmatch(*argv,"-Wp,")) { /* pass options through the driver to preprocessor */ /* Pass these to the preprocessor. */ pusharg(cpp1_args, *argv); pusharg(cc_args, *argv); } else if (match(*argv, "-l") || match(*argv, "-L") ) { if (argc==1) barf("Missing arg to %s", *argv); pusharg(cc_args, *argv); argc--; argv++; pusharg(cc_args, *argv); } else if (match(*argv, "-g") || /* generate debug info */ headmatch(*argv, "-O") || /* optimization level */ match(*argv, "-ansi") || match(*argv, "-pedantic") ) { pusharg(cc_args, *argv); pusharg(cc_early_args, *argv); } else if (match(*argv, "-woff")) { /* -woff is MIPSPRO specific */ if (argc == 1) barf("Missing arg to -woff"); argc--; argv++; pusharg(cc_args, "-woff"); pusharg(cc_args, *argv); pusharg(cc_early_args, "-woff"); pusharg(cc_early_args, *argv); } else if (headmatch(*argv, "-Wa,") || /* extra arguments to pass to the assembler (gcc specific) */ headmatch(*argv, "-Wp,") || /* extra arguments to pass to the preprocessor (gcc specific) */ headmatch(*argv, "-m") || /* -m is gcc specific */ headmatch(*argv, "-f")) { /* -f is gcc specific */ /* All of these are simply passed through without modification */ pusharg(cc_early_args, *argv); pusharg(cc_args, *argv); pusharg(cpp1_args, *argv); } else if (headmatch(*argv, "-Wc,")){ /* extra arguments to pass to the C compiler (works with any compiler by stripping of the -Wc, */ pusharg(cc_early_args, (*argv)+4); pusharg(cc_args, (*argv)+4); pusharg(cpp1_args, (*argv)+4); } else if (headmatch(*argv, "-Wl,") || /* linker options bypassing compiler driver */ headmatch(*argv, "-l") || /* if it was "-l foo.a" then the previous case matched, otherwise it is "-lfoo.a" here. */ headmatch(*argv, "-L") || match(*argv, "-static") ) { pusharg(cc_args, *argv); } else if (match(*argv, "-W") || match(*argv, "-Wall")) { pusharg(cilkc_args, "-W5"); /* gcc-specific */ pusharg(cc_early_args, *argv); pusharg(cc_args, *argv); /* printf("pushed %s to cc_args\n", *argv); */ } else if (headmatch(*argv, "-W")) { if (strlen(*argv)==2 && '1'<=*argv[1] && *argv[1] <= '5') { pusharg(cilkc_args, *argv); } else { /* gcc-specific */ pusharg(cc_early_args, *argv); pusharg(cc_args, *argv); } } else if (match(*argv, "-x")) { if (compiler != NULL) { fprintf(stderr, "Warning: -x probably doesn't work except with gcc. I'll try anyway\n"); } if (argc==1) barf("Missing arg to -x"); /* Don't actually push the -x args to the gcc arglist until we get a file. */ argc--; argv++; current_input_x = language_of_xarg(*argv); } else if (match(*argv, "-version")) { do_print_version=1; } else if (match(*argv, "-help")) { do_print_help=1; } else if (**argv!='-') { /* It is a filename */ int finish_up = (stop_at==STOP_AT_END) || (stop_at==STOP_AT_M); enum LANG lang_of_this_arg = language_of_file(current_input_x, *argv); n_input_files++; switch (lang_of_this_arg) { case L_cilk: case L_cilki: case L_cilkc: case L_c: case L_m: case L_cpp: case L_S: /* * cilk, cilki, cilkc, c, m, and cc files produce a separate output unless we finish * also assembler-with-cpp produces an output unless we finish */ if (!finish_up) n_input_files_that_can_make_one_output_file++; /* cilk files produce a separate output unless we finish */ break; case L_h: break; /* .h files never produce a separate output */ case L_i: case L_ii: /* .i and .ii files produce an output if we do -S or -c */ if (stop_at==STOP_AT_S || stop_at==STOP_AT_O) n_input_files_that_can_make_one_output_file++; break; case L_s: /* .s files produce an output if we do -c */ if (stop_at==STOP_AT_O) n_input_files_that_can_make_one_output_file++; break; case L_none: /* .o files and other random files produce no separate output */ break; } /**/; switch (lang_of_this_arg) { case L_cilk: note_cilk_file(*argv, *argv); break; case L_cilki: note_cilki_file(*argv, *argv); break; case L_cilkc: note_cilkc_file(*argv, *argv); break; case L_c: case L_m: case L_cpp: case L_h: case L_i: case L_ii: case L_s: case L_S: case L_none: if ((lang_of_this_arg==current_output_x)) { /* don't need to emit anything if last emitted -x arg matches the language */ } else if (current_output_x==L_none && lang_of_this_arg==language_of_file(L_none, *argv)) { /* don't need to emit anthing if we emitted -x none but the suffix tells us the right answer */ } else { pusharg(cc_args, "-x"); pusharg(cc_args, xarg_of_lang(lang_of_this_arg)); current_output_x = lang_of_this_arg; } n_gcc_files++; pusharg(cc_args, *argv); break; } } else { barf("What is this? %s", *argv); } argc--; argv++; } if (output_name && (n_input_files_that_can_make_one_output_file>1)) barf("You specified an output file, but more than one input file produces an output file in this mode"); if (n_input_files==0 && !do_print_version && !do_print_help) barf("You specified no input files"); pusharg(cpp1_args, "-I" CILKHEADER_DIR ); # ifdef CILK_RTSBUILD_DIR pusharg(cpp1_args, "-I" CILK_RTSBUILD_DIR ); # endif pusharg(cpp1_args, "-D__CILK__"); pusharg(cpp1_args, "-D__CILK2C__"); pusharg(cpp1_args, "-D__REENTRANT"); if (cilk_debug) pusharg(cpp1_args, "-DCILK_DEBUG=1"); if (cilk_profile) { pusharg(cpp1_args, "-DCILK_STATS=1"); pusharg(cpp1_args, "-DCILK_TIMING=1"); } if (cilk_critical_path) { if (!cilk_profile) { barf("-cilk-span requires -cilk-profile"); } pusharg(cpp1_args, "-DCILK_CRITICAL_PATH=1"); } if (cilk_debug) { pusharg(cpp1_args, "-DCILK_DEBUG=1"); } }
/* called from moveargs() */ static NODE * movearg_struct(NODE *p, int *regp) { int reg = *regp; NODE *l, *q, *t, *r; int tmpnr; int navail; int num; int sz; int ty; int i; assert(p->n_op == STARG); navail = NARGREGS - (reg - R0); navail = navail < 0 ? 0 : navail; sz = tsize(p->n_type, p->n_df, p->n_ap) / SZINT; num = sz > navail ? navail : sz; /* remove STARG node */ l = p->n_left; nfree(p); ty = l->n_type; /* * put it into a TEMP, rather than tcopy(), since the tree * in p may have side-affects */ t = tempnode(0, ty, l->n_df, l->n_ap); tmpnr = regno(t); q = buildtree(ASSIGN, t, l); /* copy structure into registers */ for (i = 0; i < num; i++) { t = tempnode(tmpnr, ty, 0, 0); t = block(SCONV, t, NIL, PTR+INT, 0, 0); t = block(PLUS, t, bcon(4*i), PTR+INT, 0, 0); t = buildtree(UMUL, t, NIL); r = block(REG, NIL, NIL, INT, 0, 0); regno(r) = reg++; r = buildtree(ASSIGN, r, t); q = block(CM, q, r, INT, 0, 0); } /* put the rest of the structure on the stack */ for (i = num; i < sz; i++) { t = tempnode(tmpnr, ty, 0, 0); t = block(SCONV, t, NIL, PTR+INT, 0, 0); t = block(PLUS, t, bcon(4*i), PTR+INT, 0, 0); t = buildtree(UMUL, t, NIL); r = pusharg(t, ®); q = block(CM, q, r, INT, 0, 0); } q = reverse(q); *regp = reg; return q; }
void do_cc(void) { if (i_files) { PAIRLIST pl; /* The i_files variable was only filled in if we are stoping after -S or -c */ assert(stop_at==STOP_AT_S || stop_at==STOP_AT_O); for (pl=i_files; pl; pl=pl->rest) { MY_ARGV ma = make_my_argv(); push_stringified_args(ma, get_cc()); pusharg(ma, pl->a); pusharg(ma, "-o"); pusharg(ma, pl->b); pushargs(ma, cc_early_args); if (stop_at==STOP_AT_S) pusharg(ma, "-S"); else if (stop_at==STOP_AT_O) pusharg(ma, "-c"); else abort(); /* This cannot happen. See the assert() above. */ push_stringified_args(ma, CILKC_PTHREAD_CFLAGS); if (save_temps) pusharg(ma, "-save-temps"); VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1, print_my_argv(stderr, ma, 0)); if (my_system(ma, 0)!=0) barf("failed running the final %s to produce %s", get_cc(), pl->b); free_my_argv(ma); } } if (n_gcc_files>0) { MY_ARGV ma = make_my_argv(); push_stringified_args(ma, get_cc()); switch (stop_at) { case STOP_AT_M: barf("I called final cc when I was supposed to do -M"); case STOP_AT_CILKI: case STOP_AT_CILKC: barf("I called final cc when I was supposed to stop earlier"); case STOP_AT_I: pusharg(ma, "-E"); break; case STOP_AT_S: pusharg(ma, "-S"); break; case STOP_AT_O: pusharg(ma, "-c"); break; case STOP_AT_END: break; } pushargs(ma, cc_args); if (stop_at==STOP_AT_END) { pusharg(ma, "-L" LIBS_DIR); pusharg(ma, "-L" LIBS2_DIR); if (cilk_debug) { if (cilk_profile) { pusharg(ma, "-lcilkrt0gp"); pusharg(ma, "-lcilk.g.p"); } else { pusharg(ma, "-lcilkrt0g"); pusharg(ma, "-lcilk.g"); } } else { if (cilk_profile) { pusharg(ma, "-lcilkrt0p"); pusharg(ma, "-lcilk.p"); } else { pusharg(ma, "-lcilkrt0"); pusharg(ma, "-lcilk"); } } # ifdef WITH_GNU_LD pusharg(ma, "-Wl,-rpath," LIBS_DIR); # endif } push_stringified_args(ma, CILKC_PTHREAD_CFLAGS); push_stringified_args(ma, CILKC_PTHREAD_LIBS); if (output_name) { pusharg(ma, "-o"); pusharg(ma, output_name); } VERBOSE(2, pusharg(ma, "-v")); VERBOSE(1, print_my_argv(stderr, ma, 0)); if (my_system(ma, 0)!=0) barf("failed running the final %s", get_cc()); free_my_argv(ma); } }