aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgsvelto <gsvelto@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-20 20:10:52 +0000
committergsvelto <gsvelto@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-20 20:10:52 +0000
commite50c85fc3b814cf3d938a9edfd898859f3dd3ede (patch)
treebb0f4ade8d4e25061b716fb305456a79f887342a
parent10b5c208be3d3e81d708deade45660884186840b (diff)
merge from trunk revisions 127002-132392, FINAL
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/st/cli-be@146453 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/config/cil32/bb-layout.c54
-rw-r--r--gcc/config/cil32/cil-builtins.c22
-rw-r--r--gcc/config/cil32/cil-builtins.h2
-rw-r--r--gcc/config/cil32/cil-refs.c48
-rw-r--r--gcc/config/cil32/cil-refs.h10
-rw-r--r--gcc/config/cil32/cil-stmt.h6
-rw-r--r--gcc/config/cil32/cil-types.h8
-rw-r--r--gcc/config/cil32/cil32.c6
-rw-r--r--gcc/config/cil32/cil32.md8
-rw-r--r--gcc/config/cil32/emit-cil.c66
-rw-r--r--gcc/config/cil32/emit-hints.c150
-rw-r--r--gcc/config/cil32/gimple-to-cil.c205
-rw-r--r--gcc/config/cil32/tree-simp-cil-early.c6
13 files changed, 353 insertions, 238 deletions
diff --git a/gcc/config/cil32/bb-layout.c b/gcc/config/cil32/bb-layout.c
index cf2e531da2b..0f64addc460 100644
--- a/gcc/config/cil32/bb-layout.c
+++ b/gcc/config/cil32/bb-layout.c
@@ -96,10 +96,10 @@ compute_layout (basic_block bb, basic_block* bb_order, int* num_so_far,
/* In case the second edge is heavier than the first one, we invert the
scanning order. */
if (e1->probability < e2->probability)
- {
- edge_pos = 1; /* start from second edge */
- edge_dir = -1; /* and go backwards */
- }
+ {
+ edge_pos = 1; /* start from second edge */
+ edge_dir = -1; /* and go backwards */
+ }
}
for(i = 0; i < num_edges; ++i)
@@ -111,28 +111,32 @@ compute_layout (basic_block bb, basic_block* bb_order, int* num_so_far,
edge_pos += edge_dir;
if ((succ == EXIT_BLOCK_PTR) || /* Skip EXIT block */
- (e->flags & EDGE_DFS_BACK) || /* Skip back edges */
- (visited (succ))) /* Already visited */
- continue;
+ (e->flags & EDGE_DFS_BACK) || /* Skip back edges */
+ (visited (succ))) /* Already visited */
+ {
+ continue;
+ }
/* Check if successor has all its predecessors visited, not considering
backedges. */
all_visited = true;
+
for (pred_it = ei_start (succ->preds);
- ei_cond (pred_it, &pred_edge);
- ei_next (&pred_it))
- {
- if (pred_edge->flags & EDGE_DFS_BACK)
- continue;
-
- if ((visited (pred_edge->src)) == 0)
- {
- all_visited = false;
- break;
- }
- }
+ ei_cond (pred_it, &pred_edge);
+ ei_next (&pred_it))
+ {
+ if (pred_edge->flags & EDGE_DFS_BACK)
+ continue;
+
+ if ((visited (pred_edge->src)) == 0)
+ {
+ all_visited = false;
+ break;
+ }
+ }
+
if (all_visited)
- compute_layout (succ, bb_order, num_so_far, changed);
+ compute_layout (succ, bb_order, num_so_far, changed);
}
}
@@ -156,11 +160,13 @@ bblayout (void)
{
bb_order[0]->prev_bb = NULL;
bb_order[0]->next_bb = bb_order[1];
+
for(i=1; i < bb_num-1; ++i)
- {
- bb_order[i]->prev_bb = bb_order[i-1];
- bb_order[i]->next_bb = bb_order[i+1];
- }
+ {
+ bb_order[i]->prev_bb = bb_order[i-1];
+ bb_order[i]->next_bb = bb_order[i+1];
+ }
+
bb_order[bb_num-1]->prev_bb = bb_order[bb_num-2];
bb_order[bb_num-1]->next_bb = NULL;
}
diff --git a/gcc/config/cil32/cil-builtins.c b/gcc/config/cil32/cil-builtins.c
index 219af92b778..e2824088102 100644
--- a/gcc/config/cil32/cil-builtins.c
+++ b/gcc/config/cil32/cil-builtins.c
@@ -142,7 +142,7 @@ cil_record_builtin_type (tree type)
/* Returns true if TYPE is a builtin type of the CIL back end. */
bool
-cil_builtin_type_p (tree type)
+cil_builtin_type_p (const_tree type)
{
void **slot;
@@ -193,6 +193,11 @@ cil_build_builtin_va_list (void)
return cil32_va_list_type;
}
+/* Build the internal representation of the complex types.
+
+ Each complex type will has a corresponding value type in the gcc4net
+ assembly. */
+
static void
cil_build_complex_types (void)
{
@@ -285,12 +290,19 @@ cil_build_complex_types (void)
}
}
+/* Given the complex type TYPE return the corresponding real or imaginary part
+ * field. */
+
tree
cil_get_builtin_complex_real_fld (tree type)
{
- unsigned HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (type), 1);
+ unsigned HOST_WIDE_INT size;
bool unsignedp;
+ gcc_assert (TREE_CODE (type) == COMPLEX_TYPE);
+ type = TREE_TYPE (type);
+ size = tree_low_cst(TYPE_SIZE (type), 1);
+
if (INTEGRAL_TYPE_P (type))
{
unsignedp = TYPE_UNSIGNED (type);
@@ -341,9 +353,13 @@ cil_get_builtin_complex_real_fld (tree type)
tree
cil_get_builtin_complex_imag_fld (tree type)
{
- unsigned HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (type), 1);
+ unsigned HOST_WIDE_INT size;
bool unsignedp;
+ gcc_assert (TREE_CODE (type) == COMPLEX_TYPE);
+ type = TREE_TYPE (type);
+ size = tree_low_cst(TYPE_SIZE (type), 1);
+
if (INTEGRAL_TYPE_P (type))
{
unsignedp = TYPE_UNSIGNED (type);
diff --git a/gcc/config/cil32/cil-builtins.h b/gcc/config/cil32/cil-builtins.h
index aa373be6143..cefe217da63 100644
--- a/gcc/config/cil32/cil-builtins.h
+++ b/gcc/config/cil32/cil-builtins.h
@@ -52,6 +52,6 @@ extern tree cil_build_builtin_va_list (void);
extern tree cil_get_builtin_complex_real_fld (tree);
extern tree cil_get_builtin_complex_imag_fld (tree);
extern void cil_record_builtin_type (tree);
-extern bool cil_builtin_type_p (tree);
+extern bool cil_builtin_type_p (const_tree);
#endif /* !CIL_BUILTINS_H */
diff --git a/gcc/config/cil32/cil-refs.c b/gcc/config/cil32/cil-refs.c
index bdd35dd6783..0fa82089720 100644
--- a/gcc/config/cil32/cil-refs.c
+++ b/gcc/config/cil32/cil-refs.c
@@ -221,7 +221,7 @@ restartswitch:
break;
case ARRAY_TYPE:
- if (TYPE_DOMAIN (type) && ! ARRAY_TYPE_VARLENGTH (type))
+ if (TYPE_DOMAIN (type) && !ARRAY_TYPE_VARLENGTH (type))
{
tree domain = TYPE_DOMAIN (type);
tree min = TYPE_MIN_VALUE (domain);
@@ -413,7 +413,7 @@ make_valuetype_identifier (tree t)
}
else if (TREE_CODE (t) == ARRAY_TYPE)
{
- gcc_assert (TYPE_DOMAIN (t) && ! ARRAY_TYPE_VARLENGTH (t));
+ gcc_assert (TYPE_DOMAIN (t) && !ARRAY_TYPE_VARLENGTH (t));
tmp_name = append_string (tmp_name, "array?",
&tmp_name_len, &tmp_name_max_len);
tmp_name = append_coded_type (tmp_name, t,
@@ -472,7 +472,7 @@ make_valuetype_identifier (tree t)
static hashval_t
ref_type_hash (const void *ptr)
{
- const tree type = (tree) ptr;
+ const_tree type = (const_tree) ptr;
return (hashval_t) TYPE_UID (type);
}
@@ -481,8 +481,8 @@ ref_type_hash (const void *ptr)
static int
ref_type_eq (const void *ptr1, const void *ptr2)
{
- const tree type1 = (tree) ptr1;
- const tree type2 = (tree) ptr2;
+ const_tree type1 = (const_tree) ptr1;
+ const_tree type2 = (const_tree) ptr2;
return TYPE_UID (type1) == TYPE_UID (type2);
}
@@ -519,7 +519,7 @@ mark_referenced_type (tree t)
/* Incomplete and variable-length arrays are pointers and
they must be dealt with as such. */
case ARRAY_TYPE:
- if (! TYPE_DOMAIN (t) || ARRAY_TYPE_VARLENGTH (t))
+ if (!TYPE_DOMAIN (t) || ARRAY_TYPE_VARLENGTH (t))
break;
case ENUMERAL_TYPE:
@@ -655,7 +655,7 @@ promote_type_for_vararg (tree type)
/* Incomplete and variable-length arrays are pointers and
they must be dealt with as such. */
case ARRAY_TYPE:
- if (! TYPE_DOMAIN (type) || ARRAY_TYPE_VARLENGTH (type))
+ if (!TYPE_DOMAIN (type) || ARRAY_TYPE_VARLENGTH (type))
goto pointer;
case RECORD_TYPE:
@@ -732,7 +732,7 @@ cil_pointer_type_p (tree type)
{
if (TREE_CODE (type) == ARRAY_TYPE)
{
- if (! TYPE_DOMAIN (type) || ARRAY_TYPE_VARLENGTH (type))
+ if (!TYPE_DOMAIN (type) || ARRAY_TYPE_VARLENGTH (type))
return true;
}
else if (POINTER_TYPE_P (type))
@@ -767,7 +767,7 @@ get_integer_type (unsigned int size, bool unsignedp)
static hashval_t
str_ref_hash (const void *ptr)
{
- str_ref ref = (str_ref) ptr;
+ const_str_ref ref = (const_str_ref) ptr;
const char *str = TREE_STRING_POINTER (ref->cst);
hashval_t hash = 0;
size_t len = TREE_STRING_LENGTH (ref->cst);
@@ -792,8 +792,8 @@ str_ref_hash (const void *ptr)
static int
str_ref_eq (const void *ptr1, const void *ptr2)
{
- const char *str1 = TREE_STRING_POINTER (((str_ref) ptr1)->cst);
- const char *str2 = TREE_STRING_POINTER (((str_ref) ptr2)->cst);
+ const char *str1 = TREE_STRING_POINTER (((const_str_ref) ptr1)->cst);
+ const char *str2 = TREE_STRING_POINTER (((const_str_ref) ptr2)->cst);
return str1 == str2;
}
@@ -859,7 +859,7 @@ referenced_strings_htab ( void )
static hashval_t
pinvoke_hash (const void *ptr)
{
- const tree func = (tree) ptr;
+ const_tree func = (const_tree) ptr;
return (hashval_t) DECL_UID (func);
}
@@ -868,8 +868,8 @@ pinvoke_hash (const void *ptr)
static int
pinvoke_eq (const void *ptr1, const void *ptr2)
{
- const tree func1 = (tree) ptr1;
- const tree func2 = (tree) ptr2;
+ const_tree func1 = (const_tree) ptr1;
+ const_tree func2 = (const_tree) ptr2;
return DECL_UID (func1) == DECL_UID (func2);
}
@@ -909,7 +909,7 @@ pinvokes_htab ( void )
static hashval_t
label_addr_hash (const void *ptr)
{
- const label_addr addr = (const label_addr) ptr;
+ const_label_addr addr = (const_label_addr) ptr;
return (hashval_t) LABEL_DECL_UID (addr->label);
}
@@ -918,8 +918,8 @@ label_addr_hash (const void *ptr)
static int
label_addr_eq (const void *ptr1, const void *ptr2)
{
- const label_addr addr1 = (const label_addr) ptr1;
- const label_addr addr2 = (const label_addr) ptr2;
+ const_label_addr addr1 = (const_label_addr) ptr1;
+ const_label_addr addr2 = (const_label_addr) ptr2;
return LABEL_DECL_UID (addr1->label) == LABEL_DECL_UID (addr2->label);
}
@@ -1037,7 +1037,7 @@ create_init_method (void)
/* Allocate memory for the function structure. The call to
allocate_struct_function clobbers CFUN, so we need to restore
it afterward. */
- allocate_struct_function (fun_decl);
+ allocate_struct_function (fun_decl, false);
TREE_STATIC (fun_decl) = 1;
TREE_USED (fun_decl) = 1;
@@ -1067,7 +1067,7 @@ create_init_method (void)
tree_rest_of_compilation (fun_decl);
/* Restore the current function */
- cfun = current_cfun;
+ set_cfun (current_cfun);
}
}
@@ -1280,7 +1280,7 @@ expand_init_to_stmt_list1 (tree decl, tree init,
tree cont_type;
tree shift_cst;
tree tmp;
-
+
get_inner_reference (ltarget, &bit_size, &bit_pos,
&tmp, &mode, &unsignedp,
&volatilep, false);
@@ -1308,7 +1308,7 @@ expand_init_to_stmt_list1 (tree decl, tree init,
/ BITS_PER_UNIT);
offset = tree_low_cst (tmp, 1);
}
-
+
shift_cst = build_int_cst (intSI_type_node, cont_off);
tmp = fold_binary_to_constant (LSHIFT_EXPR, cont_type,
fold_convert (cont_type,
@@ -1326,14 +1326,14 @@ expand_init_to_stmt_list1 (tree decl, tree init,
*((unsigned char *) le_image + offset) |= b0;
*((unsigned char *) be_image + offset) |= b0;
break;
-
+
case 16:
*((unsigned char *) le_image + offset + 0) |= b0;
*((unsigned char *) le_image + offset + 1) |= b1;
*((unsigned char *) be_image + offset + 0) |= b1;
*((unsigned char *) be_image + offset + 1) |= b0;
break;
-
+
case 32:
*((unsigned char *) le_image + offset + 0) |= b0;
*((unsigned char *) le_image + offset + 1) |= b1;
@@ -1344,7 +1344,7 @@ expand_init_to_stmt_list1 (tree decl, tree init,
*((unsigned char *) be_image + offset + 2) |= b1;
*((unsigned char *) be_image + offset + 3) |= b0;
break;
-
+
default:
gcc_unreachable ();
}
diff --git a/gcc/config/cil32/cil-refs.h b/gcc/config/cil32/cil-refs.h
index 4dfeef990dd..bc79de7d645 100644
--- a/gcc/config/cil32/cil-refs.h
+++ b/gcc/config/cil32/cil-refs.h
@@ -44,16 +44,16 @@ Erven Rohou <erven.rohou@st.com>
******************************************************************************/
/* Nonzero for a type which is at file scope. */
-#define TYPE_FILE_SCOPE_P(EXP) \
- (! TYPE_CONTEXT (EXP) \
+#define TYPE_FILE_SCOPE_P(EXP) \
+ (!TYPE_CONTEXT (EXP) \
|| TREE_CODE (TYPE_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL)
/* Nonzero for a zero-length array type */
-#define ARRAY_TYPE_ZEROLENGTH(EXP) \
- (TYPE_SIZE (EXP) == NULL_TREE)
+#define ARRAY_TYPE_ZEROLENGTH(EXP) \
+ ((TYPE_SIZE (EXP) == NULL_TREE) || integer_zerop (TYPE_SIZE (EXP)))
/* Nonzero for a variable-length array type */
-#define ARRAY_TYPE_VARLENGTH(EXP) \
+#define ARRAY_TYPE_VARLENGTH(EXP) \
(TYPE_SIZE (EXP) != NULL_TREE && TREE_CODE (TYPE_SIZE (EXP)) != INTEGER_CST)
/* Length of compacted identifiers (in characters) */
diff --git a/gcc/config/cil32/cil-stmt.h b/gcc/config/cil32/cil-stmt.h
index 5e9426db410..618f3e5a5e1 100644
--- a/gcc/config/cil32/cil-stmt.h
+++ b/gcc/config/cil32/cil-stmt.h
@@ -61,8 +61,8 @@ extern HOST_WIDE_INT cil_switch_case_high (const_cil_stmt, size_t);
static inline enum cil_opcode cil_opcode (const_cil_stmt);
static inline basic_block cil_bb (const_cil_stmt);
static inline void cil_set_bb (cil_stmt, basic_block);
-static inline source_locus cil_locus (const_cil_stmt);
-static inline void cil_set_locus (cil_stmt, source_locus);
+static inline location_t cil_locus (const_cil_stmt);
+static inline void cil_set_locus (cil_stmt, location_t);
static inline tree cil_var (const_cil_stmt);
static inline tree cil_type (const_cil_stmt);
static inline tree cil_field (const_cil_stmt);
@@ -100,8 +100,6 @@ extern bool cil_ldind_p (const_cil_stmt);
extern bool cil_stind_p (const_cil_stmt);
extern bool cil_push_p (const_cil_stmt);
-extern enum cil_arg_type opcode_arg_type (enum cil_opcode);
-
/******************************************************************************
* CIL sequence interface *
******************************************************************************/
diff --git a/gcc/config/cil32/cil-types.h b/gcc/config/cil32/cil-types.h
index ef505db0b97..9b537645775 100644
--- a/gcc/config/cil32/cil-types.h
+++ b/gcc/config/cil32/cil-types.h
@@ -33,6 +33,7 @@ Erven Rohou <erven.rohou@st.com>
#define CIL_TYPES_H
#include "coretypes.h"
+#include "line-map.h"
/******************************************************************************
* Misc types *
@@ -50,6 +51,7 @@ struct str_ref_d GTY(())
};
typedef struct str_ref_d *str_ref;
+typedef const struct str_ref_d *const_str_ref;
/* Mapping for label's whose addresses have been taken. */
@@ -63,6 +65,7 @@ struct label_addr_d GTY(())
};
typedef struct label_addr_d *label_addr;
+typedef const struct label_addr_d *const_label_addr;
/******************************************************************************
* CIL statements *
@@ -191,6 +194,8 @@ enum cil_arg_type
CIL_NONE /* No argument */
};
+extern enum cil_arg_type opcode_arg_type (enum cil_opcode);
+
/* Represents the information provided by a CALL_EXPR when converted to a CIL
CALL or CALLI instruction. The FTYPE fields points to the called function
type, the FDECL field to the function declaration (or NULL_TREE for a CALLI),
@@ -267,7 +272,7 @@ struct cil_stmt_d GTY (())
struct basic_block_def *bb;
/* Original location in the source. */
- struct location_s *locus;
+ source_location locus;
};
typedef struct cil_stmt_d *cil_stmt;
@@ -319,6 +324,7 @@ struct cil_basic_block_d GTY (())
};
typedef struct cil_basic_block_d *cil_basic_block;
+typedef const struct cil_basic_block_d *const_cil_basic_block;
/******************************************************************************
* Per-function target specific global data *
diff --git a/gcc/config/cil32/cil32.c b/gcc/config/cil32/cil32.c
index abce0966f79..1dbfe3beeaa 100644
--- a/gcc/config/cil32/cil32.c
+++ b/gcc/config/cil32/cil32.c
@@ -136,7 +136,7 @@ cil_override_options (void)
static hashval_t
cil_basic_block_hash (const void *ptr)
{
- cil_basic_block cbb = (cil_basic_block) ptr;
+ const_cil_basic_block cbb = (const_cil_basic_block) ptr;
return (hashval_t) ((long) cbb->bb >> 3);
}
@@ -146,8 +146,8 @@ cil_basic_block_hash (const void *ptr)
static int
cil_basic_block_eq (const void *ptr1, const void *ptr2)
{
- cil_basic_block cbb1 = (cil_basic_block) ptr1;
- cil_basic_block cbb2 = (cil_basic_block) ptr2;
+ const_cil_basic_block cbb1 = (const_cil_basic_block) ptr1;
+ const_cil_basic_block cbb2 = (const_cil_basic_block) ptr2;
return cbb1->bb == cbb2->bb;
}
diff --git a/gcc/config/cil32/cil32.md b/gcc/config/cil32/cil32.md
index 89ca838f123..724686ea7af 100644
--- a/gcc/config/cil32/cil32.md
+++ b/gcc/config/cil32/cil32.md
@@ -38,11 +38,11 @@
)
-(define_mode_macro ALLMODES [SI HI QI DI SF DF])
-(define_mode_macro ALLEVALMODES [SI DI SF DF])
-(define_mode_macro ALLINTEVALMODES [SI DI])
+(define_mode_iterator ALLMODES [SI HI QI DI SF DF])
+(define_mode_iterator ALLEVALMODES [SI DI SF DF])
+(define_mode_iterator ALLINTEVALMODES [SI DI])
-(define_mode_macro VECMODES [V8QI V4HI V2SI V4QI V2HI])
+(define_mode_iterator VECMODES [V8QI V4HI V2SI V4QI V2HI])
;; Jump and branch insns.
diff --git a/gcc/config/cil32/emit-cil.c b/gcc/config/cil32/emit-cil.c
index 1e5e128e41c..a4b2be5b974 100644
--- a/gcc/config/cil32/emit-cil.c
+++ b/gcc/config/cil32/emit-cil.c
@@ -93,13 +93,13 @@ static unsigned int compute_max_stack ( void );
static void decode_function_attrs (tree, struct fnct_attr *);
static void emit_enum_decl (FILE *, tree);
static void emit_array_decl (FILE *, tree);
-static void emit_incomplete_decl (FILE *, tree);
+static void emit_incomplete_decl (FILE *, const_tree);
static void emit_struct_union_decl (FILE *, tree);
static void emit_valuetype_decl (FILE *, tree);
static void dump_decl_name (FILE *, tree);
static void dump_string_name (FILE *, tree);
static void dump_label_name (FILE *, tree);
-static void dump_valuetype_name (FILE *, tree);
+static void dump_valuetype_name (FILE *, const_tree);
static void dump_fun_type (FILE *, tree, tree, const char *, bool);
static void dump_vector_type (FILE *, tree, bool);
static void dump_complex_type (FILE *, tree, bool);
@@ -336,7 +336,7 @@ dump_label_name (FILE *file, tree node)
the types emitted as CIL valuetypes. */
static void
-dump_valuetype_name (FILE *file, tree t)
+dump_valuetype_name (FILE *file, const_tree t)
{
tree name = TYPE_NAME (t);
const char *str;
@@ -393,7 +393,7 @@ dump_fun_type (FILE *file, tree fun_type, tree fun, const char *name, bool ref)
tree last_arg_type = NULL;
bool varargs = false;
- gcc_assert (! (fun && name));
+ gcc_assert (!(fun && name));
if (ref)
mark_referenced_type (fun_type);
@@ -612,7 +612,7 @@ emit_array_decl (FILE *file, tree t)
}
static void
-emit_incomplete_decl (FILE *file, tree t)
+emit_incomplete_decl (FILE *file, const_tree t)
{
if (t == NULL_TREE || t == error_mark_node)
return;
@@ -851,8 +851,8 @@ dump_string_type (FILE *file, tree node)
tree max;
gcc_assert(TREE_CODE (node) == ARRAY_TYPE
- && TYPE_DOMAIN (node)
- && ! ARRAY_TYPE_VARLENGTH (node));
+ && TYPE_DOMAIN (node)
+ && !ARRAY_TYPE_VARLENGTH (node));
domain = TYPE_DOMAIN (node);
min = TYPE_MIN_VALUE (domain);
@@ -1026,9 +1026,9 @@ emit_referenced_strings (void)
}
static bool
-emit_incomplete_type (void *elem, void *data)
+emit_incomplete_type (const void *elem, void *data)
{
- tree type = (tree) elem;
+ const_tree type = (const_tree) elem;
tree type_name = TYPE_NAME (type);
struct pointer_set_t *emitted_types = data;
@@ -1137,29 +1137,29 @@ emit_referenced_pinvokes (void)
static void
emit_prefixes (FILE *file, const_cil_stmt stmt)
{
- enum cil_opcode opcode = cil_opcode (stmt);
+ enum cil_opcode opcode = cil_opcode (stmt);
- if ((opcode == CIL_CALL) || (opcode == CIL_CALLI))
+ if ((opcode == CIL_CALL) || (opcode == CIL_CALLI))
{
- if (cil_prefix_tail (stmt))
- fprintf (file, "\n\ttail.");
+ if (cil_prefix_tail (stmt))
+ fprintf (file, "\n\ttail.");
}
- else if ((opcode == CIL_CPBLK) || (opcode == CIL_INITBLK)
- || ((opcode >= CIL_LDIND_I1) && (opcode <= CIL_LDIND_I))
- || ((opcode >= CIL_STIND_I1) && (opcode <= CIL_STIND_I))
- || (opcode == CIL_LDFLD) || (opcode == CIL_STFLD))
+ else if ((opcode == CIL_CPBLK) || (opcode == CIL_INITBLK)
+ || ((opcode >= CIL_LDIND_I1) && (opcode <= CIL_LDIND_I))
+ || ((opcode >= CIL_STIND_I1) && (opcode <= CIL_STIND_I))
+ || (opcode == CIL_LDFLD) || (opcode == CIL_STFLD))
{
- if (cil_prefix_unaligned (stmt) != 0)
- fprintf (file, "\n\tunaligned. %d", cil_prefix_unaligned (stmt));
+ if (cil_prefix_unaligned (stmt) != 0)
+ fprintf (file, "\n\tunaligned. %d", cil_prefix_unaligned (stmt));
}
- else if ((opcode == CIL_CPBLK) || (opcode == CIL_INITBLK)
- || ((opcode >= CIL_LDIND_I1) && (opcode <= CIL_LDIND_I))
- || ((opcode >= CIL_STIND_I1) && (opcode <= CIL_STIND_I))
- || (opcode == CIL_LDFLD) || (opcode == CIL_STFLD)
- || (opcode == CIL_LDSFLD) || (opcode == CIL_STSFLD))
+ else if ((opcode == CIL_CPBLK) || (opcode == CIL_INITBLK)
+ || ((opcode >= CIL_LDIND_I1) && (opcode <= CIL_LDIND_I))
+ || ((opcode >= CIL_STIND_I1) && (opcode <= CIL_STIND_I))
+ || (opcode == CIL_LDFLD) || (opcode == CIL_STFLD)
+ || (opcode == CIL_LDSFLD) || (opcode == CIL_STSFLD))
{
- if (cil_prefix_volatile (stmt))
- fprintf (file, "\n\tvolatile.");
+ if (cil_prefix_volatile (stmt))
+ fprintf (file, "\n\tvolatile.");
}
}
@@ -1332,7 +1332,7 @@ emit_switch (FILE *file, const_cil_stmt stmt)
hi = cil_switch_case_high (stmt, i);
for (j = lo; j <= hi; j++)
- labels[j - offset] = cil_switch_case_label (stmt, i);
+ labels[j - offset] = cil_switch_case_label (stmt, i);
}
/* Fill the empty slots in the array with the default case label. */
@@ -1445,7 +1445,7 @@ emit_builtin_call (FILE *file, const_cil_stmt call)
default:
/* Go Ahead as a normal function call */
- return false;
+ return false;
}
}
@@ -2255,10 +2255,10 @@ emit_local_vars (FILE *file)
VEC_pop (var_uses_s, locals);
if (DECL_NAME (var) != NULL_TREE)
- rename_var (var, DECL_FROM_INLINE (var) ? "?in" : "?", i);
+ rename_var (var, DECL_FROM_INLINE (var) ? "?in" : "?", i);
if (i != 0)
- fprintf (file, ", ");
+ fprintf (file, ", ");
dump_type (file, promote_local_var_type (var), true, false);
fprintf (file, " ");
@@ -2302,7 +2302,7 @@ emit_function_header (FILE *file)
varargs ? "vararg " : "");
dump_type (file, TREE_TYPE (TREE_TYPE (current_function_decl)), true, false);
fprintf (file, " '%s' (",
- lang_hooks.decl_printable_name (current_function_decl, 1));
+ lang_hooks.decl_printable_name (current_function_decl, 1));
args = DECL_ARGUMENTS (current_function_decl);
@@ -2325,7 +2325,7 @@ emit_function_header (FILE *file)
dump_type (file, promote_type_for_vararg (DECL_ARG_TYPE (args)),
true, true);
}
- }
+ }
else
dump_type (file, DECL_ARG_TYPE (args), true, true);
@@ -2526,7 +2526,7 @@ emit_vcg_init (void)
{
if (TARGET_EMIT_VCG)
fputs ("graph: {\n"
- "display_edge_labels: yes\n", stdout);
+ "display_edge_labels: yes\n", stdout);
}
void
diff --git a/gcc/config/cil32/emit-hints.c b/gcc/config/cil32/emit-hints.c
index cad7ff3682b..b31bed293b1 100644
--- a/gcc/config/cil32/emit-hints.c
+++ b/gcc/config/cil32/emit-hints.c
@@ -167,17 +167,17 @@ branch_probability_emit_and_reset (FILE *file)
/* Emit */
fprintf (file,
- "\n\t.custom instance void class [gcc4net]gcc4net."
- "JitCompilationHints.BranchProbabilitiesAttribute::.ctor("
- "unsigned int8[]) = (01 00 %02x %02x %02x %02x",
- length & 0xff,
- (length >> 8) & 0xff,
- (length >> 16) & 0xff,
- (length >> 24) & 0xff);
+ "\n\t.custom instance void class [gcc4net]gcc4net."
+ "JitCompilationHints.BranchProbabilitiesAttribute::.ctor("
+ "unsigned int8[]) = (01 00 %02x %02x %02x %02x",
+ length & 0xff,
+ (length >> 8) & 0xff,
+ (length >> 16) & 0xff,
+ (length >> 24) & 0xff);
+
for (n = branch_prob_list_head; n; n = n->next)
- {
- fprintf (file, " %02x", n->branch_prob * 256 / REG_BR_PROB_BASE);
- }
+ fprintf (file, " %02x", n->branch_prob * 256 / REG_BR_PROB_BASE);
+
fputs (" 00 00 ) ", file);
/* Free the list */
@@ -203,10 +203,10 @@ dump_compressed_int (FILE *file, unsigned int val)
fprintf (file, "%02x %02x ", (val >> 8) | 0x80, val & 0xff);
else
fprintf (file, "%02x %02x %02x %02x ",
- (val >> 24) | 0xa0,
- (val & 0xffffff) >> 16,
- (val & 0xffff) >> 8,
- val & 0xff);
+ (val >> 24) | 0xa0,
+ (val & 0xffffff) >> 16,
+ (val & 0xffff) >> 8,
+ val & 0xff);
}
static void
@@ -244,31 +244,33 @@ basic_block_frequency_emit (FILE *file)
The count is initialized with the number of GIMPLE blocks
minus the entry and the exit. Then, the number is:
-) incremented in case of basic blocks ending with a
- COND_EXPR statement in which the ELSE clause is not
- a fall-through; as a matter of fact, in this case a
- single GIMPLE basic block is emitted as two basic blocks.
+ COND_EXPR statement in which the ELSE clause is not
+ a fall-through; as a matter of fact, in this case a
+ single GIMPLE basic block is emitted as two basic blocks.
-) decremented in case of an empty basic block; as a matter
- of fact, in this case no basic block is emitted for
- a GIMPLE basic block. */
+ of fact, in this case no basic block is emitted for
+ a GIMPLE basic block. */
FOR_EACH_BB (bb)
{
block_stmt_iterator last_bsi = bsi_last (bb);
if (bsi_end_p (last_bsi))
- --emitted_bbs;
+ --emitted_bbs;
else
- {
- tree last = bsi_stmt (last_bsi);
-
- if (TREE_CODE (last) == COND_EXPR) {
- edge true_edge;
- edge false_edge;
- extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
- if (false_edge->dest != bb->next_bb)
- ++emitted_bbs;
- }
- }
+ {
+ tree last = bsi_stmt (last_bsi);
+
+ if (TREE_CODE (last) == COND_EXPR)
+ {
+ edge true_edge;
+ edge false_edge;
+ extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
+
+ if (false_edge->dest != bb->next_bb)
+ ++emitted_bbs;
+ }
+ }
}
/* Allocate memory for basic block frequencies bit stream */
@@ -277,14 +279,14 @@ basic_block_frequency_emit (FILE *file)
/* Emit number of basic blocks */
fprintf (file,
- "\n\t.custom instance void class "
- "[gcc4net]gcc4net.JitCompilationHints."
- "BasicBlockFrequenciesAttribute::.ctor(unsigned int8[]) = "
- "(01 00 %02x %02x %02x %02x ",
- emitted_bbs & 0xff,
- (emitted_bbs >> 8) & 0xff,
- (emitted_bbs >> 16) & 0xff,
- (emitted_bbs >> 24) & 0xff);
+ "\n\t.custom instance void class "
+ "[gcc4net]gcc4net.JitCompilationHints."
+ "BasicBlockFrequenciesAttribute::.ctor(unsigned int8[]) = "
+ "(01 00 %02x %02x %02x %02x ",
+ emitted_bbs & 0xff,
+ (emitted_bbs >> 8) & 0xff,
+ (emitted_bbs >> 16) & 0xff,
+ (emitted_bbs >> 24) & 0xff);
/* Emit frequency for each basic block.
Beware that some GIMPLE blocks are emitted as two blocks! */
@@ -302,36 +304,36 @@ basic_block_frequency_emit (FILE *file)
freq_class = (bb->frequency * 15 * 256 / BB_FREQ_MAX) / 256;
gcc_assert (freq_class >= 0 && freq_class < 16);
bit_stream_emitter_push_bits (&bse,
- coding[freq_class].num_bits,
- coding[freq_class].code);
+ coding[freq_class].num_bits,
+ coding[freq_class].code);
if (TREE_CODE (bsi_stmt (last_bsi)) == COND_EXPR)
- {
- edge true_edge;
- edge false_edge;
- basic_block dest_bb;
-
- extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
- dest_bb = false_edge->dest;
-
- if (dest_bb != bb->next_bb)
- {
- edge split_edge = find_edge (bb, dest_bb);
- int new_bb_frequency;
-
- gcc_assert (split_edge);
- new_bb_frequency =
- (bb->frequency * split_edge->probability) / REG_BR_PROB_BASE;
- fprintf (file, "%02x ",
- new_bb_frequency * 100 / BB_FREQ_MAX);
-
- freq_class = (new_bb_frequency * 15 * 256 / BB_FREQ_MAX) / 256;
- gcc_assert (freq_class >= 0 && freq_class < 16);
- bit_stream_emitter_push_bits (&bse,
- coding[freq_class].num_bits,
- coding[freq_class].code);
- }
- }
+ {
+ edge true_edge;
+ edge false_edge;
+ basic_block dest_bb;
+
+ extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
+ dest_bb = false_edge->dest;
+
+ if (dest_bb != bb->next_bb)
+ {
+ edge split_edge = find_edge (bb, dest_bb);
+ int new_bb_frequency;
+
+ gcc_assert (split_edge);
+ new_bb_frequency =
+ (bb->frequency * split_edge->probability) / REG_BR_PROB_BASE;
+ fprintf (file, "%02x ",
+ new_bb_frequency * 100 / BB_FREQ_MAX);
+
+ freq_class = (new_bb_frequency * 15 * 256 / BB_FREQ_MAX) / 256;
+ gcc_assert (freq_class >= 0 && freq_class < 16);
+ bit_stream_emitter_push_bits (&bse,
+ coding[freq_class].num_bits,
+ coding[freq_class].code);
+ }
+ }
}
bit_stream_emitter_pad_byte (&bse);
@@ -340,12 +342,14 @@ basic_block_frequency_emit (FILE *file)
fputs ("00 00 ) ", file);
fputs ("\n\t.custom instance void class "
- "[gcc4net]gcc4net.JitCompilationHints."
- "JITMethodAttribute::.ctor(unsigned int8*, unsigned int8 *) = (01 00 ",
+ "[gcc4net]gcc4net.JitCompilationHints."
+ "JITMethodAttribute::.ctor(unsigned int8*, unsigned int8 *) = (01 00 ",
file);
dump_compressed_int (file, emitted_bbs);
+
for (tmp_ptr = start_bb_freq_coded; tmp_ptr < bb_freq_coded; ++tmp_ptr)
fprintf (file, "%02x ", *tmp_ptr);
+
fputs ("00 00/*,*/ 01 00 ", file);
/* Free memory for basic block frequencies bit stream */
@@ -354,6 +358,7 @@ basic_block_frequency_emit (FILE *file)
/* Calculate the length of the branch probability list */
branch_prob_list_length = 0;
+
for (n = branch_prob_list_head; n; n = n->next)
++branch_prob_list_length;
@@ -365,12 +370,13 @@ basic_block_frequency_emit (FILE *file)
for (n = branch_prob_list_head; n; n = n->next)
{
int prob_class =
- ((n->branch_prob * 256 - REG_BR_PROB_BASE * 256 / 16)
- * 7 / REG_BR_PROB_BASE) / 256;
+ ((n->branch_prob * 256 - REG_BR_PROB_BASE * 256 / 16)
+ * 7 / REG_BR_PROB_BASE) / 256;
gcc_assert (prob_class >= -1 && prob_class <= 7);
+
if (prob_class < 0)
- prob_class = 0;
+ prob_class = 0;
bit_stream_emitter_push_bits (&bse, 3, prob_class);
}
diff --git a/gcc/config/cil32/gimple-to-cil.c b/gcc/config/cil32/gimple-to-cil.c
index 6e81dc38c4d..a4ddaeda438 100644
--- a/gcc/config/cil32/gimple-to-cil.c
+++ b/gcc/config/cil32/gimple-to-cil.c
@@ -69,6 +69,7 @@ static void gen_ldind (cil_stmt_iterator *, tree, bool);
static void gen_stind (cil_stmt_iterator *, tree, bool);
static void gen_bit_field_modify_expr (cil_stmt_iterator *, tree, tree);
static void gen_target_mem_ref_modify_expr (cil_stmt_iterator *, tree, tree);
+static void gen_bitfield_ref_modify_expr (cil_stmt_iterator *, tree, tree);
static void gen_vector_bitfield_ref_modify_expr (cil_stmt_iterator *,
tree, tree);
static void gen_modify_expr (cil_stmt_iterator *, tree, tree);
@@ -93,7 +94,7 @@ static void gen_vector_bitfield_ref (cil_stmt_iterator *, tree);
static void gen_bit_field_ref (cil_stmt_iterator *, tree);
static void gen_truth_expr (cil_stmt_iterator *, tree);
static void gen_target_mem_ref (cil_stmt_iterator *, tree);
-static void gen_view_convert_expr (cil_stmt_iterator *, tree);
+static void gen_vector_view_convert_expr (cil_stmt_iterator *, tree, tree);
static void gen_complex_part_expr (cil_stmt_iterator *, tree);
static void gen_complex (cil_stmt_iterator *, tree, tree, tree);
static enum cil_opcode conv_opcode_from_type (tree);
@@ -215,25 +216,48 @@ gen_addr_expr (cil_stmt_iterator *csi, tree node)
case VIEW_CONVERT_EXPR:
gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
+ csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
break;
case REALPART_EXPR:
case IMAGPART_EXPR:
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
+ {
+ tree obj = GENERIC_TREE_OPERAND (node, 0);
+ tree type = TREE_TYPE (obj);
- if (TREE_CODE (node) == IMAGPART_EXPR)
- {
- gen_integer_cst (csi,
- fold_convert (intSI_type_node,
- TYPE_SIZE_UNIT (TREE_TYPE (node))));
- stmt = cil_build_stmt (CIL_ADD);
- csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
- }
+ gen_addr_expr (csi, obj);
+ if (TREE_CODE (node) == REALPART_EXPR)
+ {
+ stmt = cil_build_stmt_arg (CIL_LDFLDA,
+ cil_get_builtin_complex_real_fld (type));
+ }
+ else
+ {
+ stmt = cil_build_stmt_arg (CIL_LDFLDA,
+ cil_get_builtin_complex_imag_fld (type));
+ }
+
+ csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+ }
break;
default:
- gcc_unreachable ();
+ {
+ /* A generic expression, we first evaluate it, then store it inside a
+ temporary and finally get the address of said temporary. */
+ tree tmp_var;
+
+ tmp_var = create_tmp_var (TREE_TYPE (node), "addr_expr");
+ gimple_to_cil_node (csi, node);
+ stmt = cil_build_stmt_arg (CIL_STLOC, tmp_var);
+ csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+ stmt = cil_build_stmt_arg (CIL_LDLOCA, tmp_var);
+ csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+ stmt = cil_build_stmt (CIL_CONV_I);
+ csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+ break;
+ }
}
}
@@ -554,6 +578,49 @@ gen_target_mem_ref_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
gen_stind (csi, type, TREE_THIS_VOLATILE (lhs));
}
+/* Generates a MODIFY_EXPR using a BIT_FIELD_REF scalar access as its LHS
+ operand. */
+
+static void
+gen_bitfield_ref_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
+{
+ HOST_WIDE_INT bit_size = 0;
+ HOST_WIDE_INT bit_pos = 0;
+ tree offset = NULL_TREE;
+ enum machine_mode mode;
+ int unsignedp = 0;
+ int volatilep = 0;
+ cil_stmt stmt;
+ tree ref;
+
+ /* Get the object base address and emit it. */
+ ref = get_inner_reference (lhs, &bit_size, &bit_pos, &offset, &mode,
+ &unsignedp, &volatilep, false);
+ gen_addr_expr (csi, ref);
+ csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
+
+ /* Calculate the container address if needed. */
+ if (bit_pos / BITS_PER_UNIT != 0)
+ {
+ gen_integer_cst (csi,
+ build_int_cst (intSI_type_node,
+ bit_pos / BITS_PER_UNIT));
+ stmt = cil_build_stmt (CIL_ADD);
+ csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+ }
+
+ if (offset != NULL_TREE)
+ {
+ gimple_to_cil_node (csi, offset);
+ stmt = cil_build_stmt (CIL_ADD);
+ csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+ }
+
+ /* Put the new value on the stack and store the field. */
+ gimple_to_cil_node (csi, rhs);
+ gen_scalar_stind (csi, TREE_TYPE (rhs), volatilep);
+}
+
/* Generates a MODIFY_EXPR using a BIT_FIELD_REF scalar-element vector access
as its LHS operand. */
@@ -641,8 +708,8 @@ gen_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
case COMPONENT_REF:
{
- tree obj = TREE_OPERAND (lhs, 0);
- tree fld = TREE_OPERAND (lhs, 1);
+ tree obj = GENERIC_TREE_OPERAND (lhs, 0);
+ tree fld = GENERIC_TREE_OPERAND (lhs, 1);
mark_referenced_type (TYPE_MAIN_VARIANT (TREE_TYPE (obj)));
@@ -670,17 +737,7 @@ gen_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
case REALPART_EXPR:
case IMAGPART_EXPR:
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (lhs, 0));
-
- if (TREE_CODE (lhs) == IMAGPART_EXPR)
- {
- gen_integer_cst (csi,
- fold_convert (intSI_type_node,
- TYPE_SIZE_UNIT (TREE_TYPE (lhs))));
- stmt = cil_build_stmt (CIL_ADD);
- csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
- }
-
+ gen_addr_expr (csi, lhs);
gimple_to_cil_node (csi, rhs);
gen_scalar_stind (csi, TREE_TYPE (lhs), TREE_THIS_VOLATILE (lhs));
break;
@@ -689,7 +746,7 @@ gen_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
if (TREE_CODE (TREE_TYPE (GENERIC_TREE_OPERAND (lhs, 0))) == VECTOR_TYPE)
gen_vector_bitfield_ref_modify_expr (csi, lhs, rhs);
else
- gcc_unreachable ();
+ gen_bitfield_ref_modify_expr (csi, lhs, rhs);
break;
@@ -754,8 +811,8 @@ gen_cond_expr (cil_stmt_iterator *csi, tree node)
}
else
{
- lhs = TREE_OPERAND (cond, 0);
- rhs = TREE_OPERAND (cond, 1);
+ lhs = GENERIC_TREE_OPERAND (cond, 0);
+ rhs = GENERIC_TREE_OPERAND (cond, 1);
type = TREE_TYPE (lhs);
switch (TREE_CODE (cond))
@@ -1846,7 +1903,7 @@ gen_minmax_expr (cil_stmt_iterator *csi, tree node)
bool unsignedp;
enum cil32_builtin builtin = 0;
- gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
if (POINTER_TYPE_P (type))
{
@@ -1854,7 +1911,7 @@ gen_minmax_expr (cil_stmt_iterator *csi, tree node)
csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
}
- gimple_to_cil_node (csi, TREE_OPERAND (node, 1));
+ gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 1));
if (POINTER_TYPE_P (type))
{
@@ -1915,7 +1972,7 @@ gen_abs_expr (cil_stmt_iterator *csi, tree node)
gcc_assert (!TARGET_EXPAND_ABS);
- gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
if (INTEGRAL_TYPE_P (type))
{
@@ -2006,6 +2063,7 @@ gen_bit_field_comp_ref (cil_stmt_iterator *csi, tree node)
/* Get the object base address and emit it. */
ref = get_inner_reference (node, &bit_size, &bit_pos, &offset, &mode,
&unsignedp, &volatilep, false);
+
gen_addr_expr (csi, ref);
csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
@@ -2086,8 +2144,8 @@ gen_bit_field_comp_ref (cil_stmt_iterator *csi, tree node)
static void
gen_comp_ref (cil_stmt_iterator *csi, tree node)
{
- tree obj = TREE_OPERAND (node, 0);
- tree fld = TREE_OPERAND (node, 1);
+ tree obj = GENERIC_TREE_OPERAND (node, 0);
+ tree fld = GENERIC_TREE_OPERAND (node, 1);
cil_stmt stmt;
gcc_assert (TREE_CODE (fld) == FIELD_DECL);
@@ -2217,8 +2275,8 @@ gen_bit_field_ref (cil_stmt_iterator *csi, tree node)
static void
gen_truth_expr (cil_stmt_iterator *csi, tree node)
{
- tree op0 = TREE_OPERAND (node, 0);
- tree op1 = TREE_OPERAND (node, 1);
+ tree op0 = GENERIC_TREE_OPERAND (node, 0);
+ tree op1 = GENERIC_TREE_OPERAND (node, 1);
cil_stmt stmt;
gimple_to_cil_node (csi, op0);
@@ -2283,16 +2341,15 @@ gen_target_mem_ref (cil_stmt_iterator *csi, tree node)
gen_ldind (csi, type, TREE_THIS_VOLATILE (node));
}
-/* Generates CIL code for a VIEW_CONVERT_EXPR held in the tree NODE. The
- generated statements are appended to the current function's CIL code using
- the CSI iterator. */
+/* Generates CIL code for a VIEW_CONVERT_EXPR working on the operand held by
+ NODE to the destination type DEST_TYPE with either the type of NODE or
+ DEST_TYPE or both being vector types. The generated statements are appended
+ to the current function's CIL code using the CSI iterator. */
static void
-gen_view_convert_expr (cil_stmt_iterator *csi, tree node)
+gen_vector_view_convert_expr (cil_stmt_iterator *csi, tree dest_type, tree node)
{
- tree op0 = TREE_OPERAND (node, 0);
- tree dest_type = TREE_TYPE (node);
- tree src_type = TREE_TYPE (op0);
+ tree src_type = TREE_TYPE (node);
tree elem_type;
unsigned HOST_WIDE_INT dest_size = tree_low_cst (TYPE_SIZE (dest_type), 1);
unsigned HOST_WIDE_INT src_size = tree_low_cst (TYPE_SIZE (src_type), 1);
@@ -2301,7 +2358,7 @@ gen_view_convert_expr (cil_stmt_iterator *csi, tree node)
enum cil32_builtin builtin = CIL32_MAX_BUILT_IN; /* Placeholder */
cil_stmt stmt;
- gimple_to_cil_node (csi, op0);
+ gimple_to_cil_node (csi, node);
if (TREE_CODE (src_type) == VECTOR_TYPE)
{
@@ -2346,7 +2403,7 @@ gen_view_convert_expr (cil_stmt_iterator *csi, tree node)
}
}
}
- else if (TREE_CODE (dest_type) == VECTOR_TYPE)
+ else
{
/* Convert something to a vector type */
elem_type = TREE_TYPE (dest_type);
@@ -2390,7 +2447,7 @@ gen_complex_part_expr (cil_stmt_iterator *csi, tree node)
{
cil_stmt stmt;
tree op0 = GENERIC_TREE_OPERAND (node, 0);
- tree type = TREE_TYPE (node);
+ tree type = TREE_TYPE (op0);
if (TREE_CODE (op0) == COMPLEX_EXPR)
{
@@ -2656,12 +2713,12 @@ gen_rotate (cil_stmt_iterator *csi, tree node)
/* Rotation is replaced by shifts on unsigned values:
generate the unsigned version of first operand type. */
- op0 = TREE_OPERAND (node, 0);
+ op0 = GENERIC_TREE_OPERAND (node, 0);
uns_type = unsigned_type_for (TREE_TYPE (op0));
op0 = fold_convert (uns_type, op0);
/* Convert the second operand to 32-bit. */
- op1 = fold_convert (intSI_type_node, TREE_OPERAND (node, 1));
+ op1 = fold_convert (intSI_type_node, GENERIC_TREE_OPERAND (node, 1));
/* Build first shift. */
t1 = fold_build2 (left ? LSHIFT_EXPR : RSHIFT_EXPR, uns_type, op0, op1);
@@ -2843,8 +2900,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case MINUS_EXPR:
case RDIV_EXPR:
case LSHIFT_EXPR:
- op0 = TREE_OPERAND (node, 0);
- op1 = TREE_OPERAND (node, 1);
+ op0 = GENERIC_TREE_OPERAND (node, 0);
+ op1 = GENERIC_TREE_OPERAND (node, 1);
gimple_to_cil_node (csi, op0);
@@ -2876,8 +2933,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
- op0 = TREE_OPERAND (node, 0);
- op1 = TREE_OPERAND (node, 1);
+ op0 = GENERIC_TREE_OPERAND (node, 0);
+ op1 = GENERIC_TREE_OPERAND (node, 1);
gimple_to_cil_node (csi, op0);
gimple_to_cil_node (csi, op1);
@@ -2924,8 +2981,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case TRUNC_DIV_EXPR:
case TRUNC_MOD_EXPR:
case RSHIFT_EXPR:
- op0 = TREE_OPERAND (node, 0);
- op1 = TREE_OPERAND (node, 1);
+ op0 = GENERIC_TREE_OPERAND (node, 0);
+ op1 = GENERIC_TREE_OPERAND (node, 1);
uns = TYPE_UNSIGNED (TREE_TYPE (node));
gimple_to_cil_node (csi, op0);
@@ -2963,8 +3020,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
{
bool is_signed0, is_signed1;
- op0 = TREE_OPERAND (node, 0);
- op1 = TREE_OPERAND (node, 1);
+ op0 = GENERIC_TREE_OPERAND (node, 0);
+ op1 = GENERIC_TREE_OPERAND (node, 1);
gimple_to_cil_node (csi, op0);
gimple_to_cil_node (csi, op1);
@@ -2990,7 +3047,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case NEGATE_EXPR:
case BIT_NOT_EXPR:
- gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
if (POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 0))))
{
@@ -3049,7 +3106,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case RETURN_EXPR:
- op0 = TREE_OPERAND (node, 0);
+ op0 = GENERIC_TREE_OPERAND (node, 0);
if (op0 != NULL_TREE)
{
@@ -3127,7 +3184,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case ADDR_EXPR:
- gen_addr_expr (csi, TREE_OPERAND (node, 0));
+ gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
break;
case COMPONENT_REF:
@@ -3135,7 +3192,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case TRUTH_NOT_EXPR:
- gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
gen_integer_cst (csi, integer_zero_node);
stmt = cil_build_stmt (CIL_CEQ);
csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
@@ -3148,7 +3205,32 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case VIEW_CONVERT_EXPR:
- gen_view_convert_expr (csi, node);
+ {
+ /* VIEW_CONVERT_EXPRs may be redundant, check the type of the innermost
+ object and emit code only if it differs from the topmost conversion.
+ */
+ tree op0 = GENERIC_TREE_OPERAND (node, 0);
+ tree dest_type = TREE_TYPE (node);
+ tree src_type;
+
+ while (TREE_CODE (op0) == VIEW_CONVERT_EXPR)
+ op0 = GENERIC_TREE_OPERAND (op0, 0);
+
+ src_type = TREE_TYPE (op0);
+
+ if (src_type == dest_type)
+ gimple_to_cil_node (csi, op0);
+ else if ((TREE_CODE (src_type) == VECTOR_TYPE)
+ || (TREE_CODE (dest_type) == VECTOR_TYPE))
+ {
+ gen_vector_view_convert_expr (csi, dest_type, op0);
+ }
+ else
+ {
+ gen_addr_expr (csi, node);
+ gen_ldind (csi, dest_type, TREE_THIS_VOLATILE (node));
+ }
+ }
break;
case REALPART_EXPR:
@@ -3333,7 +3415,7 @@ gimple_to_cil (void)
}
for (; !csi_end_p (prev_csi); csi_next (&prev_csi))
- cil_set_locus (csi_stmt (prev_csi), EXPR_LOCUS (node));
+ cil_set_locus (csi_stmt (prev_csi), EXPR_LOCATION (node));
}
if ((!node || (TREE_CODE (node) != COND_EXPR)) && single_succ_p (bb))
@@ -3349,7 +3431,8 @@ gimple_to_cil (void)
tree label = tree_block_label (succ);
stmt = cil_build_stmt_arg (CIL_BR, label);
- cil_set_locus (stmt, node ? EXPR_LOCUS (node) : NULL);
+ cil_set_locus (stmt,
+ node ? EXPR_LOCATION (node) : UNKNOWN_LOCATION);
csi_insert_after (&csi, stmt, CSI_CONTINUE_LINKING);
}
}
diff --git a/gcc/config/cil32/tree-simp-cil-early.c b/gcc/config/cil32/tree-simp-cil-early.c
index fe12b771f90..e43503e8059 100644
--- a/gcc/config/cil32/tree-simp-cil-early.c
+++ b/gcc/config/cil32/tree-simp-cil-early.c
@@ -59,7 +59,7 @@ struct eqv_label_entry_t
/* Label manipulation functions */
static bool is_eqv_label (tree, tree);
static void group_labels (tree);
-static bool eqv_label_dispose (void *, void **, void *data);
+static bool eqv_label_dispose (const void *, void **, void *data);
/* Switch-conversion functions */
static void merge_cases_into_ranges (tree);
@@ -169,7 +169,7 @@ group_labels (tree func)
/* Used in pointer_map_traverse () to free eqv_label_t entries */
static bool
-eqv_label_dispose (void *key ATTRIBUTE_UNUSED, void **value,
+eqv_label_dispose (const void *key ATTRIBUTE_UNUSED, void **value,
void *data ATTRIBUTE_UNUSED)
{
XDELETE (*value);
@@ -253,7 +253,7 @@ merge_cases_into_ranges (tree switch_stmt)
length of the vector. */
for (i = 0, j = 0; i < new_size; i++)
{
- while (! TREE_VEC_ELT (labels, j))
+ while (!TREE_VEC_ELT (labels, j))
j++;
TREE_VEC_ELT (labels, i) = TREE_VEC_ELT (labels, j++);