]> git.proxmox.com Git - rustc.git/blame - src/librustc_target/abi/call/x86_win64.rs
New upstream version 1.34.2+dfsg1
[rustc.git] / src / librustc_target / abi / call / x86_win64.rs
CommitLineData
9fa01778
XL
1use crate::abi::call::{ArgType, FnType, Reg};
2use crate::abi::Abi;
54a0048b
SL
3
4// Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
5
9fa01778
XL
6pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
7 let fixup = |a: &mut ArgType<'_, Ty>| {
ff7c6d11 8 match a.layout.abi {
83c7162d
XL
9 Abi::Uninhabited => {}
10 Abi::ScalarPair(..) |
11 Abi::Aggregate { .. } => {
ff7c6d11
XL
12 match a.layout.size.bits() {
13 8 => a.cast_to(Reg::i8()),
14 16 => a.cast_to(Reg::i16()),
15 32 => a.cast_to(Reg::i32()),
16 64 => a.cast_to(Reg::i64()),
17 _ => a.make_indirect()
18 }
19 }
83c7162d 20 Abi::Vector { .. } => {
cc61c64b
XL
21 // FIXME(eddyb) there should be a size cap here
22 // (probably what clang calls "illegal vectors").
ff7c6d11 23 }
83c7162d 24 Abi::Scalar(_) => {
ff7c6d11
XL
25 if a.layout.size.bytes() > 8 {
26 a.make_indirect();
27 } else {
28 a.extend_integer_width_to(32);
29 }
cc61c64b 30 }
54a0048b
SL
31 }
32 };
33
34 if !fty.ret.is_ignore() {
35 fixup(&mut fty.ret);
36 }
37 for arg in &mut fty.args {
38 if arg.is_ignore() { continue; }
39 fixup(arg);
40 }
41}