1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Reference: PTX Writer's Guide to Interoperability
12 // http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability
14 #![allow(non_upper_case_globals)]
18 use abi::{self, ArgType, FnType};
19 use context::CrateContext;
22 fn ty_size(ty: Type) -> usize {
26 fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
27 if ret.ty.kind() == Struct && ty_size(ret.ty) > 32 {
28 ret.make_indirect(ccx);
30 ret.extend_integer_width_to(32);
34 fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType) {
35 if arg.ty.kind() == Struct && ty_size(arg.ty) > 32 {
36 arg.make_indirect(ccx);
38 arg.extend_integer_width_to(32);
42 pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
43 if !fty.ret.is_ignore() {
44 classify_ret_ty(ccx, &mut fty.ret);
47 for arg in &mut fty.args {
51 classify_arg_ty(ccx, arg);