From bab9c7adba4cea6dca05ff8a5b2a21b96e237a6a Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 8 Nov 2007 21:52:38 -0800 Subject: [PATCH] Proper compile time processing of arithmetic right shift Handle arithmetic right shift during compile time. This comes up with both the operands are constant expressions. the compiler is able to evaluate this down to a constant to replace the expression. Signed-off-by: Stephen Williams --- eval_tree.cc | 11 ++++++----- pform_dump.cc | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/eval_tree.cc b/eval_tree.cc index 9c6dfe976..2f2e877cc 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -16,9 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifdef HAVE_CVS_IDENT -#ident "$Id: eval_tree.cc,v 1.77 2007/06/02 03:42:12 steve Exp $" -#endif # include "config.h" # include "compiler.h" @@ -1075,9 +1072,13 @@ NetEConst* NetEBShift::eval_tree(int prune_to_width) wid = prune_to_width; assert(wid); - verinum nv (verinum::V0, wid, lv.has_len()); + verinum::V pad = verinum::V0; + if (op() == 'R' && has_sign()) { + pad = lv[lv.len()-1]; + } + verinum nv (pad, wid, lv.has_len()); - if (op() == 'r') { + if (op() == 'r' || op() == 'R') { unsigned cnt = wid; if (cnt > nv.len()) cnt = nv.len(); diff --git a/pform_dump.cc b/pform_dump.cc index 978aa6609..ddab6468a 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -16,9 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifdef HAVE_CVS_IDENT -#ident "$Id: pform_dump.cc,v 1.101 2007/06/04 02:19:07 steve Exp $" -#endif # include "config.h" @@ -243,6 +240,9 @@ void PEBinary::dump(ostream&out) const case 'N': out << "!=="; break; + case 'R': + out << ">>>"; + break; case 'r': out << ">>"; break;