On 6/9/22 17:38, Matteo Bruni wrote:
My current vision of SMxIR is that it should be a one-to-one representation of actual instructions, writable without any lowering passes (and hence any passes that are done on it should be optimization only, with the *possible* exception of RA.) In a sense, it's what we have already with sm4_instruction and such, except that we'd be storing it and doing passes on it rather than just writing it directly.
Right, I agree with the general idea. In practice it might turn out to be useful to relax the 1:1 requirements a bit and introduce some "extra" instructions (that would be quickly lowered to real ones) if that makes the HIR->SMxIR conversion easier.
Something related we already discussed: SM1IR and SM4IR are going to be different, obviously, but we want to try and architect them so that the optimization passes machinery and most of the actual passes can be shared between the two.
Hmm, I don't remember that discussion. My take is that if there's only two backends it probably makes more sense not to (over-)engineer any common framework, but rather just make them look similar enough that we can copy-paste things from one to the other. (It's an unpopular opinion, perhaps, but I think that code duplication is an important and often the best method of code deduplication.)
Of course, I don't know what the sm6 backend will look like, when and if we add it.