diff options
Diffstat (limited to 'src/librustc_trans/trans/cabi_powerpc64.rs')
-rw-r--r-- | src/librustc_trans/trans/cabi_powerpc64.rs | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/src/librustc_trans/trans/cabi_powerpc64.rs b/src/librustc_trans/trans/cabi_powerpc64.rs index f76bb4f9eeb..340de235732 100644 --- a/src/librustc_trans/trans/cabi_powerpc64.rs +++ b/src/librustc_trans/trans/cabi_powerpc64.rs @@ -15,8 +15,8 @@ // Alignment of 128 bit types is not currently handled, this will // need to be fixed when PowerPC vector support is added. -use llvm::{Integer, Pointer, Float, Double, Struct, Array, Attribute}; -use trans::cabi::{FnType, ArgType}; +use llvm::{Integer, Pointer, Float, Double, Struct, Array}; +use trans::abi::{FnType, ArgType}; use trans::context::CrateContext; use trans::type_::Type; @@ -151,22 +151,21 @@ fn is_homogenous_aggregate_ty(ty: Type) -> Option<(Type, u64)> { }) } -fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { - if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; - return ArgType::direct(ty, None, None, attr); +fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) { + if is_reg_ty(ret.ty) { + return; } // The PowerPC64 big endian ABI doesn't return aggregates in registers if ccx.sess().target.target.target_endian == "big" { - return ArgType::indirect(ty, Some(Attribute::StructRet)) + ret.make_indirect(ccx); } - if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) { - let llty = Type::array(&base_ty, members); - return ArgType::direct(ty, Some(llty), None, None); + if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ret.ty) { + ret.cast = Some(Type::array(&base_ty, members)); + return; } - let size = ty_size(ty); + let size = ty_size(ret.ty); if size <= 16 { let llty = if size <= 1 { Type::i8(ccx) @@ -179,28 +178,24 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { } else { Type::array(&Type::i64(ccx), ((size + 7 ) / 8 ) as u64) }; - return ArgType::direct(ty, Some(llty), None, None); + ret.cast = Some(llty); + return; } - ArgType::indirect(ty, Some(Attribute::StructRet)) + ret.make_indirect(ccx); } -fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType { - if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; - return ArgType::direct(ty, None, None, attr); +fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType) { + if is_reg_ty(arg.ty) { + return; } - if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) { - let llty = Type::array(&base_ty, members); - return ArgType::direct(ty, Some(llty), None, None); + + if let Some((base_ty, members)) = is_homogenous_aggregate_ty(arg.ty) { + arg.cast = Some(Type::array(&base_ty, members)); + return; } - ArgType::direct( - ty, - Some(struct_ty(ccx, ty)), - None, - None - ) + arg.cast = Some(struct_ty(ccx, arg.ty)); } fn is_reg_ty(ty: Type) -> bool { @@ -236,24 +231,13 @@ fn struct_ty(ccx: &CrateContext, ty: Type) -> Type { Type::struct_(ccx, &coerce_to_long(ccx, size), false) } -pub fn compute_abi_info(ccx: &CrateContext, - atys: &[Type], - rty: Type, - ret_def: bool) -> FnType { - let ret_ty = if ret_def { - classify_ret_ty(ccx, rty) - } else { - ArgType::direct(Type::void(ccx), None, None, None) - }; - - let mut arg_tys = Vec::new(); - for &aty in atys { - let ty = classify_arg_ty(ccx, aty); - arg_tys.push(ty); - }; +pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) { + if !fty.ret.is_ignore() { + classify_ret_ty(ccx, &mut fty.ret); + } - return FnType { - arg_tys: arg_tys, - ret_ty: ret_ty, - }; + for arg in &mut fty.args { + if arg.is_ignore() { continue; } + classify_arg_ty(ccx, arg); + } } |