Fix rebase
This commit is contained in:
parent
78f3a7ed1f
commit
e74f6ff54f
@ -455,12 +455,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature="master")]
|
#[cfg(feature="master")]
|
||||||
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> {
|
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> {
|
||||||
let try_block = self.current_func().new_block("try");
|
let try_block = self.current_func().new_block("try");
|
||||||
|
|
||||||
let current_block = self.block.clone();
|
let current_block = self.block.clone();
|
||||||
self.block = try_block;
|
self.block = try_block;
|
||||||
let call = self.call(typ, func, args, None); // TODO(antoyo): use funclet here?
|
let call = self.call(typ, None, func, args, None); // TODO(antoyo): use funclet here?
|
||||||
self.block = current_block;
|
self.block = current_block;
|
||||||
|
|
||||||
let return_value = self.current_func()
|
let return_value = self.current_func()
|
||||||
@ -1210,23 +1210,20 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
let zero = self.cx.context.new_rvalue_zero(self.int_type);
|
let zero = self.cx.context.new_rvalue_zero(self.int_type);
|
||||||
let ptr = self.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
|
let ptr = self.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
|
||||||
|
|
||||||
let field1_type = self.u8_type.make_pointer();
|
let value1_type = self.u8_type.make_pointer();
|
||||||
let field1 = self.context.new_field(None, field1_type, "landing_pad_field_1");
|
let ptr = self.cx.context.new_cast(None, ptr, value1_type);
|
||||||
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_2");
|
let value1 = ptr;
|
||||||
let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
|
let value2 = zero; // TODO(antoyo): set the proper value here (the type of exception?).
|
||||||
let value = self.current_func().new_local(None, struct_type.as_type(), "landing_pad");
|
|
||||||
let ptr = self.cx.context.new_cast(None, ptr, field1_type);
|
|
||||||
self.block.add_assignment(None, value.access_field(None, field1), ptr);
|
|
||||||
self.block.add_assignment(None, value.access_field(None, field2), zero); // TODO(antoyo): set the proper value here (the type of exception?).
|
|
||||||
|
|
||||||
value.to_rvalue()
|
(value1, value2)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature="master"))]
|
#[cfg(not(feature="master"))]
|
||||||
fn cleanup_landing_pad(&mut self, _pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
|
fn cleanup_landing_pad(&mut self, _pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
|
||||||
let field1 = self.context.new_field(None, self.u8_type.make_pointer(), "landing_pad_field_1");
|
let value1 = self.current_func().new_local(None, self.u8_type.make_pointer(), "landing_pad0")
|
||||||
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
|
.to_rvalue();
|
||||||
(field1, field2)
|
let value2 = self.current_func().new_local(None, self.i32_type, "landing_pad1").to_rvalue();
|
||||||
|
(value1, value2)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature="master")]
|
#[cfg(feature="master")]
|
||||||
|
@ -391,7 +391,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||||||
tcx,
|
tcx,
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
def_id,
|
def_id,
|
||||||
tcx.intern_substs(&[]),
|
ty::List::empty(),
|
||||||
)
|
)
|
||||||
.unwrap().unwrap();
|
.unwrap().unwrap();
|
||||||
|
|
||||||
|
@ -1202,21 +1202,21 @@ fn codegen_gnu_try<'gcc>(bx: &mut Builder<'_, 'gcc, '_>, try_func: RValue<'gcc>,
|
|||||||
let zero = bx.cx.context.new_rvalue_zero(bx.int_type);
|
let zero = bx.cx.context.new_rvalue_zero(bx.int_type);
|
||||||
let ptr = bx.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
|
let ptr = bx.cx.context.new_call(None, eh_pointer_builtin, &[zero]);
|
||||||
let catch_ty = bx.type_func(&[bx.type_i8p(), bx.type_i8p()], bx.type_void());
|
let catch_ty = bx.type_func(&[bx.type_i8p(), bx.type_i8p()], bx.type_void());
|
||||||
bx.call(catch_ty, catch_func, &[data, ptr], None);
|
bx.call(catch_ty, None, catch_func, &[data, ptr], None);
|
||||||
bx.ret(bx.const_i32(1));
|
bx.ret(bx.const_i32(1));
|
||||||
|
|
||||||
// NOTE: the blocks must be filled before adding the try/catch, otherwise gcc will not
|
// NOTE: the blocks must be filled before adding the try/catch, otherwise gcc will not
|
||||||
// generate a try/catch.
|
// generate a try/catch.
|
||||||
// FIXME(antoyo): add a check in the libgccjit API to prevent this.
|
// FIXME(antoyo): add a check in the libgccjit API to prevent this.
|
||||||
bx.switch_to_block(current_block);
|
bx.switch_to_block(current_block);
|
||||||
bx.invoke(try_func_ty, try_func, &[data], then, catch, None);
|
bx.invoke(try_func_ty, None, try_func, &[data], then, catch, None);
|
||||||
});
|
});
|
||||||
|
|
||||||
let func = unsafe { std::mem::transmute(func) };
|
let func = unsafe { std::mem::transmute(func) };
|
||||||
|
|
||||||
// Note that no invoke is used here because by definition this function
|
// Note that no invoke is used here because by definition this function
|
||||||
// can't panic (that's what it's catching).
|
// can't panic (that's what it's catching).
|
||||||
let ret = bx.call(llty, func, &[try_func, data, catch_func], None);
|
let ret = bx.call(llty, None, func, &[try_func, data, catch_func], None);
|
||||||
let i32_align = bx.tcx().data_layout.i32_align.abi;
|
let i32_align = bx.tcx().data_layout.i32_align.abi;
|
||||||
bx.store(ret, dest, i32_align);
|
bx.store(ret, dest, i32_align);
|
||||||
}
|
}
|
||||||
@ -1253,8 +1253,8 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(cx: &'a CodegenCx<'gcc, 'tcx>, codegen: &mut
|
|||||||
)));
|
)));
|
||||||
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
|
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
|
||||||
let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig(
|
let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig(
|
||||||
[try_fn_ty, i8p, catch_fn_ty].iter(),
|
[try_fn_ty, i8p, catch_fn_ty],
|
||||||
&tcx.types.i32,
|
tcx.types.i32,
|
||||||
false,
|
false,
|
||||||
rustc_hir::Unsafety::Unsafe,
|
rustc_hir::Unsafety::Unsafe,
|
||||||
Abi::Rust,
|
Abi::Rust,
|
||||||
|
@ -4,6 +4,7 @@ use gccjit::{BinaryOp, RValue, Type};
|
|||||||
|
|
||||||
use rustc_codegen_ssa::base::compare_simd_types;
|
use rustc_codegen_ssa::base::compare_simd_types;
|
||||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
||||||
|
use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization};
|
||||||
use rustc_codegen_ssa::mir::operand::OperandRef;
|
use rustc_codegen_ssa::mir::operand::OperandRef;
|
||||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||||
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods};
|
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods};
|
||||||
@ -295,11 +296,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
(Style::Unsupported, Style::Unsupported) => {
|
(Style::Unsupported, Style::Unsupported) => {
|
||||||
require!(
|
require!(
|
||||||
false,
|
false,
|
||||||
"unsupported cast from `{}` with element `{}` to `{}` with element `{}`",
|
InvalidMonomorphization::UnsupportedCast {
|
||||||
in_ty,
|
span,
|
||||||
in_elem,
|
name,
|
||||||
ret_ty,
|
in_ty,
|
||||||
out_elem
|
in_elem,
|
||||||
|
ret_ty,
|
||||||
|
out_elem
|
||||||
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
_ => return Ok(bx.context.convert_vector(None, args[0].immediate(), llret_ty)),
|
_ => return Ok(bx.context.convert_vector(None, args[0].immediate(), llret_ty)),
|
||||||
@ -362,7 +366,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
}
|
}
|
||||||
ty::Array(elem, len)
|
ty::Array(elem, len)
|
||||||
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
|
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
|
||||||
&& len.try_eval_usize(bx.tcx, ty::ParamEnv::reveal_all())
|
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
|
||||||
== Some(expected_bytes) =>
|
== Some(expected_bytes) =>
|
||||||
{
|
{
|
||||||
// Zero-extend iN to the array length:
|
// Zero-extend iN to the array length:
|
||||||
@ -375,12 +379,13 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
let ptr = bx.pointercast(ptr, bx.cx.type_ptr_to(array_ty));
|
let ptr = bx.pointercast(ptr, bx.cx.type_ptr_to(array_ty));
|
||||||
return Ok(bx.load(array_ty, ptr, Align::ONE));
|
return Ok(bx.load(array_ty, ptr, Align::ONE));
|
||||||
}
|
}
|
||||||
_ => return_error!(
|
_ => return_error!(InvalidMonomorphization::CannotReturn {
|
||||||
"cannot return `{}`, expected `u{}` or `[u8; {}]`",
|
span,
|
||||||
|
name,
|
||||||
ret_ty,
|
ret_ty,
|
||||||
expected_int_bits,
|
expected_int_bits,
|
||||||
expected_bytes
|
expected_bytes
|
||||||
),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,9 +415,9 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
return_error!(InvalidMonomorphizationNotFloat { span, name, ty: in_ty });
|
return_error!(InvalidMonomorphizationNotFloat { span, name, ty: in_ty });
|
||||||
};
|
};
|
||||||
|
|
||||||
let vec_ty = bx.cx.type_vector(elem_ty, in_len);
|
let vec_ty = bx.cx.type_vector(elem_ty, in_len);
|
||||||
|
|
||||||
@ -560,27 +565,32 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
let (out_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
|
let (out_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
|
||||||
require!(
|
require!(
|
||||||
in_len == out_len,
|
in_len == out_len,
|
||||||
"expected {} argument with length {} (same as input type `{}`), \
|
InvalidMonomorphization::SecondArgumentLength {
|
||||||
found `{}` with length {}",
|
span,
|
||||||
"second",
|
name,
|
||||||
in_len,
|
in_len,
|
||||||
in_ty,
|
in_ty,
|
||||||
arg_tys[1],
|
arg_ty: arg_tys[1],
|
||||||
out_len
|
out_len
|
||||||
|
}
|
||||||
);
|
);
|
||||||
require!(
|
require!(
|
||||||
in_len == out_len2,
|
in_len == out_len2,
|
||||||
"expected {} argument with length {} (same as input type `{}`), \
|
InvalidMonomorphization::ThirdArgumentLength {
|
||||||
found `{}` with length {}",
|
span,
|
||||||
"third",
|
name,
|
||||||
in_len,
|
in_len,
|
||||||
in_ty,
|
in_ty,
|
||||||
arg_tys[2],
|
arg_ty: arg_tys[2],
|
||||||
out_len2
|
out_len: out_len2
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// The return type must match the first argument type
|
// The return type must match the first argument type
|
||||||
require!(ret_ty == in_ty, "expected return type `{}`, found `{}`", in_ty, ret_ty);
|
require!(
|
||||||
|
ret_ty == in_ty,
|
||||||
|
InvalidMonomorphization::ExpectedReturnType { span, name, in_ty, ret_ty }
|
||||||
|
);
|
||||||
|
|
||||||
// This counts how many pointers
|
// This counts how many pointers
|
||||||
fn ptr_count(t: Ty<'_>) -> usize {
|
fn ptr_count(t: Ty<'_>) -> usize {
|
||||||
@ -607,15 +617,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
_ => {
|
_ => {
|
||||||
require!(
|
require!(
|
||||||
false,
|
false,
|
||||||
"expected element type `{}` of second argument `{}` \
|
InvalidMonomorphization::ExpectedElementType {
|
||||||
to be a pointer to the element type `{}` of the first \
|
span,
|
||||||
argument `{}`, found `{}` != `*_ {}`",
|
name,
|
||||||
element_ty1,
|
expected_element: element_ty1,
|
||||||
arg_tys[1],
|
second_arg: arg_tys[1],
|
||||||
in_elem,
|
in_elem,
|
||||||
in_ty,
|
in_ty,
|
||||||
element_ty1,
|
mutability: ExpectedPointerMutability::Not,
|
||||||
in_elem
|
}
|
||||||
);
|
);
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
@ -631,10 +641,12 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
_ => {
|
_ => {
|
||||||
require!(
|
require!(
|
||||||
false,
|
false,
|
||||||
"expected element type `{}` of third argument `{}` \
|
InvalidMonomorphization::ThirdArgElementType {
|
||||||
to be a signed integer type",
|
span,
|
||||||
element_ty2,
|
name,
|
||||||
arg_tys[2]
|
expected_element: element_ty2,
|
||||||
|
third_arg: arg_tys[2]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,23 +672,25 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
let (element_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
|
let (element_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
|
||||||
require!(
|
require!(
|
||||||
in_len == element_len1,
|
in_len == element_len1,
|
||||||
"expected {} argument with length {} (same as input type `{}`), \
|
InvalidMonomorphization::SecondArgumentLength {
|
||||||
found `{}` with length {}",
|
span,
|
||||||
"second",
|
name,
|
||||||
in_len,
|
in_len,
|
||||||
in_ty,
|
in_ty,
|
||||||
arg_tys[1],
|
arg_ty: arg_tys[1],
|
||||||
element_len1
|
out_len: element_len1
|
||||||
|
}
|
||||||
);
|
);
|
||||||
require!(
|
require!(
|
||||||
in_len == element_len2,
|
in_len == element_len2,
|
||||||
"expected {} argument with length {} (same as input type `{}`), \
|
InvalidMonomorphization::ThirdArgumentLength {
|
||||||
found `{}` with length {}",
|
span,
|
||||||
"third",
|
name,
|
||||||
in_len,
|
in_len,
|
||||||
in_ty,
|
in_ty,
|
||||||
arg_tys[2],
|
arg_ty: arg_tys[2],
|
||||||
element_len2
|
out_len: element_len2
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// This counts how many pointers
|
// This counts how many pointers
|
||||||
@ -707,15 +721,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
_ => {
|
_ => {
|
||||||
require!(
|
require!(
|
||||||
false,
|
false,
|
||||||
"expected element type `{}` of second argument `{}` \
|
InvalidMonomorphization::ExpectedElementType {
|
||||||
to be a pointer to the element type `{}` of the first \
|
span,
|
||||||
argument `{}`, found `{}` != `*mut {}`",
|
name,
|
||||||
element_ty1,
|
expected_element: element_ty1,
|
||||||
arg_tys[1],
|
second_arg: arg_tys[1],
|
||||||
in_elem,
|
in_elem,
|
||||||
in_ty,
|
in_ty,
|
||||||
element_ty1,
|
mutability: ExpectedPointerMutability::Mut,
|
||||||
in_elem
|
}
|
||||||
);
|
);
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
@ -730,10 +744,12 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
_ => {
|
_ => {
|
||||||
require!(
|
require!(
|
||||||
false,
|
false,
|
||||||
"expected element type `{}` of third argument `{}` \
|
InvalidMonomorphization::ThirdArgElementType {
|
||||||
be a signed integer type",
|
span,
|
||||||
element_ty2,
|
name,
|
||||||
arg_tys[2]
|
expected_element: element_ty2,
|
||||||
|
third_arg: arg_tys[2]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -816,18 +832,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let builtin_name =
|
|
||||||
match (signed, is_add, in_len, elem_width) {
|
|
||||||
(true, true, 32, 8) => "__builtin_ia32_paddsb256", // TODO(antoyo): cast arguments to unsigned.
|
|
||||||
(false, true, 32, 8) => "__builtin_ia32_paddusb256",
|
|
||||||
(true, true, 16, 16) => "__builtin_ia32_paddsw256",
|
|
||||||
(false, true, 16, 16) => "__builtin_ia32_paddusw256",
|
|
||||||
(true, false, 16, 16) => "__builtin_ia32_psubsw256",
|
|
||||||
(false, false, 16, 16) => "__builtin_ia32_psubusw256",
|
|
||||||
(true, false, 32, 8) => "__builtin_ia32_psubsb256",
|
|
||||||
(false, false, 32, 8) => "__builtin_ia32_psubusb256",
|
|
||||||
_ => unimplemented!("signed: {}, is_add: {}, in_len: {}, elem_width: {}", signed, is_add, in_len, elem_width),
|
|
||||||
};
|
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
match (signed, is_add) {
|
match (signed, is_add) {
|
||||||
|
@ -247,10 +247,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||||||
pub fn type_named_struct(&self, name: &str) -> Struct<'gcc> {
|
pub fn type_named_struct(&self, name: &str) -> Struct<'gcc> {
|
||||||
self.context.new_opaque_struct_type(None, name)
|
self.context.new_opaque_struct_type(None, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_bool(&self) -> Type<'gcc> {
|
|
||||||
self.context.new_type::<bool>()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_fields<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout<'tcx>) -> (Vec<Type<'gcc>>, bool) {
|
pub fn struct_fields<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout<'tcx>) -> (Vec<Type<'gcc>>, bool) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user