Skip to content

Commit e74f6ff

Browse files
committed
Fix rebase
1 parent 78f3a7e commit e74f6ff

File tree

5 files changed

+96
-99
lines changed

5 files changed

+96
-99
lines changed

src/builder.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
455455
}
456456

457457
#[cfg(feature="master")]
458-
fn invoke(&mut self, typ: Type<'gcc>, fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, func: RValue<'gcc>, args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
458+
fn invoke(&mut self, typ: Type<'gcc>, _fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, func: RValue<'gcc>, args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
459459
let try_block = self.current_func().new_block("try");
460460

461461
let current_block = self.block.clone();
462462
self.block = try_block;
463-
let call = self.call(typ, func, args, None); // TODO(antoyo): use funclet here?
463+
let call = self.call(typ, None, func, args, None); // TODO(antoyo): use funclet here?
464464
self.block = current_block;
465465

466466
let return_value = self.current_func()
@@ -1210,23 +1210,20 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12101210
let zero = self.cx.context.new_rvalue_zero(self.int_type);
12111211
let ptr = self.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
12121212

1213-
let field1_type = self.u8_type.make_pointer();
1214-
let field1 = self.context.new_field(None, field1_type, "landing_pad_field_1");
1215-
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_2");
1216-
let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
1217-
let value = self.current_func().new_local(None, struct_type.as_type(), "landing_pad");
1218-
let ptr = self.cx.context.new_cast(None, ptr, field1_type);
1219-
self.block.add_assignment(None, value.access_field(None, field1), ptr);
1220-
self.block.add_assignment(None, value.access_field(None, field2), zero); // TODO(antoyo): set the proper value here (the type of exception?).
1213+
let value1_type = self.u8_type.make_pointer();
1214+
let ptr = self.cx.context.new_cast(None, ptr, value1_type);
1215+
let value1 = ptr;
1216+
let value2 = zero; // TODO(antoyo): set the proper value here (the type of exception?).
12211217

1222-
value.to_rvalue()
1218+
(value1, value2)
12231219
}
12241220

12251221
#[cfg(not(feature="master"))]
12261222
fn cleanup_landing_pad(&mut self, _pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
1227-
let field1 = self.context.new_field(None, self.u8_type.make_pointer(), "landing_pad_field_1");
1228-
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
1229-
(field1, field2)
1223+
let value1 = self.current_func().new_local(None, self.u8_type.make_pointer(), "landing_pad0")
1224+
.to_rvalue();
1225+
let value2 = self.current_func().new_local(None, self.i32_type, "landing_pad1").to_rvalue();
1226+
(value1, value2)
12301227
}
12311228

12321229
#[cfg(feature="master")]

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
391391
tcx,
392392
ty::ParamEnv::reveal_all(),
393393
def_id,
394-
tcx.intern_substs(&[]),
394+
ty::List::empty(),
395395
)
396396
.unwrap().unwrap();
397397

src/intrinsic/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,21 +1202,21 @@ fn codegen_gnu_try<'gcc>(bx: &mut Builder<'_, 'gcc, '_>, try_func: RValue<'gcc>,
12021202
let zero = bx.cx.context.new_rvalue_zero(bx.int_type);
12031203
let ptr = bx.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
12041204
let catch_ty = bx.type_func(&[bx.type_i8p(), bx.type_i8p()], bx.type_void());
1205-
bx.call(catch_ty, catch_func, &[data, ptr], None);
1205+
bx.call(catch_ty, None, catch_func, &[data, ptr], None);
12061206
bx.ret(bx.const_i32(1));
12071207

12081208
// NOTE: the blocks must be filled before adding the try/catch, otherwise gcc will not
12091209
// generate a try/catch.
12101210
// FIXME(antoyo): add a check in the libgccjit API to prevent this.
12111211
bx.switch_to_block(current_block);
1212-
bx.invoke(try_func_ty, try_func, &[data], then, catch, None);
1212+
bx.invoke(try_func_ty, None, try_func, &[data], then, catch, None);
12131213
});
12141214

12151215
let func = unsafe { std::mem::transmute(func) };
12161216

12171217
// Note that no invoke is used here because by definition this function
12181218
// can't panic (that's what it's catching).
1219-
let ret = bx.call(llty, func, &[try_func, data, catch_func], None);
1219+
let ret = bx.call(llty, None, func, &[try_func, data, catch_func], None);
12201220
let i32_align = bx.tcx().data_layout.i32_align.abi;
12211221
bx.store(ret, dest, i32_align);
12221222
}
@@ -1253,8 +1253,8 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(cx: &'a CodegenCx<'gcc, 'tcx>, codegen: &mut
12531253
)));
12541254
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
12551255
let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig(
1256-
[try_fn_ty, i8p, catch_fn_ty].iter(),
1257-
&tcx.types.i32,
1256+
[try_fn_ty, i8p, catch_fn_ty],
1257+
tcx.types.i32,
12581258
false,
12591259
rustc_hir::Unsafety::Unsafe,
12601260
Abi::Rust,

src/intrinsic/simd.rs

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use gccjit::{BinaryOp, RValue, Type};
44

55
use rustc_codegen_ssa::base::compare_simd_types;
66
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
7+
use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization};
78
use rustc_codegen_ssa::mir::operand::OperandRef;
89
use rustc_codegen_ssa::mir::place::PlaceRef;
910
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods};
@@ -295,11 +296,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
295296
(Style::Unsupported, Style::Unsupported) => {
296297
require!(
297298
false,
298-
"unsupported cast from `{}` with element `{}` to `{}` with element `{}`",
299-
in_ty,
300-
in_elem,
301-
ret_ty,
302-
out_elem
299+
InvalidMonomorphization::UnsupportedCast {
300+
span,
301+
name,
302+
in_ty,
303+
in_elem,
304+
ret_ty,
305+
out_elem
306+
}
303307
);
304308
},
305309
_ => return Ok(bx.context.convert_vector(None, args[0].immediate(), llret_ty)),
@@ -362,7 +366,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
362366
}
363367
ty::Array(elem, len)
364368
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
365-
&& len.try_eval_usize(bx.tcx, ty::ParamEnv::reveal_all())
369+
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
366370
== Some(expected_bytes) =>
367371
{
368372
// Zero-extend iN to the array length:
@@ -375,12 +379,13 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
375379
let ptr = bx.pointercast(ptr, bx.cx.type_ptr_to(array_ty));
376380
return Ok(bx.load(array_ty, ptr, Align::ONE));
377381
}
378-
_ => return_error!(
379-
"cannot return `{}`, expected `u{}` or `[u8; {}]`",
382+
_ => return_error!(InvalidMonomorphization::CannotReturn {
383+
span,
384+
name,
380385
ret_ty,
381386
expected_int_bits,
382387
expected_bytes
383-
),
388+
}),
384389
}
385390
}
386391

@@ -410,9 +415,9 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
410415
}
411416
}
412417
}
413-
} else {
414-
return_error!(InvalidMonomorphizationNotFloat { span, name, ty: in_ty });
415-
};
418+
else {
419+
return_error!(InvalidMonomorphizationNotFloat { span, name, ty: in_ty });
420+
};
416421

417422
let vec_ty = bx.cx.type_vector(elem_ty, in_len);
418423

@@ -560,27 +565,32 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
560565
let (out_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
561566
require!(
562567
in_len == out_len,
563-
"expected {} argument with length {} (same as input type `{}`), \
564-
found `{}` with length {}",
565-
"second",
566-
in_len,
567-
in_ty,
568-
arg_tys[1],
569-
out_len
568+
InvalidMonomorphization::SecondArgumentLength {
569+
span,
570+
name,
571+
in_len,
572+
in_ty,
573+
arg_ty: arg_tys[1],
574+
out_len
575+
}
570576
);
571577
require!(
572578
in_len == out_len2,
573-
"expected {} argument with length {} (same as input type `{}`), \
574-
found `{}` with length {}",
575-
"third",
576-
in_len,
577-
in_ty,
578-
arg_tys[2],
579-
out_len2
579+
InvalidMonomorphization::ThirdArgumentLength {
580+
span,
581+
name,
582+
in_len,
583+
in_ty,
584+
arg_ty: arg_tys[2],
585+
out_len: out_len2
586+
}
580587
);
581588

582589
// The return type must match the first argument type
583-
require!(ret_ty == in_ty, "expected return type `{}`, found `{}`", in_ty, ret_ty);
590+
require!(
591+
ret_ty == in_ty,
592+
InvalidMonomorphization::ExpectedReturnType { span, name, in_ty, ret_ty }
593+
);
584594

585595
// This counts how many pointers
586596
fn ptr_count(t: Ty<'_>) -> usize {
@@ -607,15 +617,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
607617
_ => {
608618
require!(
609619
false,
610-
"expected element type `{}` of second argument `{}` \
611-
to be a pointer to the element type `{}` of the first \
612-
argument `{}`, found `{}` != `*_ {}`",
613-
element_ty1,
614-
arg_tys[1],
620+
InvalidMonomorphization::ExpectedElementType {
621+
span,
622+
name,
623+
expected_element: element_ty1,
624+
second_arg: arg_tys[1],
615625
in_elem,
616626
in_ty,
617-
element_ty1,
618-
in_elem
627+
mutability: ExpectedPointerMutability::Not,
628+
}
619629
);
620630
unreachable!();
621631
}
@@ -631,10 +641,12 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
631641
_ => {
632642
require!(
633643
false,
634-
"expected element type `{}` of third argument `{}` \
635-
to be a signed integer type",
636-
element_ty2,
637-
arg_tys[2]
644+
InvalidMonomorphization::ThirdArgElementType {
645+
span,
646+
name,
647+
expected_element: element_ty2,
648+
third_arg: arg_tys[2]
649+
}
638650
);
639651
}
640652
}
@@ -660,23 +672,25 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
660672
let (element_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
661673
require!(
662674
in_len == element_len1,
663-
"expected {} argument with length {} (same as input type `{}`), \
664-
found `{}` with length {}",
665-
"second",
666-
in_len,
667-
in_ty,
668-
arg_tys[1],
669-
element_len1
675+
InvalidMonomorphization::SecondArgumentLength {
676+
span,
677+
name,
678+
in_len,
679+
in_ty,
680+
arg_ty: arg_tys[1],
681+
out_len: element_len1
682+
}
670683
);
671684
require!(
672685
in_len == element_len2,
673-
"expected {} argument with length {} (same as input type `{}`), \
674-
found `{}` with length {}",
675-
"third",
676-
in_len,
677-
in_ty,
678-
arg_tys[2],
679-
element_len2
686+
InvalidMonomorphization::ThirdArgumentLength {
687+
span,
688+
name,
689+
in_len,
690+
in_ty,
691+
arg_ty: arg_tys[2],
692+
out_len: element_len2
693+
}
680694
);
681695

682696
// This counts how many pointers
@@ -707,15 +721,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
707721
_ => {
708722
require!(
709723
false,
710-
"expected element type `{}` of second argument `{}` \
711-
to be a pointer to the element type `{}` of the first \
712-
argument `{}`, found `{}` != `*mut {}`",
713-
element_ty1,
714-
arg_tys[1],
724+
InvalidMonomorphization::ExpectedElementType {
725+
span,
726+
name,
727+
expected_element: element_ty1,
728+
second_arg: arg_tys[1],
715729
in_elem,
716730
in_ty,
717-
element_ty1,
718-
in_elem
731+
mutability: ExpectedPointerMutability::Mut,
732+
}
719733
);
720734
unreachable!();
721735
}
@@ -730,10 +744,12 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
730744
_ => {
731745
require!(
732746
false,
733-
"expected element type `{}` of third argument `{}` \
734-
be a signed integer type",
735-
element_ty2,
736-
arg_tys[2]
747+
InvalidMonomorphization::ThirdArgElementType {
748+
span,
749+
name,
750+
expected_element: element_ty2,
751+
third_arg: arg_tys[2]
752+
}
737753
);
738754
}
739755
}
@@ -816,18 +832,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
816832
});
817833
}
818834
};
819-
let builtin_name =
820-
match (signed, is_add, in_len, elem_width) {
821-
(true, true, 32, 8) => "__builtin_ia32_paddsb256", // TODO(antoyo): cast arguments to unsigned.
822-
(false, true, 32, 8) => "__builtin_ia32_paddusb256",
823-
(true, true, 16, 16) => "__builtin_ia32_paddsw256",
824-
(false, true, 16, 16) => "__builtin_ia32_paddusw256",
825-
(true, false, 16, 16) => "__builtin_ia32_psubsw256",
826-
(false, false, 16, 16) => "__builtin_ia32_psubusw256",
827-
(true, false, 32, 8) => "__builtin_ia32_psubsb256",
828-
(false, false, 32, 8) => "__builtin_ia32_psubusb256",
829-
_ => unimplemented!("signed: {}, is_add: {}, in_len: {}, elem_width: {}", signed, is_add, in_len, elem_width),
830-
};
831835

832836
let result =
833837
match (signed, is_add) {

src/type_.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
247247
pub fn type_named_struct(&self, name: &str) -> Struct<'gcc> {
248248
self.context.new_opaque_struct_type(None, name)
249249
}
250-
251-
pub fn type_bool(&self) -> Type<'gcc> {
252-
self.context.new_type::<bool>()
253-
}
254250
}
255251

256252
pub fn struct_fields<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout<'tcx>) -> (Vec<Type<'gcc>>, bool) {

0 commit comments

Comments
 (0)