OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [java/] [java-gimplify.c] - Blame information for rev 294

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 287 jeremybenn
/* Java(TM) language-specific gimplification routines.
2
   Copyright (C) 2003, 2004, 2006, 2007, 2007, 2008
3
   Free Software Foundation, Inc.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3, or (at your option)
10
any later version.
11
 
12
GCC is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.
20
 
21
Java and all Java-based marks are trademarks or registered trademarks
22
of Sun Microsystems, Inc. in the United States and other countries.
23
The Free Software Foundation is independent of Sun Microsystems, Inc.  */
24
 
25
#include "config.h"
26
#include "system.h"
27
#include "coretypes.h"
28
#include "tm.h"
29
#include "tree.h"
30
#include "java-tree.h"
31
#include "tree-dump.h"
32
#include "gimple.h"
33
#include "toplev.h"
34
 
35
static tree java_gimplify_block (tree);
36
static enum gimplify_status java_gimplify_modify_expr (tree *);
37
static enum gimplify_status java_gimplify_self_mod_expr (tree *, gimple_seq *,
38
                                                         gimple_seq *);
39
 
40
static void dump_java_tree (enum tree_dump_index, tree);
41
 
42
/* Convert a Java tree to GENERIC.  */
43
 
44
void
45
java_genericize (tree fndecl)
46
{
47
  walk_tree (&DECL_SAVED_TREE (fndecl), java_replace_references, NULL, NULL);
48
  dump_java_tree (TDI_original, fndecl);
49
}
50
 
51
/* Gimplify a Java tree.  */
52
 
53
int
54
java_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
55
{
56
  enum tree_code code = TREE_CODE (*expr_p);
57
 
58
  switch (code)
59
    {
60
    case BLOCK:
61
      *expr_p = java_gimplify_block (*expr_p);
62
      break;
63
 
64
    case MODIFY_EXPR:
65
      return java_gimplify_modify_expr (expr_p);
66
 
67
    case POSTINCREMENT_EXPR:
68
    case POSTDECREMENT_EXPR:
69
    case PREINCREMENT_EXPR:
70
    case PREDECREMENT_EXPR:
71
      return java_gimplify_self_mod_expr (expr_p, pre_p, post_p);
72
 
73
    /* These should already be lowered before we get here.  */
74
    case URSHIFT_EXPR:
75
    case COMPARE_EXPR:
76
    case COMPARE_L_EXPR:
77
    case COMPARE_G_EXPR:
78
      gcc_unreachable ();
79
 
80
    default:
81
      return GS_UNHANDLED;
82
    }
83
 
84
  return GS_OK;
85
}
86
 
87
static enum gimplify_status
88
java_gimplify_modify_expr (tree *modify_expr_p)
89
{
90
  tree modify_expr = *modify_expr_p;
91
  tree lhs = TREE_OPERAND (modify_expr, 0);
92
  tree rhs = TREE_OPERAND (modify_expr, 1);
93
  tree lhs_type = TREE_TYPE (lhs);
94
 
95
  if (lhs_type != TREE_TYPE (rhs))
96
    /* Fix up type mismatches to make legal GIMPLE.  These are
97
       generated in several places, in particular null pointer
98
       assignment and subclass assignment.  */
99
    TREE_OPERAND (modify_expr, 1) = convert (lhs_type, rhs);
100
 
101
  return GS_UNHANDLED;
102
}
103
 
104
/*  Special case handling for volatiles: we need to generate a barrier
105
    between the reading and the writing.  */
106
 
107
static enum gimplify_status
108
java_gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
109
                             gimple_seq *post_p ATTRIBUTE_UNUSED)
110
{
111
  tree lhs = TREE_OPERAND (*expr_p, 0);
112
 
113
  if (TREE_CODE (lhs) == COMPONENT_REF
114
      && TREE_THIS_VOLATILE (TREE_OPERAND (lhs, 1)))
115
    TREE_THIS_VOLATILE (lhs) = 1;
116
 
117
  return GS_UNHANDLED;
118
}
119
 
120
 
121
/* Gimplify BLOCK into a BIND_EXPR.  */
122
 
123
static tree
124
java_gimplify_block (tree java_block)
125
{
126
  tree decls = BLOCK_VARS (java_block);
127
  tree body = BLOCK_EXPR_BODY (java_block);
128
  gimple outer = gimple_current_bind_expr ();
129
  tree block;
130
 
131
  /* Don't bother with empty blocks.  */
132
  if (! body)
133
    return build_empty_stmt (input_location);
134
 
135
  if (IS_EMPTY_STMT (body))
136
    return body;
137
 
138
  /* Make a proper block.  Java blocks are unsuitable for BIND_EXPR
139
     because they use BLOCK_SUBBLOCKS for another purpose.  */
140
  block = make_node (BLOCK);
141
  BLOCK_VARS (block) = decls;
142
 
143
  /* The TREE_USED flag on a block determines whether the debug output
144
     routines generate info for the variables in that block.  */
145
  TREE_USED (block) = 1;
146
 
147
  if (outer != NULL)
148
    {
149
      tree b = gimple_bind_block (outer);
150
      BLOCK_SUBBLOCKS (b) = chainon (BLOCK_SUBBLOCKS (b), block);
151
    }
152
  BLOCK_EXPR_BODY (java_block) = NULL_TREE;
153
 
154
  return build3 (BIND_EXPR, TREE_TYPE (java_block), decls, body, block);
155
}
156
 
157
/* Dump a tree of some kind.  This is a convenience wrapper for the
158
   dump_* functions in tree-dump.c.  */
159
static void
160
dump_java_tree (enum tree_dump_index phase, tree t)
161
{
162
  FILE *stream;
163
  int flags;
164
 
165
  stream = dump_begin (phase, &flags);
166
  flags |= TDF_SLIM;
167
  if (stream)
168
    {
169
      dump_node (t, flags, stream);
170
      dump_end (phase, stream);
171
    }
172
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.