add support for thread-local storage
The apple targets are not done yet.
This commit is contained in:
parent
5cea0c20ee
commit
00a30954ac
12 changed files with 145 additions and 70 deletions
11
amd64/emit.c
11
amd64/emit.c
|
@ -166,8 +166,11 @@ emitcon(Con *con, FILE *f)
|
|||
switch (con->type) {
|
||||
case CAddr:
|
||||
l = str(con->label);
|
||||
p = con->local ? T.asloc : l[0] == '"' ? "" : T.assym;
|
||||
fprintf(f, "%s%s", p, l);
|
||||
p = l[0] == '"' ? "" : T.assym;
|
||||
if (con->rel == RelThr)
|
||||
fprintf(f, "%%fs:%s%s@tpoff", p, l);
|
||||
else
|
||||
fprintf(f, "%s%s", p, l);
|
||||
if (con->bits.i)
|
||||
fprintf(f, "%+"PRId64, con->bits.i);
|
||||
break;
|
||||
|
@ -337,7 +340,7 @@ Next:
|
|||
case RCon:
|
||||
off = fn->con[ref.val];
|
||||
emitcon(&off, f);
|
||||
if (off.type == CAddr)
|
||||
if (off.type == CAddr && off.rel != RelThr)
|
||||
fprintf(f, "(%%rip)");
|
||||
break;
|
||||
case RTmp:
|
||||
|
@ -549,7 +552,7 @@ emitfn(Fn *fn, FILE *f)
|
|||
int *r, c, o, n, lbl;
|
||||
uint64_t fs;
|
||||
|
||||
emitlnk(fn->name, &fn->lnk, ".text", f);
|
||||
emitfnlnk(fn->name, &fn->lnk, f);
|
||||
fputs("\tpushq %rbp\n\tmovq %rsp, %rbp\n", f);
|
||||
fs = framesz(fn);
|
||||
if (fs)
|
||||
|
|
|
@ -78,9 +78,8 @@ fixarg(Ref *r, int k, Ins *i, Fn *fn)
|
|||
vgrow(&fn->mem, ++fn->nmem);
|
||||
memset(&a, 0, sizeof a);
|
||||
a.offset.type = CAddr;
|
||||
a.offset.local = 1;
|
||||
n = stashbits(&fn->con[r0.val].bits, KWIDE(k) ? 8 : 4);
|
||||
sprintf(buf, "fp%d", n);
|
||||
sprintf(buf, "\"%sfp%d\"", T.asloc, n);
|
||||
a.offset.label = intern(buf);
|
||||
fn->mem[fn->nmem-1] = a;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue