Add extension marker to i32 arguments of builtin functions

Some platform ABIs require i32 values to be zero- or sign-extended
to the full register width.  The extension is implemented by the
cranelift codegen backend, but this happens only if the appropriate
"uext" or "sext" attribute is present in the cranelift IR.

For calls to builtin functions, that IR is synthesized by the code
in func_environ.rs -- to ensure correct codegen for the target ABI,
this code needs to add those attributes as necessary.
This commit is contained in:
Ulrich Weigand
2020-11-03 16:22:20 +01:00
parent d1be8dcfc0
commit 56caf1b29a

View File

@@ -69,7 +69,16 @@ macro_rules! declare_function_signatures {
}
fn i32(&self) -> AbiParam {
AbiParam::new(I32)
// Some platform ABIs require i32 values to be zero- or sign-
// extended to the full register width. We need to indicate
// this here by using the appropriate .uext or .sext attribute.
// The attribute can be added unconditionally; platforms whose
// ABI does not require such extensions will simply ignore it.
// Note that currently all i32 arguments or return values used
// by builtin functions are unsigned, so we always use .uext.
// If that ever changes, we will have to add a second type
// marker here.
AbiParam::new(I32).uext()
}
$(