IUCompilerCourse / Essentials-of-Compilation

A book about compiling Racket and Python to x86-64 assembly
1.27k stars 137 forks source link

x86 variant for output of assign homes #152

Open jsiek opened 1 year ago

jsiek commented 1 year ago

We currently use x86_Var as the output of assign homes, which is a bit confusing because assign homes removes the variables. We need a variant of x86_Int that relaxes the argument restrictions.

jnear commented 1 year ago

Currently, x86_Int doesn't restrict arguments. e.g. Figure 2.5 (Python version) allows both arguments of a movq to be memory references. I assumed this was intentional - but maybe it wasn't?

jsiek commented 1 year ago

The restriction is not expressed in the grammar. (That kind of restriction is difficult to express in a grammar.) The restriction is instead expressed in the text, on page 21, and the lifting of the restrictions for x86_Var is stated on page 22.

jsiek commented 1 year ago

I should add, those restrictions are difficult to express without significantly increasing the size of the grammar.

jnear commented 1 year ago

That makes sense. I think it is not bad as it is, this is just a nuance that I need to explain in class better. An alternative might be a grammar x86_Int* that just has a footnote saying there are no argument restrictions.