Update to nightly-2021-08-12 (#61)

This commit is contained in:
antoyo 2021-08-14 10:05:49 -04:00 committed by GitHub
parent afae271d5d
commit 0c89065b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 19 deletions

View File

@ -1 +1 @@
nightly-2021-07-21 nightly-2021-08-12

View File

@ -25,6 +25,7 @@ use rustc_codegen_ssa::traits::{
BuilderMethods, BuilderMethods,
ConstMethods, ConstMethods,
DerivedTypeMethods, DerivedTypeMethods,
LayoutTypeMethods,
HasCodegen, HasCodegen,
OverflowOp, OverflowOp,
StaticBuilderMethods, StaticBuilderMethods,
@ -514,8 +515,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
self.block.expect("block").end_with_switch(None, value, default_block, &gcc_cases); self.block.expect("block").end_with_switch(None, value, default_block, &gcc_cases);
} }
fn invoke(&mut self, _func: RValue<'gcc>, _args: &[RValue<'gcc>], _then: Block<'gcc>, _catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> { fn invoke(&mut self, _typ: Type<'gcc>, _func: RValue<'gcc>, _args: &[RValue<'gcc>], then: Block<'gcc>, catch: Block<'gcc>, _funclet: Option<&Funclet>) -> RValue<'gcc> {
unimplemented!(); let condition = self.context.new_rvalue_from_int(self.bool_type, 0);
self.llbb().end_with_conditional(None, condition, then, catch);
self.context.new_rvalue_from_int(self.int_type, 0)
// TODO
/*debug!("invoke {:?} with args ({:?})", func, args); /*debug!("invoke {:?} with args ({:?})", func, args);
let args = self.check_call("invoke", func, args); let args = self.check_call("invoke", func, args);
@ -1001,9 +1006,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
} }
else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi { else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
let b_offset = a.value.size(self).align_to(b.value.align(self).abi); let b_offset = a.value.size(self).align_to(b.value.align(self).abi);
let pair_type = place.layout.gcc_type(self, false);
let mut load = |i, scalar: &abi::Scalar, align| { let mut load = |i, scalar: &abi::Scalar, align| {
let llptr = self.struct_gep(place.llval, i as u64); let llptr = self.struct_gep(pair_type, place.llval, i as u64);
let load = self.load(llptr.get_type(), llptr, align); let load = self.load(llptr.get_type(), llptr, align);
scalar_load_metadata(self, load, scalar); scalar_load_metadata(self, load, scalar);
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load } if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
@ -1044,7 +1050,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size); let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size);
cg_elem.val.store(&mut body_bx, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align)); cg_elem.val.store(&mut body_bx, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align));
let next = body_bx.inbounds_gep(current.to_rvalue(), &[self.const_usize(1)]); let next = body_bx.inbounds_gep(self.backend_type(cg_elem.layout), current.to_rvalue(), &[self.const_usize(1)]);
body_bx.llbb().add_assignment(None, current, next); body_bx.llbb().add_assignment(None, current, next);
body_bx.br(header_bx.llbb()); body_bx.br(header_bx.llbb());
@ -1130,7 +1136,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
.add_eval(None, self.context.new_call(None, atomic_store, &[ptr, value, ordering])); .add_eval(None, self.context.new_call(None, atomic_store, &[ptr, value, ordering]));
} }
fn gep(&mut self, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> { fn gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
let mut result = ptr; let mut result = ptr;
for index in indices { for index in indices {
result = self.context.new_array_access(None, result, *index).get_address(None).to_rvalue(); result = self.context.new_array_access(None, result, *index).get_address(None).to_rvalue();
@ -1138,7 +1144,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
result result
} }
fn inbounds_gep(&mut self, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> { fn inbounds_gep(&mut self, _typ: Type<'gcc>, ptr: RValue<'gcc>, indices: &[RValue<'gcc>]) -> RValue<'gcc> {
// FIXME: would be safer if doing the same thing (loop) as gep. // FIXME: would be safer if doing the same thing (loop) as gep.
// TODO: specify inbounds somehow. // TODO: specify inbounds somehow.
match indices.len() { match indices.len() {
@ -1153,11 +1159,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
} }
} }
fn struct_gep(&mut self, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> { fn struct_gep(&mut self, value_type: Type<'gcc>, ptr: RValue<'gcc>, idx: u64) -> RValue<'gcc> {
// FIXME: it would be better if the API only called this on struct, not on arrays. // FIXME: it would be better if the API only called this on struct, not on arrays.
assert_eq!(idx as usize as u64, idx); assert_eq!(idx as usize as u64, idx);
let value = ptr.dereference(None).to_rvalue(); let value = ptr.dereference(None).to_rvalue();
let value_type = value.get_type();
if value_type.is_array().is_some() { if value_type.is_array().is_some() {
let index = self.context.new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from")); let index = self.context.new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from"));
@ -1449,14 +1454,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
} }
fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses: usize) -> RValue<'gcc> { fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses: usize) -> RValue<'gcc> {
unimplemented!(); let field1 = self.context.new_field(None, self.u8_type, "landing_pad_field_1");
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
self.current_func().new_local(None, struct_type.as_type(), "landing_pad")
.to_rvalue()
// TODO
/*unsafe { /*unsafe {
llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn, num_clauses as c_uint, UNNAMED) llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn, num_clauses as c_uint, UNNAMED)
}*/ }*/
} }
fn set_cleanup(&mut self, _landing_pad: RValue<'gcc>) { fn set_cleanup(&mut self, _landing_pad: RValue<'gcc>) {
unimplemented!(); // TODO
/*unsafe { /*unsafe {
llvm::LLVMSetCleanup(landing_pad, llvm::True); llvm::LLVMSetCleanup(landing_pad, llvm::True);
}*/ }*/
@ -1527,7 +1537,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
} }
fn set_personality_fn(&mut self, _personality: RValue<'gcc>) { fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
unimplemented!(); // TODO
/*unsafe { /*unsafe {
llvm::LLVMSetPersonalityFn(self.llfn(), personality); llvm::LLVMSetPersonalityFn(self.llfn(), personality);
}*/ }*/
@ -1620,7 +1630,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
//self.call_lifetime_intrinsic("llvm.lifetime.end.p0i8", ptr, size); //self.call_lifetime_intrinsic("llvm.lifetime.end.p0i8", ptr, size);
} }
fn call(&mut self, func: RValue<'gcc>, args: &[RValue<'gcc>], funclet: Option<&Funclet>) -> RValue<'gcc> { fn call(&mut self, _typ: Type<'gcc>, func: RValue<'gcc>, args: &[RValue<'gcc>], funclet: Option<&Funclet>) -> RValue<'gcc> {
// FIXME: remove when having a proper API. // FIXME: remove when having a proper API.
let gcc_func = unsafe { std::mem::transmute(func) }; let gcc_func = unsafe { std::mem::transmute(func) };
if self.functions.borrow().values().find(|value| **value == gcc_func).is_some() { if self.functions.borrow().values().find(|value| **value == gcc_func).is_some() {

View File

@ -14,7 +14,6 @@ use gccjit::{
use rustc_codegen_ssa::base::wants_msvc_seh; use rustc_codegen_ssa::base::wants_msvc_seh;
use rustc_codegen_ssa::traits::{ use rustc_codegen_ssa::traits::{
BackendTypes, BackendTypes,
BaseTypeMethods,
MiscMethods, MiscMethods,
}; };
use rustc_data_structures::base_n; use rustc_data_structures::base_n;
@ -349,12 +348,15 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
.unwrap().unwrap(), .unwrap().unwrap(),
), ),
_ => { _ => {
let name = if wants_msvc_seh(self.sess()) { let _name = if wants_msvc_seh(self.sess()) {
"__CxxFrameHandler3" "__CxxFrameHandler3"
} else { } else {
"rust_eh_personality" "rust_eh_personality"
}; };
self.declare_func(name, self.type_i32(), &[], true) //let func = self.declare_func(name, self.type_i32(), &[], true);
// FIXME: this hack should not be needed. That will probably be removed when
// unwinding support is added.
self.context.new_rvalue_from_int(self.int_type, 0)
} }
}; };
//attributes::apply_target_cpu_attr(self, llfn); //attributes::apply_target_cpu_attr(self, llfn);

View File

@ -98,7 +98,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
_ if simple.is_some() => { _ if simple.is_some() => {
// FIXME: remove this cast when the API supports function. // FIXME: remove this cast when the API supports function.
let func = unsafe { std::mem::transmute(simple.expect("simple")) }; let func = unsafe { std::mem::transmute(simple.expect("simple")) };
self.call(func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None) self.call(self.type_void(), func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None)
}, },
sym::likely => { sym::likely => {
self.expect(args[0].immediate(), true) self.expect(args[0].immediate(), true)
@ -392,7 +392,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
fn abort(&mut self) { fn abort(&mut self) {
let func = self.context.get_builtin_function("abort"); let func = self.context.get_builtin_function("abort");
let func: RValue<'gcc> = unsafe { std::mem::transmute(func) }; let func: RValue<'gcc> = unsafe { std::mem::transmute(func) };
self.call(func, &[], None); self.call(self.type_void(), func, &[], None);
} }
fn assume(&mut self, value: Self::Value) { fn assume(&mut self, value: Self::Value) {
@ -1075,7 +1075,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
fn try_intrinsic<'gcc, 'tcx>(bx: &mut Builder<'_, 'gcc, 'tcx>, try_func: RValue<'gcc>, data: RValue<'gcc>, _catch_func: RValue<'gcc>, dest: RValue<'gcc>) { fn try_intrinsic<'gcc, 'tcx>(bx: &mut Builder<'_, 'gcc, 'tcx>, try_func: RValue<'gcc>, data: RValue<'gcc>, _catch_func: RValue<'gcc>, dest: RValue<'gcc>) {
if bx.sess().panic_strategy() == PanicStrategy::Abort { if bx.sess().panic_strategy() == PanicStrategy::Abort {
bx.call(try_func, &[data], None); bx.call(bx.type_void(), try_func, &[data], None);
// Return 0 unconditionally from the intrinsic call; // Return 0 unconditionally from the intrinsic call;
// we can never unwind. // we can never unwind.
let ret_align = bx.tcx.data_layout.i32_align.abi; let ret_align = bx.tcx.data_layout.i32_align.abi;

View File

@ -293,6 +293,11 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
} }
} }
// NOTE: see note above. Some other test uses usize::MAX.
if len == u64::MAX {
len = 0;
}
let len: i32 = len.try_into().expect("array len"); let len: i32 = len.try_into().expect("array len");
self.context.new_array_type(None, ty, len) self.context.new_array_type(None, ty, len)

View File

@ -363,4 +363,10 @@ impl<'gcc, 'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
unimplemented!(); unimplemented!();
//ty.gcc_type(self) //ty.gcc_type(self)
} }
fn fn_decl_backend_type(&self, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> Type<'gcc> {
// FIXME: return correct type.
self.type_void()
//fn_abi.gcc_type(self)
}
} }