History

Fix structure passing in ARM calling convention

Fix the address on stack where a structure is copied when it is a parameter of a function call. This address must be computed from the stack pointer and a possible padding offset.

Thomas Preud'homme committed 12 years ago

Commit 48fc7461 parent dcec8671 file · +6 −3Browse files

Unified · Split

arm-gen.c+6−3
@@ -1020,19 +1020,22 @@ static int copy_params(int nb_args, struct plan *plan, int todo) · 1019 unmodified lines
1020 case CORE_STRUCT_CLASS:1020 case CORE_STRUCT_CLASS:
1021 case VFP_STRUCT_CLASS:1021 case VFP_STRUCT_CLASS:
1022 if ((pplan->sval->type.t & VT_BTYPE) == VT_STRUCT) {1022 if ((pplan->sval->type.t & VT_BTYPE) == VT_STRUCT) {
1023 int padding = 0;
1023 size = type_size(&pplan->sval->type, &align);1024 size = type_size(&pplan->sval->type, &align);
1024 /* align to stack align size */1025 /* align to stack align size */
1025 size = (size + 3) & ~3;1026 size = (size + 3) & ~3;
1026 if (i == STACK_CLASS && pplan->prev)1027 if (i == STACK_CLASS && pplan->prev)
1027 size += pplan->start - pplan->prev->end; /* Add padding if any */1028 padding = pplan->start - pplan->prev->end;
1029 size += padding; /* Add padding if any */
1028 /* allocate the necessary size on stack */1030 /* allocate the necessary size on stack */
1029 gadd_sp(-size);1031 gadd_sp(-size);
1030 /* generate structure store */1032 /* generate structure store */
1031 r = get_reg(RC_INT);1033 r = get_reg(RC_INT);
1032 o(0xE1A0000D|(intr(r)<<12)); /* mov r, sp */1034 o(0xE28D0000|(intr(r)<<12)|padding); /* add r, sp, padding */
1033 vset(&vtop->type, r | VT_LVAL, 0);1035 vset(&vtop->type, r | VT_LVAL, 0);
1034 vswap();1036 vswap();
1035 vstore(); /* memcpy to current sp */1037 vstore(); /* memcpy to current sp + potential padding */
1038
1036 /* Homogeneous float aggregate are loaded to VFP registers1039 /* Homogeneous float aggregate are loaded to VFP registers
1037 immediately since there is no way of loading data in multiple1040 immediately since there is no way of loading data in multiple
1038 non consecutive VFP registers as what is done for other1041 non consecutive VFP registers as what is done for other

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