[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:
@@ -1051,13 +1051,15 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
|
||||
pub fn lower<B: LowerBackend<MInst = I>>(mut self, backend: &B) -> CodegenResult<VCode<I>> {
|
||||
trace!("about to lower function: {:?}", self.f);
|
||||
|
||||
// Initialize the ABI object, giving it a temp if requested.
|
||||
let maybe_tmp = if let Some(temp_ty) = self.vcode.abi().temp_needed() {
|
||||
Some(self.alloc_tmp(temp_ty).only_reg().unwrap())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.vcode.abi().init(maybe_tmp);
|
||||
// Initialize the ABI object, giving it temps if requested.
|
||||
let temps = self
|
||||
.vcode
|
||||
.abi()
|
||||
.temps_needed()
|
||||
.into_iter()
|
||||
.map(|temp_ty| self.alloc_tmp(temp_ty).only_reg().unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
self.vcode.abi().init(temps);
|
||||
|
||||
// Get the pinned reg here (we only parameterize this function on `B`,
|
||||
// not the whole `Lower` impl).
|
||||
|
||||
Reference in New Issue
Block a user