3 ms·
No, it will not make anything easier, except will just bloat the compiler and slow down the whole process. All kinds of optimizations you probably mean are poss
by mojuba 18y ago
No, it will not make anything easier, except will just bloat the compiler and slow down the whole process. All kinds of optimizations you probably mean are possible at the level of intermediate/pseudo code, and should be done there together with the other optimization techniques.
We can look at specific examples if you wish.
- eru 18y agoDepends on your definition of intermediate code, doesn't it?
- mojuba 18y agoUsually a stack-based language, very close to assembly with a lot of simplifications, e.g. no registers. Because of these simplifications, intermediate code is easier to optimize and to generate native code from.
- eru 18y agoI'd extend the definition to include things like GRIN code. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.27.3918 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.27.3...
- ntoshev 18y agoIntermediate code will obfuscate code's intent. Why require from the optimizer to reverse-engineer what you meant from a description at a different (lower) level of abstraction?
- mojuba 18y agoOn the philosophical level, "code's intent" is to run on a machine using machine language. Practically speaking, I've never seen any problem that couldn't be solved by analyzing intermediate code.
- jules 18y agoInteresting. Do you have pointers to any papers/implementations of optimizing compilers without abstract syntax trees. Also, are you still able to implement optimizations with the same effort? I'd gladly trade 10x longer compile time for 10% faster execution time. > We can look at specific examples if you wish. Common Subexpression Elimination, for example. Not just syntactically equal expressions but also cases like this: a1 = b + c a2 = c + b // eliminated And how do you do loop fusion & interchange? Edit: I now realise that we may be talking about different abstract syntax trees. I thought that you meant no intermediate data structures. But you probably meant that you don't need a parse tree, you can translate to the intermediate language directly from the source. If that's the case then here's another challenge: how do you produce error messages for type errors?