aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2024-04-11 10:28:41 +0200
committerQuentin Carbonneaux <[email protected]>2024-04-11 14:14:53 +0200
commit4a809d69b5647aabc8f6a9e22e0bc889f9c779ed (patch)
tree31168efce4b56685c1564ea49b93a56bc27c9569 /util.c
parent8e8f7064366996a7fcc8d84267958cfaf5ee8194 (diff)
fold scaled offsets in addresses
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/util.c b/util.c
index b3401f2..2e4b4cc 100644
--- a/util.c
+++ b/util.c
@@ -398,18 +398,21 @@ getcon(int64_t val, Fn *fn)
}
int
-addcon(Con *c0, Con *c1)
+addcon(Con *c0, Con *c1, int m)
{
- if (c0->type == CUndef)
+ if (m != 1 && c1->type == CAddr)
+ return 0;
+ if (c0->type == CUndef) {
*c0 = *c1;
- else {
+ c0->bits.i *= m;
+ } else {
if (c1->type == CAddr) {
if (c0->type == CAddr)
return 0;
c0->type = CAddr;
c0->sym = c1->sym;
}
- c0->bits.i += c1->bits.i;
+ c0->bits.i += c1->bits.i * m;
}
return 1;
}