This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: generate_bytecode_insn - tree code not implemented: min_expr
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Roger Sayle <roger at eyesopen dot com>, Erik Poupaert <erik dot poupaert at hurricanedev dot com>
- Date: Tue, 16 Sep 2003 16:08:11 +0100
- Subject: Re: generate_bytecode_insn - tree code not implemented: min_expr
- References: <1063443469.10626.ezmlm@gcc.gnu.org><20030913110357.66c244e1.erik.poupaert@hurricanedev.com><16226.57784.441530.467806@cuddles.cambridge.redhat.com><20030913113927.763e1a55.erik.poupaert@hurricanedev.com>
Try this.
Roger, I'm still interested in finding out what canonical set of
expressions I really should expect. There may be more I don't know
about, leaving latent bugs.
Andrew.
2003-09-16 Andrew Haley <aph@redhat.com>
* jcf-write.c (generate_bytecode_insns): Add MIN_EXPR and MAX_EXPR.
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.130
diff -c -2 -p -r1.130 jcf-write.c
*** jcf-write.c 12 Aug 2003 20:34:51 -0000 1.130
--- jcf-write.c 16 Sep 2003 15:03:15 -0000
*************** generate_bytecode_insns (tree exp, int t
*** 2414,2417 ****
--- 2414,2433 ----
NOTE_PUSH (1); /* Pushed by exception system. */
break;
+ case MIN_EXPR:
+ case MAX_EXPR:
+ {
+ /* This copes with cases where fold() has created MIN or MAX
+ from a conditional expression. */
+ enum tree_code code = TREE_CODE (exp) == MIN_EXPR ? LT_EXPR : GT_EXPR;
+ tree op0 = TREE_OPERAND (exp, 0);
+ tree op1 = TREE_OPERAND (exp, 1);
+ if (TREE_SIDE_EFFECTS (op0) || TREE_SIDE_EFFECTS (op1))
+ abort ();
+ tree new = build (COND_EXPR, TREE_TYPE (exp),
+ build (code, boolean_type_node, op0, op1),
+ op0, op1);
+ generate_bytecode_insns (new, target, state);
+ break;
+ }
case NEW_CLASS_EXPR:
{