Jon Harrop
2010-04-27 21:24:13 UTC
HLVM now includes an example pattern match compiler in the third example
compiler front-end that can compile some quite sophisticated ML-like
programs:
http://flyingfrogblog.blogspot.com/2010/04/variant-types-and-pattern-matching-in.html
However, there is a perf bug in my pattern match compiler where the amount
of HLVM IR generated grows exponentially with the number of match cases.
This seems unavoidable when compiling to nested "if" expressions so my first
thought is to pull the pattern match compiler into HLVM itself and generate
shared LLVM basic blocks directly. However, I believe most pattern match
compilers in ML compilers don't do this and just compile to a higher-level
IR so I'm wondering how they get around this redundant code issue. I can
think of two alternative solutions. One is to convey sharing some other way
and have HLVM detect them and reuse the same basic block. The other is to
factor the shared code into separate functions.
Is this a fair assessment?
compiler front-end that can compile some quite sophisticated ML-like
programs:
http://flyingfrogblog.blogspot.com/2010/04/variant-types-and-pattern-matching-in.html
However, there is a perf bug in my pattern match compiler where the amount
of HLVM IR generated grows exponentially with the number of match cases.
This seems unavoidable when compiling to nested "if" expressions so my first
thought is to pull the pattern match compiler into HLVM itself and generate
shared LLVM basic blocks directly. However, I believe most pattern match
compilers in ML compilers don't do this and just compile to a higher-level
IR so I'm wondering how they get around this redundant code issue. I can
think of two alternative solutions. One is to convey sharing some other way
and have HLVM detect them and reuse the same basic block. The other is to
factor the shared code into separate functions.
Is this a fair assessment?
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com