diff options
| author | Alessandro Decina <alessandro.d@gmail.com> | 2020-11-30 19:41:57 +0000 |
|---|---|---|
| committer | Alessandro Decina <alessandro.d@gmail.com> | 2021-05-23 18:03:27 +1000 |
| commit | 12e70929d66577f74cb6214bba5bf104e1f14aa2 (patch) | |
| tree | 140448195cdbf393d03330a6ee276a42b2ca8156 /compiler/rustc_target/src/abi | |
| parent | 92418ce65aa9d45fd1af355136d65493254a344a (diff) | |
| download | rust-12e70929d66577f74cb6214bba5bf104e1f14aa2.tar.gz rust-12e70929d66577f74cb6214bba5bf104e1f14aa2.zip | |
Add BPF target
This change adds the bpfel-unknown-none and bpfeb-unknown-none targets which can be used to generate little endian and big endian BPF
Diffstat (limited to 'compiler/rustc_target/src/abi')
| -rw-r--r-- | compiler/rustc_target/src/abi/call/bpf.rs | 31 | ||||
| -rw-r--r-- | compiler/rustc_target/src/abi/call/mod.rs | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/abi/call/bpf.rs b/compiler/rustc_target/src/abi/call/bpf.rs new file mode 100644 index 00000000000..79af0150e21 --- /dev/null +++ b/compiler/rustc_target/src/abi/call/bpf.rs @@ -0,0 +1,31 @@ +// see BPFCallingConv.td +use crate::abi::call::{ArgAbi, FnAbi}; + +fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { + if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 { + ret.make_indirect(); + } else { + ret.extend_integer_width_to(64); + } +} + +fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) { + if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 { + arg.make_indirect(); + } else { + arg.extend_integer_width_to(64); + } +} + +pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) { + if !fn_abi.ret.is_ignore() { + classify_ret(&mut fn_abi.ret); + } + + for arg in &mut fn_abi.args { + if arg.is_ignore() { + continue; + } + classify_arg(arg); + } +} diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 0cf2441d84e..864b4fe5f08 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -6,6 +6,7 @@ mod aarch64; mod amdgpu; mod arm; mod avr; +mod bpf; mod hexagon; mod mips; mod mips64; @@ -654,6 +655,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { } } "asmjs" => wasm::compute_c_abi_info(cx, self), + "bpfel" | "bpfeb" => bpf::compute_abi_info(self), a => return Err(format!("unrecognized arch \"{}\" in target specification", a)), } |
