<div dir="ltr">Hi,<br><br>I am working on a new back-end for LLVM. This architecture has two register types, data(A) and accumulator(B). <br><br>A registers are i32 where as B registers are i64. This is causing me some headaches, as far as I can tell, it's not really possible to mix the two using tablegen?<br>
<br>In the hardware, every instruction can either take an A register or a B register, in tablegen (as far as I can understand) this is not possible.<br><br>I ended up creating instructions like<br><br>MOV32ri (register immediate)<br>
MOV32rr (register register)<br>MOV64rr, MOV64ri etc.<br><br>I've done this for essentially every instruction. This kind of works, but there are issues.<br><br>It results in unneeded copies between A registers and B registers. If a value is in an A register and the other is in a B, LLVM will do a copy between registers to make sure both registers are the same "type"(same bank) before doing the operation.<br>
<br>Is there any way around this? Also is it really necessary to define a different instruction for each register type (even though it's the same instruction in hardware, with the same encoding etc).<br><br>Another issue is that when multiplying, the result must always be stored in a B (accumulator register). So I did some custom lowering for the MUL node, and got the instruction to always write the result to a B register.<br>
<br>The problem is that later on LLVM will move it from a B register to an A register which means the result getting truncated (64 bit -> 32 bit). I am also unsure how to deal with this.<br><br>I just want to confirm that I'm doing this somewhat correctly and there isn't a much more obvious and better way of doing this.<br>
<br>Kind Regards,<br><br>Jonathan<br></div>