History

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.

Edmund Grimley Evans committed 11 years ago

Commit f4082851 parent 35e715a2 files · +12 −5Browse files

Unified · Split

2 files
  1. arm64-gen.c +11 −3
  2. tests/Makefile +1 −2
arm64-gen.c+11−3
@@ -1820,15 +1820,23 @@ ST_FUNC void gen_clear_cache(void) · 1819 unmodified lines
18201820 }
18211821
18221822 ST_FUNC void gen_vla_sp_save(int addr) {
1823− tcc_error("variable length arrays unsupported for this target");
1823+ uint32_t r = intr(get_reg(RC_INT));
1824+ o(0x910003e0 | r); // mov x(r),sp
1825+ arm64_strx(3, r, 29, addr);
18241826 }
18251827
18261828 ST_FUNC void gen_vla_sp_restore(int addr) {
1827− tcc_error("variable length arrays unsupported for this target");
1829+ uint32_t r = intr(get_reg(RC_INT));
1830+ arm64_ldrx(0, 3, r, 29, addr);
1831+ o(0x9100001f | r << 5); // mov sp,x(r)
18281832 }
18291833
18301834 ST_FUNC void gen_vla_alloc(CType *type, int align) {
1831− tcc_error("variable length arrays unsupported for this target");
1835+ uint32_t r = intr(gv(RC_INT));
1836+ o(0x91003c00 | r | r << 5); // add x(r),x(r),#15
1837+ o(0x927cec00 | r | r << 5); // bic x(r),x(r),#15
1838+ o(0xcb2063ff | r << 16); // sub sp,sp,x(r)
1839+ vpop();
18321840 }
18331841
18341842 /* end of A64 code generator */
tests/Makefile+1−2
@@ -41,8 +41,7 @@ endif · 40 unmodified lines
4141 ifeq ($(TARGETOS),Darwin)
4242 TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS))
4343 endif
44−ifeq ($(ARCH),i386)
45−else ifneq ($(ARCH),x86-64)
44+ifeq (,$(filter arm64 i386 x86-64,$(ARCH)))
4645 TESTS := $(filter-out vla_test-run,$(TESTS))
4746 endif
4847 ifeq ($(CONFIG_arm_eabi),yes)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t