diff options
author | dsmith <dsmith> | 2007-05-01 18:06:37 +0000 |
---|---|---|
committer | dsmith <dsmith> | 2007-05-01 18:06:37 +0000 |
commit | 1ae2676e68a7dd10b64d25a4862f9506718284e2 (patch) | |
tree | 0b04b73f7697dbb9499e0a5984c9a2904f30c4d2 /translate.cxx | |
parent | 355fc303a5a99f085c5f3e323f446b67778558ad (diff) | |
download | systemtap-steved-1ae2676e68a7dd10b64d25a4862f9506718284e2.tar.gz systemtap-steved-1ae2676e68a7dd10b64d25a4862f9506718284e2.tar.xz systemtap-steved-1ae2676e68a7dd10b64d25a4862f9506718284e2.zip |
2007-05-01 David Smith <dsmith@redhat.com>
* translate.cxx (c_tmpcounter::visit_binary_expression): Updated
temporary handling.
(c_unparser::visit_binary_expression): Improved handing of numeric
constants when handling '%' and '/' operators.
(c_tmpcounter::visit_print_format): Updated temporary handling.
(c_unparser::visit_print_format): Removed the need for a result
temporary when printing to a stream.
Diffstat (limited to 'translate.cxx')
-rw-r--r-- | translate.cxx | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/translate.cxx b/translate.cxx index e17e36ff..c48fccdd 100644 --- a/translate.cxx +++ b/translate.cxx @@ -2856,8 +2856,10 @@ c_tmpcounter::visit_binary_expression (binary_expression* e) { tmpvar left = parent->gensym (pe_long); tmpvar right = parent->gensym (pe_long); - left.declare (*parent); - right.declare (*parent); + if (e->left->tok->type != tok_number) + left.declare (*parent); + if (e->right->tok->type != tok_number) + right.declare (*parent); } e->left->visit (this); @@ -2904,14 +2906,25 @@ c_unparser::visit_binary_expression (binary_expression* e) tmpvar right = gensym (pe_long); o->line() << "({"; - o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";"; - o->newline(1) << left << " = "; - e->left->visit (this); - o->line() << ";"; + o->newline(1) << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";"; - o->newline() << right << " = "; - e->right->visit (this); - o->line() << ";"; + if (e->left->tok->type == tok_number) + left.override(c_expression(e->left)); + else + { + o->newline() << left << " = "; + e->left->visit (this); + o->line() << ";"; + } + + if (e->right->tok->type == tok_number) + right.override(c_expression(e->right)); + else + { + o->newline() << right << " = "; + e->right->visit (this); + o->line() << ";"; + } o->newline() << ((e->op == "/") ? "_stp_div64" : "_stp_mod64") << " (&c->last_error, " << left << ", " << right << ");"; @@ -3905,7 +3918,8 @@ c_tmpcounter::visit_print_format (print_format* e) // And the result exp_type ty = e->print_to_stream ? pe_long : pe_string; tmpvar res = parent->gensym (ty); - res.declare (*parent); + if (ty == pe_string) + res.declare (*parent); } } @@ -4008,7 +4022,9 @@ c_unparser::visit_print_format (print_format* e) o->indent(1); if (e->print_to_stream) { - o->newline() << res.value() << " = 0;"; + // We'll just hardcode the result of 0 instead of using the + // temporary. + res.override("((int64_t)0LL)"); o->newline() << "_stp_printf ("; } else |