summaryrefslogtreecommitdiffhomepage
path: root/ir/be/begnuas.c
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2018-05-31 14:08:59 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2018-05-31 14:09:14 +0200
commit3ed52021390f193cef8a317f3d1637df7296203d (patch)
tree2e8839bd80487432269120e85da8cefef2511f7c /ir/be/begnuas.c
parente7a96ec68c8fb9637f067f14e47e0b5f90a0386b (diff)
be: Factor out code to decide whether a basic block needs a label.
For this a new flag 'arch_irn_flag_fallthrough' is introduced to mark nodes which are capable of falling through to their successor.
Diffstat (limited to 'ir/be/begnuas.c')
-rw-r--r--ir/be/begnuas.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c
index 2bbd06c..26828d9 100644
--- a/ir/be/begnuas.c
+++ b/ir/be/begnuas.c
@@ -1330,9 +1330,30 @@ void be_gas_emit_block_name(const ir_node *block)
}
}
-void be_gas_begin_block(const ir_node *block, bool needs_label)
+static bool block_needs_label(ir_node const *const block)
{
- if (needs_label || get_Block_entity(block)) {
+ if (get_Block_entity(block))
+ return true;
+
+ int const n_cfgpreds = get_Block_n_cfgpreds(block);
+ if (n_cfgpreds == 0) {
+ return false;
+ } else if (n_cfgpreds == 1) {
+ ir_node *const cfgpred = get_Block_cfgpred(block, 0);
+ ir_node *const cfgpred_block = get_nodes_block(cfgpred);
+ if (be_emit_get_prev_block(block) != cfgpred_block)
+ return true;
+
+ ir_node const *const pred = skip_Proj(cfgpred);
+ return !(arch_get_irn_flags(pred) & arch_irn_flag_fallthrough);
+ } else {
+ return true;
+ }
+}
+
+void be_gas_begin_block(ir_node const *const block)
+{
+ if (block_needs_label(block)) {
be_gas_emit_block_name(block);
be_emit_char(':');
} else {