This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Switch stmts and inserting on edges


OK, so my current bootstrapping problem presents an interesting
situation.

I have an edge from the switch stmt to the default case that I need to
insert a copy on.

The problem is that the preceeding case stmt drops into the default
case. Arg. That means the default block has 2 predecessors, and the
switch stmt has multiple successors, so the only way to insert is to
split the edge.

Splitting that edge is not trivial... Since it can't be properly split,
Id have to go to all the other predecessors, change them to goto a label
that would be inserted after the stmt Im trying to insert.
ie,

case blah:
  <...>
  goto new_label;

default:
  <inserted_stmt>
new_label:
  default code.

And that strikes me as being rather fragile. Esecially since the
preceeding case can have multiple block s which drop into the default.
(parts of conditionals for instance) And What if other cases share the
block with default, ie:
  case 142:
  default:
    code;
That requires even fancier tap-dancing.

So. what to do?

I suppose you could take the 'default' case and its block:

BB26
default:
  code;

and replace it with

BB26
new_label_1:
  goto new_label_2;
BB100
default:
  copy_stmt;
BB101
new_label_2:
  code;

So the fallthroughs would still fallthrough to block 26, and jump around
the default case code which can now be inserted in the default block.

Ick. Blah.

Any other suggestions? I havent thought of anything I actually like....

Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]