about summary refs log tree commit diff
path: root/compiler/rustc_target/src/callconv/mips.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-14 12:20:35 +0000
committerbors <bors@rust-lang.org>2024-10-14 12:20:35 +0000
commit17a19e684cdf3ca088af8b4da6a6209d128913f4 (patch)
treec5079eb765379d0c131f40fd76365fd5d8a692c8 /compiler/rustc_target/src/callconv/mips.rs
parentf6648f252a05a0a46c865d7ec836b46290613bf9 (diff)
parentd34b9324c0557abbcd52257fdc544e8a8ff77d4d (diff)
downloadrust-17a19e684cdf3ca088af8b4da6a6209d128913f4.tar.gz
rust-17a19e684cdf3ca088af8b4da6a6209d128913f4.zip
Auto merge of #131672 - matthiaskrgr:rollup-gyzysj4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128967 (std::fs::get_path freebsd update.)
 - #130629 (core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments.)
 - #131274 (library: Const-stabilize `MaybeUninit::assume_init_mut`)
 - #131473 (compiler: `{TyAnd,}Layout` comes home)
 - #131533 (emscripten: Use the latest emsdk 3.1.68)
 - #131593 (miri: avoid cloning AllocExtra)
 - #131616 (merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate)
 - #131660 (Also use outermost const-anon for impl items in `non_local_defs` lint)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_target/src/callconv/mips.rs')
-rw-r--r--compiler/rustc_target/src/callconv/mips.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/callconv/mips.rs b/compiler/rustc_target/src/callconv/mips.rs
new file mode 100644
index 00000000000..37980a91c76
--- /dev/null
+++ b/compiler/rustc_target/src/callconv/mips.rs
@@ -0,0 +1,53 @@
+use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
+use crate::abi::{HasDataLayout, Size};
+
+fn classify_ret<Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
+where
+    C: HasDataLayout,
+{
+    if !ret.layout.is_aggregate() {
+        ret.extend_integer_width_to(32);
+    } else {
+        ret.make_indirect();
+        *offset += cx.data_layout().pointer_size;
+    }
+}
+
+fn classify_arg<Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
+where
+    C: HasDataLayout,
+{
+    if !arg.layout.is_sized() {
+        // Not touching this...
+        return;
+    }
+    let dl = cx.data_layout();
+    let size = arg.layout.size;
+    let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align).abi;
+
+    if arg.layout.is_aggregate() {
+        let pad_i32 = !offset.is_aligned(align);
+        arg.cast_to_and_pad_i32(Uniform::new(Reg::i32(), size), pad_i32);
+    } else {
+        arg.extend_integer_width_to(32);
+    }
+
+    *offset = offset.align_to(align) + size.align_to(align);
+}
+
+pub(crate) fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
+where
+    C: HasDataLayout,
+{
+    let mut offset = Size::ZERO;
+    if !fn_abi.ret.is_ignore() {
+        classify_ret(cx, &mut fn_abi.ret, &mut offset);
+    }
+
+    for arg in fn_abi.args.iter_mut() {
+        if arg.is_ignore() {
+            continue;
+        }
+        classify_arg(cx, arg, &mut offset);
+    }
+}