From 889150a4f9eb603a90ec241d14777e001b2c3b08 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 25 Sep 2018 18:35:05 +0200 Subject: [PATCH] Implement binop eq and ne for fat ptr's --- ...nd-task-modules-because-they-contain.patch | 68 ------------------- ...me-more-unsupported-stuff-in-libcore.patch | 0 src/base.rs | 61 ++++++++++------- 3 files changed, 36 insertions(+), 93 deletions(-) delete mode 100644 0004-Disable-future-and-task-modules-because-they-contain.patch rename 0005-Disable-some-more-unsupported-stuff-in-libcore.patch => 0004-Disable-some-more-unsupported-stuff-in-libcore.patch (100%) diff --git a/0004-Disable-future-and-task-modules-because-they-contain.patch b/0004-Disable-future-and-task-modules-because-they-contain.patch deleted file mode 100644 index 9b272a8f34b..00000000000 --- a/0004-Disable-future-and-task-modules-because-they-contain.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 8838226899913c8636fa00f4dfbc7497c685abc5 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Thu, 20 Sep 2018 18:16:25 +0200 -Subject: [PATCH] Disable future and task modules, because they contain unsized - types - ---- - src/libcore/lib.rs | 4 +++- - src/libcore/option.rs | 4 +++- - 2 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 09f5035..f129254 100644 ---- a/src/libcore/lib.rs -+++ b/src/libcore/lib.rs -@@ -194,7 +194,7 @@ pub mod cell; - pub mod char; - pub mod panic; - pub mod panicking; --pub mod pin; -+//pub mod pin; - pub mod iter; - pub mod option; - pub mod raw; -@@ -209,9 +209,11 @@ pub mod time; - - pub mod unicode; - -+/* - /* Async */ - pub mod future; - pub mod task; -+*/ - - /* Heap memory allocator trait */ - #[allow(missing_docs)] -diff --git a/src/libcore/option.rs b/src/libcore/option.rs -index 58bf6be..902d38f 100644 ---- a/src/libcore/option.rs -+++ b/src/libcore/option.rs -@@ -147,7 +147,7 @@ - - use iter::{FromIterator, FusedIterator, TrustedLen}; - use {hint, mem, ops::{self, Deref}}; --use pin::Pin; -+//use pin::Pin; - - // Note that this is not a lang item per se, but it has a hidden dependency on - // `Iterator`, which is one. The compiler assumes that the `next` method of -@@ -271,6 +271,7 @@ impl Option { - } - - -+ /* - /// Converts from `Pin<&Option>` to `Option>` - #[inline] - #[unstable(feature = "pin", issue = "49150")] -@@ -288,6 +289,7 @@ impl Option { - Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x)) - } - } -+ */ - - ///////////////////////////////////////////////////////////////////////// - // Getting to contained values --- -2.11.0 - diff --git a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch b/0004-Disable-some-more-unsupported-stuff-in-libcore.patch similarity index 100% rename from 0005-Disable-some-more-unsupported-stuff-in-libcore.patch rename to 0004-Disable-some-more-unsupported-stuff-in-libcore.patch diff --git a/src/base.rs b/src/base.rs index e3df8769b98..590f6d63264 100644 --- a/src/base.rs +++ b/src/base.rs @@ -968,38 +968,49 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, - ty: Ty<'tcx>, + ret_ty: Ty<'tcx>, ) -> CValue<'tcx> { match lhs.layout().ty.sty { ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - if !ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { - unimpl!("Unsized values are not yet implemented"); + if ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { + binop_match! { + fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) iadd; + } + } else { + let lhs = lhs.load_value_pair(fx).0; + let rhs = rhs.load_value_pair(fx).0; + let res = match bin_op { + BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), + BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), + _ => unimplemented!("trans_ptr_binop({:?}, , ) not implemented", bin_op), + }; + + assert_eq!(fx.tcx.types.bool, ret_ty); + let ret_layout = fx.layout_of(ret_ty); + CValue::ByVal(fx.bcx.ins().bint(types::I8, res), ret_layout) } } _ => bug!("trans_ptr_binop on non ptr"), } - binop_match! { - fx, bin_op, false, lhs, rhs, ty, "ptr"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) iadd; - } } pub fn trans_place<'a, 'tcx: 'a>(