Skip to content

Commit 4bbf92f

Browse files
author
whitequark
committed
Use the correct struct/union ABI (always *byval) on OR1K.
1 parent e487020 commit 4bbf92f

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

src/librustc_trans/cabi_or1k.rs

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use libc::c_uint;
1211
use llvm;
13-
use llvm::{Integer, Pointer, Float, Double, Struct, Array};
12+
use llvm::{Integer, Pointer, Float, Double, Struct, Array, Attribute};
1413
use abi::{FnType, ArgType};
1514
use context::CrateContext;
1615
use type_::Type;
@@ -91,19 +90,18 @@ fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
9190
}
9291

9392
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut usize) {
94-
let orig_offset = *offset;
9593
let size = ty_size(arg.ty) * 8;
9694
let mut align = ty_align(arg.ty);
9795

9896
align = cmp::min(cmp::max(align, 4), 8);
9997
*offset = align_up_to(*offset, align);
10098
*offset += align_up_to(size, align * 8) / 8;
10199

102-
if !is_reg_ty(arg.ty) {
103-
arg.cast = Some(struct_ty(ccx, arg.ty));
104-
arg.pad = padding_ty(ccx, align, orig_offset);
105-
} else {
100+
if is_reg_ty(arg.ty) {
106101
arg.extend_integer_width_to(32);
102+
} else {
103+
arg.make_indirect(ccx);
104+
arg.attrs.set(Attribute::ByVal);
107105
}
108106
}
109107

@@ -117,39 +115,6 @@ fn is_reg_ty(ty: Type) -> bool {
117115
};
118116
}
119117

120-
fn padding_ty(ccx: &CrateContext, align: usize, offset: usize) -> Option<Type> {
121-
if ((align - 1 ) & offset) > 0 {
122-
Some(Type::i32(ccx))
123-
} else {
124-
None
125-
}
126-
}
127-
128-
fn coerce_to_int(ccx: &CrateContext, size: usize) -> Vec<Type> {
129-
let int_ty = Type::i32(ccx);
130-
let mut args = Vec::new();
131-
132-
let mut n = size / 32;
133-
while n > 0 {
134-
args.push(int_ty);
135-
n -= 1;
136-
}
137-
138-
let r = size % 32;
139-
if r > 0 {
140-
unsafe {
141-
args.push(Type::from_ref(llvm::LLVMIntTypeInContext(ccx.llcx(), r as c_uint)));
142-
}
143-
}
144-
145-
args
146-
}
147-
148-
fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
149-
let size = ty_size(ty) * 8;
150-
Type::struct_(ccx, &coerce_to_int(ccx, size), false)
151-
}
152-
153118
pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
154119
if !fty.ret.is_ignore() {
155120
classify_ret_ty(ccx, &mut fty.ret);

0 commit comments

Comments
 (0)