- /* A struct is returned using general register 2. */
- if (struct_return)
- {
- regcache_cooked_write_unsigned (regcache, S390_R0_REGNUM + gr,
- struct_addr);
- gr++;
- }
-
- for (i = 0; i < nargs; i++)
- {
- struct value *arg = args[i];
- struct type *type = check_typedef (value_type (arg));
- unsigned length = TYPE_LENGTH (type);
-
- if (s390_function_arg_pass_by_reference (type))
- {
- /* Actually copy the argument contents to the stack slot
- that was reserved above. */
- write_memory (copy_addr[i], value_contents (arg), length);
-
- if (gr <= 6)
- {
- regcache_cooked_write_unsigned (regcache, S390_R0_REGNUM + gr,
- copy_addr[i]);
- gr++;
- }
- else
- {
- write_memory_unsigned_integer (starg, word_size, byte_order,
- copy_addr[i]);
- starg += word_size;
- }
- }
- else if (s390_function_arg_float (type))
- {
- /* The GNU/Linux for S/390 ABI uses FPRs 0 and 2 to pass arguments,
- the GNU/Linux for zSeries ABI uses 0, 2, 4, and 6. */
- if (fr <= (tdep->abi == ABI_LINUX_S390 ? 2 : 6))
- {
- /* When we store a single-precision value in an FP register,
- it occupies the leftmost bits. */
- regcache_cooked_write_part (regcache, S390_F0_REGNUM + fr,
- 0, length, value_contents (arg));
- fr += 2;
- }
- else
- {
- /* When we store a single-precision value in a stack slot,
- it occupies the rightmost bits. */
- starg = align_up (starg + length, word_size);
- write_memory (starg - length, value_contents (arg), length);
- }
- }
- else if (s390_function_arg_integer (type) && length <= word_size)
- {
- if (gr <= 6)
- {
- /* Integer arguments are always extended to word size. */
- regcache_cooked_write_signed (regcache, S390_R0_REGNUM + gr,
- extend_simple_arg (gdbarch,
- arg));
- gr++;
- }
- else
- {
- /* Integer arguments are always extended to word size. */
- write_memory_signed_integer (starg, word_size, byte_order,
- extend_simple_arg (gdbarch, arg));
- starg += word_size;
- }
- }
- else if (s390_function_arg_integer (type) && length == 2*word_size)
- {
- if (gr <= 5)
- {
- regcache_cooked_write (regcache, S390_R0_REGNUM + gr,
- value_contents (arg));
- regcache_cooked_write (regcache, S390_R0_REGNUM + gr + 1,
- value_contents (arg) + word_size);
- gr += 2;
- }
- else
- {
- /* If we skipped r6 because we couldn't fit a DOUBLE_ARG
- in it, then don't go back and use it again later. */
- gr = 7;
-
- write_memory (starg, value_contents (arg), length);
- starg += length;
- }
- }
- else
- internal_error (__FILE__, __LINE__, _("unknown argument type"));
- }
- }