aboutsummaryrefslogtreecommitdiff
path: root/libmudflap/ChangeLog
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2013-03-13 21:57:30 +0000
committerDiego Novillo <dnovillo@google.com>2013-03-13 21:57:30 +0000
commitf13a2ceb6b815892f592d14cf87edf1c17383457 (patch)
tree6a44fa653c7803af6421b09fdf6a5d4c30a9f1e9 /libmudflap/ChangeLog
parent1c1969a1a345eb614a1d097e74d2a8a5f45c289f (diff)
This patch adds an initial implementation for a new helper type for
generating GIMPLE statements. The type is called gimple_builder. There are two main variants: gimple_builder_normal and gimple_builder_ssa. The difference between the two is the temporaries they create. The 'normal' builder creates temporaries in normal form (i.e., VAR_DECLs). The 'ssa' builder creates SSA names. The basic functionality is described in http://gcc.gnu.org/wiki/cxx-conversion/gimple-generation. I expect it to evolve as I address feedback on this initial implementation. The patch implements the initial builder. It has enough functionality to simplify the generation of 3 address assignments (the bulk of all generated code). To use the builder: 1- Declare an instance 'gb' of gimple_builder_normal or gimple_builder_ssa. E.g., gimple_builder_ssa gb; 2- Use gb.add_* to add a new statement to it. This returns an SSA name or VAR_DECL with the value of the added statement. 3- Call gb.insert_*() to insert the sequence of statements in the builder into a statement iterator. For instance, in asan.c we generate the expression: (shadow != 0) & (base_addr & 7) + (size_in_bytes - 1)) >= shadow). with the following code: ----------------------------------------------------------------------------- gimple_builder_ssa gb(location); t = gb.add (NE_EXPR, shadow, 0); tree t1 = gb.add (BIT_AND_EXPR, base_addr, 7); t1 = gb.add_type_cast (shadow_type, t1); if (size_in_bytes > 1) t1 = gb.add (PLUS_EXPR, t1, size_in_bytes - 1); t1 = gb.add (GE_EXPR, t1, shadow); t = gb.add (BIT_AND_EXPR, t, t1); gb.insert_after (&gsi, GSI_NEW_STMT); ----------------------------------------------------------------------------- In contrast, the original code needed to generate the same expression is significantly longer: ----------------------------------------------------------------------------- g = gimple_build_assign_with_ops (NE_EXPR, make_ssa_name (boolean_type_node, NULL), shadow, build_int_cst (shadow_type, 0)); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); t = gimple_assign_lhs (g); g = gimple_build_assign_with_ops (BIT_AND_EXPR, make_ssa_name (uintptr_type, NULL), base_addr, build_int_cst (uintptr_type, 7)); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); g = gimple_build_assign_with_ops (NOP_EXPR, make_ssa_name (shadow_type, NULL), gimple_assign_lhs (g), NULL_TREE); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); if (size_in_bytes > 1) { g = gimple_build_assign_with_ops (PLUS_EXPR, make_ssa_name (shadow_type, NULL), gimple_assign_lhs (g), build_int_cst (shadow_type, size_in_bytes - 1)); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); } g = gimple_build_assign_with_ops (GE_EXPR, make_ssa_name (boolean_type_node, NULL), gimple_assign_lhs (g), shadow); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); g = gimple_build_assign_with_ops (BIT_AND_EXPR, make_ssa_name (boolean_type_node, NULL), t, gimple_assign_lhs (g)); gimple_set_location (g, location); gsi_insert_after (&gsi, g, GSI_NEW_STMT); t = gimple_assign_lhs (g); ----------------------------------------------------------------------------- I expect to add more facilities to the builder. Mainly, generation of control flow altering statements which will automatically reflect on the CFG. I do not think the helper should replace all code generation, but it should serve as a shorter/simpler way of generating GIMPLE IL in the common cases. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/cxx-conversion@196640 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libmudflap/ChangeLog')
0 files changed, 0 insertions, 0 deletions