[s390x, abi_impl] Add i128 support (#4598)

This adds full i128 support to the s390x target, including new filetests
and enabling the existing i128 runtest on s390x.

The ABI requires that i128 is passed and returned via implicit pointer,
but the front end still generates direct i128 types in call.  This means
we have to implement ABI support to implicitly convert i128 types to
pointers when passing arguments.

To do so, we add a new variant ABIArg::ImplicitArg.  This acts like
StructArg, except that the value type is the actual target type,
not a pointer type.  The required conversions have to be inserted
in the prologue and at function call sites.

Note that when dereferencing the implicit pointer in the prologue,
we may require a temp register: the pointer may be passed on the
stack so it needs to be loaded first, but the value register may
be in the wrong class for pointer values.  In this case, we use
the "stack limit" register, which should be available at this
point in the prologue.

For return values, we use a mechanism similar to the one used for
supporting multiple return values in the Wasmtime ABI.  The only
difference is that the hidden pointer to the return buffer must
be the *first*, not last, argument in this case.

(This implements the second half of issue #4565.)
This commit is contained in:
Ulrich Weigand
2022-08-04 22:41:26 +02:00
committed by GitHub
parent dc8362ceec
commit b17b1eb25d
46 changed files with 2424 additions and 166 deletions

View File

@@ -906,6 +906,11 @@
(decl abi_arg_struct_pointer (ABIArgSlot i64 u64) ABIArg)
(extern extractor abi_arg_struct_pointer abi_arg_struct_pointer)
;; Extractor to detect the special case where a non-struct argument
;; is implicitly passed by reference using a hidden pointer.
(decl abi_arg_implicit_pointer (ABIArgSlot i64 Type) ABIArg)
(extern extractor abi_arg_implicit_pointer abi_arg_implicit_pointer)
;; Convert a real register number into a virtual register.
(decl real_reg_to_reg (RealReg) Reg)
(extern constructor real_reg_to_reg real_reg_to_reg)