63
return linklinefmt(ctxt, fp);
70
Dlist = allocn(Dlist, nDlist*sizeof(char *),
78
print("usage: %ca [options] file.c...\n", thechar);
61
83
main(int argc, char *argv[])
90
ctxt = linknew(&link386);
93
Binit(&bstdout, 1, OWRITE);
95
fmtinstall('L', Lconv);
97
// Allow GOARCH=thestring or GOARCH=thestringsuffix,
98
// but not other values.
100
if(strncmp(p, thestring, strlen(thestring)) != 0)
101
sysfatal("cannot use %cc with GOARCH=%s", thechar, p);
69
103
ensuresymb(NSYMB);
70
104
memset(debug, 0, sizeof(debug));
77
if(c >= 0 && c < sizeof(debug))
89
Dlist = allocn(Dlist, nDlist*sizeof(char *),
101
print("usage: %ca [-options] file.s\n", thechar);
109
flagfn1("D", "name[=value]: add #define", dodef);
110
flagfn1("I", "dir: add dir to include path", setinclude);
111
flagcount("S", "print assembly and machine code", &debug['S']);
112
flagcount("m", "debug preprocessor macros", &debug['m']);
113
flagstr("o", "file: set output file", &outfile);
114
flagstr("trimpath", "prefix: remove prefix from recorded source file paths", &ctxt->trimpath);
116
flagparse(&argc, &argv, usage);
117
ctxt->debugasm = debug['S'];
105
122
print("can't assemble multiple files\n");
108
126
if(assemble(argv[0]))
147
166
Binit(&obuf, of, OWRITE);
152
Bprint(&obuf, "go object %s %s %s\n", getgoos(), thestring, getgoversion());
154
for(i=0; i<nDlist; i++)
167
Bprint(&obuf, "go object %s %s %s\n", getgoos(), getgoarch(), getgoversion());
168
Bprint(&obuf, "!\n");
170
for(pass = 1; pass <= 2; pass++) {
172
for(i=0; i<nDlist; i++)
162
Bprint(&obuf, "\n!\n");
167
for(i=0; i<nDlist; i++)
180
writeobj(ctxt, &obuf);
778
790
"PSUBW", LTYPE3, APSUBW,
779
791
"PUNPCKHQDQ", LTYPE3, APUNPCKHQDQ,
780
792
"PUNPCKLQDQ", LTYPE3, APUNPCKLQDQ,
793
"PXOR", LTYPE3, APXOR,
781
794
"RCPPS", LTYPE3, ARCPPS,
782
795
"RCPSS", LTYPE3, ARCPSS,
783
796
"RSQRTPS", LTYPE3, ARSQRTPS,
834
840
s->type = itab[i].type;
835
841
s->value = itab[i].value;
838
pathname = allocn(pathname, 0, 100);
839
if(getwd(pathname, 99) == 0) {
840
pathname = allocn(pathname, 100, 900);
841
if(getwd(pathname, 999) == 0)
842
strcpy(pathname, "/???");
873
872
g2.from = nullgen;
875
874
outcode(AEND, &g2);
880
zname(char *n, int t, int s)
883
BPUTLE2(&obuf, ANAME); /* as(2) */
884
BPUTC(&obuf, t); /* type */
885
BPUTC(&obuf, s); /* sym */
902
if(a->index != D_NONE || a->scale != 0)
917
t |= T_OFFSET|T_OFFSET2;
927
if(t & T_INDEX) { /* implies index, scale */
928
BPUTC(&obuf, a->index);
929
BPUTC(&obuf, a->scale);
931
if(t & T_OFFSET) { /* implies offset */
939
if(t & T_SYM) /* implies sym */
942
ieeedtod(&e, a->dval);
949
for(i=0; i<NSNAME; i++) {
956
BPUTC(&obuf, a->type);
960
outcode(int a, Gen2 *g2)
880
outcode(int a, Addr2 *g2)
973
if(sf < 0 || sf >= NSYM)
981
zname(s->name, t, sym);
995
if(st < 0 || st >= NSYM)
1003
zname(s->name, t, sym);
1016
BPUTLE4(&obuf, stmtline);
1017
zaddr(&g2->from, sf);
888
p = malloc(sizeof *p);
889
memset(p, 0, sizeof *p);
891
p->lineno = stmtline;
897
pl = linknewplist(ctxt);
1021
904
if(a != AGLOBL && a != ADATA)
1030
char *p, *q, *op, c;
1033
static int first = 1;
1034
static char *goroot, *goroot_final;
1037
// Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL.
1039
goroot = getenv("GOROOT");
1040
goroot_final = getenv("GOROOT_FINAL");
1043
if(goroot_final == nil)
1044
goroot_final = goroot;
1045
if(strcmp(goroot, goroot_final) == 0) {
1055
for(h = hist; h != H; h = h->link) {
1057
if(p != nil && goroot != nil) {
1059
if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') {
1060
tofree = smprint("%s%s", goroot_final, p+n);
1065
if(systemtype(Windows) && p && p[1] == ':'){
1067
} else if(p && p[0] != c && h->offset == 0 && pathname){
1068
if(systemtype(Windows) && pathname[1] == ':') {
1072
} else if(pathname[0] == c){
1082
n = 1; /* leading "/" */
1083
*p = '/'; /* don't emit "\" on windows */
1091
BPUTLE2(&obuf, ANAME);
1092
BPUTC(&obuf, D_FILE); /* type */
1093
BPUTC(&obuf, 1); /* sym */
1095
Bwrite(&obuf, p, n);
1104
g.offset = h->offset;
1106
BPUTLE2(&obuf, AHISTORY);
1107
BPUTLE4(&obuf, h->line);
1118
908
#include "../cc/lexbody"
1119
909
#include "../cc/macbody"