diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-03 23:32:57 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-03 23:32:57 +0300 |
| commit | 68059b52c389143e766c5499c76c6c90c6b82846 (patch) | |
| tree | 6e10707dbc417946dee5c4dbb333a4952914a9e8 /src/abi.c | |
| parent | f4be2429f38faba0c54862055f808cb242a7eb49 (diff) | |
| download | qbt-68059b52c389143e766c5499c76c6c90c6b82846.tar.gz qbt-68059b52c389143e766c5499c76c6c90c6b82846.zip | |
add callsite register saving
Diffstat (limited to 'src/abi.c')
| -rw-r--r-- | src/abi.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -30,7 +30,9 @@ static struct insn rewrite_retval(struct insn n) assert(n.in[1].class == IMM); int64_t nth_retval = n.in[1].v; assert(nth_retval >= 0 && nth_retval < 25); - return insn_create(MOVE, I27, n.out, nth_ar(nth_retval), noclass()); + n = insn_create(MOVE, I27, n.out, nth_ar(nth_retval), noclass()); + set_insn_flags(&n, CALL_TEARDOWN); + return n; } static struct insn rewrite_arg(struct insn n) @@ -40,12 +42,18 @@ static struct insn rewrite_arg(struct insn n) int64_t nth_arg = n.in[1].v; assert(nth_arg >= 0 && nth_arg < 25); - if (n.in[0].class == TMP || n.in[0].class == REG) - return insn_create(MOVE, I27, nth_ar(nth_arg), n.in[0], + if (n.in[0].class == TMP || n.in[0].class == REG) { + n = insn_create(MOVE, I27, nth_ar(nth_arg), n.in[0], noclass()); - else if (n.in[0].class == IMM || n.in[0].class == REF) - return insn_create(COPY, I27, nth_ar(nth_arg), n.in[0], + set_insn_flags(&n, CALL_SETUP); + return n; + } + else if (n.in[0].class == IMM || n.in[0].class == REF) { + n = insn_create(COPY, I27, nth_ar(nth_arg), n.in[0], noclass()); + set_insn_flags(&n, CALL_SETUP); + return n; + } assert("illegal arg type"); abort(); |
