uchar back; // 6l, 8l
uchar ft; /* 6l, 8l oclass cache */
uchar tt; // 6l, 8l
- uchar optab; // 5l
+ uint16 optab; // 5l
uchar isize; // 6l, 8l
char width; /* fake for DATA */
int asmode;
uchar* andptr;
uchar and[100];
- int32 instoffset;
+ int64 instoffset;
int32 autosize;
int32 armsize;
extern char* anames6[];
extern char* anames8[];
+extern char* cnames5[];
+
extern LinkArch link386;
extern LinkArch linkamd64;
extern LinkArch linkamd64p32;
#pragma varargck type "lD" Addr*
#pragma varargck type "P" Prog*
#pragma varargck type "R" int
+#pragma varargck type "^" int
// TODO(ality): remove this workaround.
// It's here because Pconv in liblink/list?.c references %L.
/* compiler allocates register variables F0 up */
/* compiler allocates external registers F7 down */
+enum
+{
+ C_NONE,
+ C_REG,
+ C_REGREG,
+ C_REGREG2,
+ C_SHIFT,
+ C_FREG,
+ C_PSR,
+ C_FCR,
+
+ C_RCON, /* 0xff rotated */
+ C_NCON, /* ~RCON */
+ C_SCON, /* 0xffff */
+ C_LCON,
+ C_LCONADDR,
+ C_ZFCON,
+ C_SFCON,
+ C_LFCON,
+
+ C_RACON,
+ C_LACON,
+
+ C_SBRA,
+ C_LBRA,
+
+ C_HAUTO, /* halfword insn offset (-0xff to 0xff) */
+ C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */
+ C_HFAUTO, /* both H and F */
+ C_SAUTO, /* -0xfff to 0xfff */
+ C_LAUTO,
+
+ C_HOREG,
+ C_FOREG,
+ C_HFOREG,
+ C_SOREG,
+ C_ROREG,
+ C_SROREG, /* both nil and R */
+ C_LOREG,
+
+ C_PC,
+ C_SP,
+ C_HREG,
+
+ C_ADDR, /* reference to relocatable address */
+
+ C_GOK,
+
+ C_NCLASS, /* must be the last */
+};
+
enum
{
AXXX,
LEAF = 1<<2,
MINLC = 4,
-
- C_NONE = 0,
- C_REG,
- C_REGREG,
- C_REGREG2,
- C_SHIFT,
- C_FREG,
- C_PSR,
- C_FCR,
-
- C_RCON, /* 0xff rotated */
- C_NCON, /* ~RCON */
- C_SCON, /* 0xffff */
- C_LCON,
- C_LCONADDR,
- C_ZFCON,
- C_SFCON,
- C_LFCON,
-
- C_RACON,
- C_LACON,
-
- C_SBRA,
- C_LBRA,
-
- C_HAUTO, /* halfword insn offset (-0xff to 0xff) */
- C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */
- C_HFAUTO, /* both H and F */
- C_SAUTO, /* -0xfff to 0xfff */
- C_LAUTO,
-
- C_HOREG,
- C_FOREG,
- C_HFOREG,
- C_SOREG,
- C_ROREG,
- C_SROREG, /* both nil and R */
- C_LOREG,
-
- C_PC,
- C_SP,
- C_HREG,
-
- C_ADDR, /* reference to relocatable address */
-
- C_GOK,
};
EXTERN int32 autosize;
// mkanames reads [568].out.h and writes anames[568].c
// The format is much the same as the Go opcodes above.
+// it also writes out cnames array for C_* constants.
void
mkanames(char *dir, char *file)
{
int i, ch;
- Buf in, b, out;
+ Buf in, b, out, out2;
Vec lines;
char *p;
binit(&b);
binit(&in);
binit(&out);
+ binit(&out2);
vinit(&lines);
ch = file[xstrlen(file)-3];
}
}
bwritestr(&out, "};\n");
+
+ bprintf(&out2, "char* cnames%c[] = {\n", ch);
+ for(i=0; i<lines.len; i++) {
+ if(hasprefix(lines.p[i], "\tC_")) {
+ p = xstrstr(lines.p[i], ",");
+ if(p)
+ *p = '\0';
+ p = xstrstr(lines.p[i], "\n");
+ if(p)
+ *p = '\0';
+ p = lines.p[i] + 3;
+ bwritestr(&out2, bprintf(&b, "\t\"%s\",\n", p));
+ }
+ }
+ bwritestr(&out2, "};\n");
+ bwriteb(&out, &out2);
+
writefile(&out, file, 0);
bfree(&b);
bfree(&in);
bfree(&out);
+ bfree(&out2);
vfree(&lines);
}
LTO = 1<<1,
LPOOL = 1<<2,
LPCREL = 1<<3,
-
- C_NONE = 0,
- C_REG,
- C_REGREG,
- C_REGREG2,
- C_SHIFT,
- C_FREG,
- C_PSR,
- C_FCR,
-
- C_RCON, /* 0xff rotated */
- C_NCON, /* ~RCON */
- C_SCON, /* 0xffff */
- C_LCON,
- C_LCONADDR,
- C_ZFCON,
- C_SFCON,
- C_LFCON,
-
- C_RACON,
- C_LACON,
-
- C_SBRA,
- C_LBRA,
-
- C_HAUTO, /* halfword insn offset (-0xff to 0xff) */
- C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */
- C_HFAUTO, /* both H and F */
- C_SAUTO, /* -0xfff to 0xfff */
- C_LAUTO,
-
- C_HOREG,
- C_FOREG,
- C_HFOREG,
- C_SOREG,
- C_ROREG,
- C_SROREG, /* both nil and R */
- C_LOREG,
-
- C_PC,
- C_SP,
- C_HREG,
-
- C_ADDR, /* reference to relocatable address */
-
- C_GOK,
};
static Optab optab[] =
o = oprange[r].stop; /* just generate an error */
}
if(0 /*debug['O']*/) {
- print("oplook %A %d %d %d\n",
+ print("oplook %A %^ %^ %^\n",
(int)p->as, a1, a2, a3);
print(" %d %d\n", p->from.type, p->to.type);
}
p->optab = (o-optab)+1;
return o;
}
- ctxt->diag("illegal combination %P; %d %d %d, %d %d",
+ ctxt->diag("illegal combination %P; %^ %^ %^, %d %d",
p, a1, a2, a3, p->from.type, p->to.type);
ctxt->diag("from %d %d to %d %d\n", p->from.type, p->from.name, p->to.type, p->to.name);
prasm(p);
static int Rconv(Fmt *fp);
static int RAconv(Fmt *fp);
static int DSconv(Fmt *fp);
+static int DRconv(Fmt*);
#pragma varargck type "$" char*
#pragma varargck type "M" Addr*
fmtinstall('P', Pconv);
fmtinstall('R', Rconv);
+ // for liblink internal use
+ fmtinstall('^', DRconv);
+
// for internal use
fmtinstall('$', DSconv);
fmtinstall('M', Mconv);
return fmtstrcpy(fp, str);
}
+static int
+DRconv(Fmt *fp)
+{
+ char *s;
+ int a;
+
+ a = va_arg(fp->args, int);
+ s = "C_??";
+ if(a >= C_NONE && a <= C_NCLASS)
+ s = cnames5[a];
+ return fmtstrcpy(fp, s);
+}
+
static int
Mconv(Fmt *fp)
{