aboutsummaryrefslogtreecommitdiffhomepage
path: root/c.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-09-14 17:59:39 +0200
committerlemon <lsof@mailbox.org>2025-09-14 18:24:05 +0200
commit7a318363ec4fdcd80d9d0154cef393c9bf205d5e (patch)
treec254e3a3b985bc22e84480346c856052ef9963ca /c.c
parent5753e393954aca532abd6a5c10d6e8ab9a96c96c (diff)
preliminary pie and pic
Diffstat (limited to 'c.c')
-rw-r--r--c.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/c.c b/c.c
index 6833722..2d484c4 100644
--- a/c.c
+++ b/c.c
@@ -2447,10 +2447,11 @@ genptroff(struct function *fn, enum op op, uint siz, union ref ptr,
assert(siz);
idx = cvt(fn, targ_sizetype, tt, idx);
- if (siz == 1) off = idx;
- else if (idx.t == RICON)
- off = mkintcon(cls, idx.i * siz);
- else if (ispo2(siz))
+ if (siz == 1) off = idx;
+ else if (idx.t == RICON) {
+ if (op == Osub) op = Oadd, idx.i = -idx.i;
+ off = mkintcon(cls, idx.i * (int)siz);
+ } else if (ispo2(siz))
off = addinstr(fn,
mkinstr(Oshl, cls, .l = idx, .r = mkintcon(cls, ilog2(siz))));
else