-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify IR data structures #82
Labels
Milestone
Comments
fabianschuiki
added
A-ir
Area: Intermediate representation.
P-long-term
Priority: Long-term endeavour.
labels
Jan 31, 2020
Improved IR node handling moved to #107. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Functions, Processes, Entities
Functions, processes, and entities are fairly uniform. They merely differ in their signatures (whether they have a return type or a list of output arguments), and whether they contain basic blocks or just a set of instructions.
Working with LLHD could be greatly simplified by unifying the
Function
,Process
, andEntity
structs into oneUnit
struct. Differences in signature are already handled, and entities can be represented by having a single implicit basic block.CFG, DFG, Layout
The current setup with separate CFG, DFG, and layouts is rather cumbersome to work with. Rather consider consolidating
ControlFlowGraph
,DataFlowGraph
,FunctionLayout
, andInstLayout
into one data structure that is shared among functions, processes, and entities.Improve IR manipulation with a single builder
The graph-ir branch contains a quick trial on how the IR could be revamped. Part of that is a new builder/modifier scheme where the user does not directly interact with modules, functions, processes, entities, blocks, and instructions, but rather uses builder instances. These lock the module or unit in place using a lifetime and are the only means to modify these structs -- they don't provide such functionality themselves.
llhd/examples/gir.rs
Lines 47 to 85 in 75aeda7
llhd/examples/gir.rs
Lines 107 to 155 in 75aeda7
This provides a single point of modification for the IR, and allows the code to perform a lot of bookkeeping on the side, such as pred/succ and usage tables, as well as dominator tree invalidation. The current IR would greatly benefit from such a scheme as it streamlines interaction with LLHD and provides more opportunities to make things fast on the inside.
An interesting improvement would be to make the changes applied to these builders deferred, such that the user can accumulate modifications which then only become visible upon committing them. This would allow the user to interact with analyses such as DTs and TRGs without them being invalidated by modification, with the express mental model being that the changes are delayed and as such the analyses remain valid.
An important side-effect of this is that modification through a single structure allows that structure to maintain a lot of accelerating lookup data structures, such as predecessor/successor lists, terminator maps, phi node lists, cached dominator tables, etc.
Todo
Modification through a single builder
&mut self
functions fromUnit
trait&self
functions fromUnitBuilder
traitEntity
with the rest by adding a single default blockEntity
,Process
, andFunction
into aUnitData
structModUnit
s and replace with explicit list of units and declarationsUnit
andUnitBuilder
into structsdump()
to takeUnit
instead of DFG and optional CFGDominatorTree
andPredecessorTable
to useUnit
FunctionInsertPos
functions intoUnit
cfg
,dfg
, andlayout
privateThe text was updated successfully, but these errors were encountered: