fabianschuiki / moore

A hardware compiler based on LLHD and CIRCT
http://www.llhd.io
Apache License 2.0
246 stars 31 forks source link

Fold constants upon code emission #160

Closed fabianschuiki closed 4 years ago

fabianschuiki commented 4 years ago

Using the ** operator in a constant expression on the left-hand side of an assignment currently triggers an error during codegen, complaining about ** not being supported on non-constants. This is due to the fact that codegen is called on the MIR of the expression, which immediately tries to emit LLHD instructions. What should actually happen is that whenever MIR is asked to be emitted, the compiler should try to constant-fold, thus eliminating the need for lots of redundant instructions.