aboutsummaryrefslogtreecommitdiff
path: root/arm64-gen.c
diff options
context:
space:
mode:
authorEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-10-31 11:04:52 +0000
committerEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-10-31 11:04:52 +0000
commitf4082851eafd7bdec93e4eb7433cfc1f771ffefb (patch)
tree412784c93cd7b99944ab1f6809cde899d539133f /arm64-gen.c
parent35e715a1e3eb9949419c92196a07bde3e281a613 (diff)
downloadtinycc-f4082851eafd7bdec93e4eb7433cfc1f771ffefb.tar.gz
tinycc-f4082851eafd7bdec93e4eb7433cfc1f771ffefb.tar.bz2
Enable variable-length arrays on arm64.
arm64-gen.c: Implement gen_vla_sp_save, gen_vla_sp_restore, gen_vla_alloc. tests/Makefile: Run vla_test on arm64.
Diffstat (limited to 'arm64-gen.c')
-rw-r--r--arm64-gen.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/arm64-gen.c b/arm64-gen.c
index 0c435d9..fa0e748 100644
--- a/arm64-gen.c
+++ b/arm64-gen.c
@@ -1820,15 +1820,23 @@ ST_FUNC void gen_clear_cache(void)
}
ST_FUNC void gen_vla_sp_save(int addr) {
- tcc_error("variable length arrays unsupported for this target");
+ uint32_t r = intr(get_reg(RC_INT));
+ o(0x910003e0 | r); // mov x(r),sp
+ arm64_strx(3, r, 29, addr);
}
ST_FUNC void gen_vla_sp_restore(int addr) {
- tcc_error("variable length arrays unsupported for this target");
+ uint32_t r = intr(get_reg(RC_INT));
+ arm64_ldrx(0, 3, r, 29, addr);
+ o(0x9100001f | r << 5); // mov sp,x(r)
}
ST_FUNC void gen_vla_alloc(CType *type, int align) {
- tcc_error("variable length arrays unsupported for this target");
+ uint32_t r = intr(gv(RC_INT));
+ o(0x91003c00 | r | r << 5); // add x(r),x(r),#15
+ o(0x927cec00 | r | r << 5); // bic x(r),x(r),#15
+ o(0xcb2063ff | r << 16); // sub sp,sp,x(r)
+ vpop();
}
/* end of A64 code generator */