Skip to content
Snippets Groups Projects
Commit cf9de710 authored by Keith Packard's avatar Keith Packard Committed by Jeff Law
Browse files

lm32: In va_arg, skip to stack args with too few remaining reg args

lm32 has 8 register parameter slots, so many vararg functions end up
with several anonymous parameters passed in registers. If we run out
of registers in the middle of a parameter, the entire parameter will
be placed on the stack, skipping any remaining available registers.

The receiving varargs function doesn't know this, and will save all of
the possible parameter register values just below the stack parameters.

When processing a va_arg call with a type size larger than a single
register, we must check to see if it spans the boundary between
register and stack parameters. If so, we need to skip to the stack
parameters.

This is done by making va_list a structure containing the arg pointer
and the address of the start of the stack parameters. Boundary checks
are inserted in va_arg calls to detect this case and the address of
the parameter is set to the stack parameter start when the parameter
crosses over.

gcc/
	* config/lm32/lm32.cc: Add several #includes.
	(va_list_type): New.
	(lm32_build_va_list): New function.
	(lm32_builtin_va_start): Likewise.
	(lm32_sd_gimplify_va_arg_expr): Likewise.
	(lm32_gimplify_va_arg_expr): Likewise.
parent 423e9a8a
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment