Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So you hardcode canonical forms to simplify them down to a common form so that you only need to hardcode one kind of form for the next pass?


Almost. Canonicalize constructs so that they will be easier to manage in later passes.

So for example in the x * 2 case, if you canonicalize it to a shift, the representation of that shift may have other properties (or tags or whatever) like “this operation has no side effects on memory”. A later pass might make sure the register is saved (or decide to discard the shift because its result is not used) without* that pass having to know specifically about shifts.

Later passes could have different canonicalizations, say coupling the shift and its store so that a single thing is, say, hoisted out of a loop (this is actually probably an unrealistic example, but reasonable for explanatory reasons)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: