[Firm] libfirm Erweiterung um IR bäume zu durchsuchen
mm.beck at gmx.net
Thu Nov 14 19:15:31 CET 2013
I fully agree with Mathias here. The question is, what is the goal of this
There are of course some semi-automatic systems for this task. LLVM's
tablegen comes in mind.
The question is, how big are your search pattern, how often you expect to
find it and are you interested in
speed of simplicity in specification. For the first, probably any
hand-written approach that uses libFirm
specific knowledge will beat the automatic result in either speed or size.
I believe LLVM's tablegen approach
counts for a great part of the code size of an LLVM backend.
If simplicity is your goal, a pattern matcher might be a good idea, but
often finding the match is just
one part on the problem. Especially when you want replace the pattern by
something different and either must
re-use some nodes/attributes of the old pattern of need some "context",
you must be able identify every node, etc.
this will add a great amount of extra work that must be implemented. Then,
in compiler construction these patterns
often are limited to some block structure (for instance all nodes in the
same BB of in the same super block)
which is more complicated to express.
Last, often pattern matcher expect that the graph can be accessed
bi-directional, which is not always the case
in libFirm, where you have only dependency edges by default.
I don't believe it will be worth the effort, but I would try to write a
"backend" for tablegen ...
More information about the Firm