Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000049 [libFirm] representation feature always 2009-08-06 16:05 2011-12-24 03:47
Reporter Matze View Status public  
Assigned To Matze
Priority low Resolution fixed  
Status closed   Product Version
Summary 0000049: Proposal for a better representation of switch jumps
Description switch constructs are currently represented as a Cond node with a Proj node for each case. Additionally there's a magic reserved number (saved as attribute of the Cond node), that represents the default jump which is taken when none of the Projs matches.

This has a number of problems:
* Finding a magic number for the default Proj complicates the frontends (you have to find a number which is not used by any case label)
* Representing case ranges (case 0..1000: is a gcc extension) is very inefficient and resource intensive as we have to construct 1000 Proj nodes
* Projs spanning a wide range between INT_MIN and INT_MAX are bad for the backend: We can't create simple arrays anymore to represent output constraints for all possible Projs (as the arrays grow too large when the projs are too sparse).
* Some APIs in the backend are buggy in that they take a paramter "int pos". It represents a node input if the number is positiv or a node output if it is negative. If a switch Proj has a negative number then we can't address it with this API (currently its buggy and unexpectely address an input)

Proposed alternative:
Create a sorted array of switch destinations and save it as attribute of the Cond node. Entries should look like this:

struct switch_dest_entry { long min; long max; };

We can then define that Proj0 is always the default Proj. All other Proj numbers reference entries in this switch destination table. This results in seamless and always positive Proj numbers and an efficient packing of case-ranges (only 1 table entry for a case range).
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
Matze (administrator)
2009-08-06 18:35

We should probably introduce a new node type too when rewriting this. So Cond works only on mode_b inputs for ifs.
Matze (administrator)
2011-11-03 19:42

implemented in 1c89dc2a2c3cccd6e29fcfbf65248496db66ab92

- Issue History
Date Modified Username Field Change
2009-08-06 16:05 Matze New Issue
2009-08-06 16:06 Matze Severity minor => feature
2009-08-06 16:06 Matze Status new => confirmed
2009-08-06 18:35 Matze Note Added: 0000084
2011-11-03 19:42 Matze Note Added: 0000131
2011-11-03 19:42 Matze Assigned To => Matze
2011-11-03 19:42 Matze Status confirmed => resolved
2011-11-03 19:42 Matze Resolution open => fixed
2011-12-24 03:47 Matze Status resolved => closed

Mantis 1.1.5[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker