Re: Books on compiler backends?
- From: Kaleb Pederson <kaleb.pederson@xxxxxxxxx>
- Date: Mon, 11 Feb 2008 13:03:48 -0800 (PST)
On Feb 9, 3:06 am, Jyrki Saarinen <jy...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Take a look at the SableCC. It produces standard Visitor design pattern code
after you have described the structure of your AST (it does it even without,
but that's not likely to be very useful).
The visitor design pattern is great and I understand it well, but it
doesn't solve the problem that I was alluding to (perhaps too weakly).
The problem is that checking each node to see if it matches one of the
many patterns that need to be replaced is extremely inefficient, and
that's about where my knowledge breaks down.
Based on my understanding, I want to find an optimal or optimum
solution, possibly using a maximal much algorithm, but there's a few
things that I'm unsure of. At this point, I'm not really doing
instruction selection, but I do have a number of subtree patterns that
I want replaced with optimized versions. If possible and optimal, I
would like to use an algorithm that will do this for me, so I need not
create a visitor that needs N passes through my AST to discover, and
possibly replace, N different types of subtrees.
Can I use the standard maximal munch algorithm, with the replacement
for all nodes being the node itself at cost X and then, for all
replacement subtrees, indicate that the replacement subtree has cost X
- y (eg. some lower cost so it will always be preferred to the non-
replacement)? What other algorithms, if any, should I look at?
Thanks.
--Kaleb
.
- References:
- Books on compiler backends?
- From: Kaleb Pederson
- Re: Books on compiler backends?
- From: Jyrki Saarinen
- Books on compiler backends?
- Prev by Date: Re: Full LR(1) parser generator Hyacc 0.9 release
- Next by Date: Re: Optimizing in my toy compiler
- Previous by thread: Re: Books on compiler backends?
- Next by thread: TYPES 2008 (Torino, Ithaly, Mar 08)
- Index(es):
Relevant Pages
|
Loading