Register allocation and spilling, the easy way?

I’ve used a greedy approach in a JVM allocator once, which worked pretty well. Basically start at the top of a basic block with all values stored on the stack. Then just scan the instructions forward, maintaining a list of registers which contain a value, and whether the value is dirty (needs to be written … Read more

(When) Should I learn compilers?

If you just want to be a run-of-the-mill coder, and write stuff… you don’t need to take compilers. If you want to learn computer science and appreciate and really become a computer scientist, you MUST take compilers. Compilers is a microcosm of computer science! It contains every single problem, including (but not limited to) AI … Read more

What’s the difference between parse trees and abstract syntax trees (ASTs)?

This is based on the Expression Evaluator grammar by Terrence Parr. The grammar for this example: grammar Expr002; options { output=AST; ASTLabelType=CommonTree; // type of $stat.tree ref etc… } prog : ( stat )+ ; stat : expr NEWLINE -> expr | ID ‘=’ expr NEWLINE -> ^(‘=’ ID expr) | NEWLINE -> ; expr … Read more

What programming languages are context-free?

What programming languages are context-free? […] My gut tells me that functional languages might be context-free […] The short version: There are hardly any real-world programming languages that are context-free in any meaning of the word. Whether a language is context-free or not has nothing to do with it being functional. It is simply a … Read more

What’s the difference between parse trees and abstract syntax trees (ASTs)?

This is based on the Expression Evaluator grammar by Terrence Parr. The grammar for this example: grammar Expr002; options { output=AST; ASTLabelType=CommonTree; // type of $stat.tree ref etc… } prog : ( stat )+ ; stat : expr NEWLINE -> expr | ID ‘=’ expr NEWLINE -> ^(‘=’ ID expr) | NEWLINE -> ; expr … Read more

tech