<div dir="ltr"><div>Hello,</div><div>I'm writing a backend for an architecture that only has LOAD Instructions that first copy the old value of the target register in another register and after that load the provided value into the register. </div>
<div> </div><div>Example of an addition:</div><div>load a, reg1; // -> copies old value of reg1 in reg2 and loads value from a into reg1</div><div>load b, reg1; // -> copies old value of reg1 in reg2 and loads value from b into reg1</div>
<div>add reg1, reg2; // adds values from a and b and saves the result into reg1</div><div> </div><div>So I need to describe the "load X, reg1" Instruction so that LLVM understands it correctly.</div><div>How can I do that in LLVM? Where is the best place to do that(TableGen, Instruction Selection, Instruction Lowering)?</div>
<div> </div><div>It would be fine if I could tell LLVM that reg2 is invalid after a load Operation, but I don#t know how to do that...</div><div>I tried the following in TableGen to let LLVM know that Resg2 isn't valid anymore after a load but it didn't produce the desired result:</div>
<div> </div><div>let Defs = [Regs2] in</div><div>{</div><div><font face="Consolas"><font face="Consolas"><p>  def LD: Inst<(outs Regs1:$dst), (ins MEM:$addr),</p>
<p>                       "load $addr, $dst;",</p>
<p>                       [(set Regs1:$dst, (load addr:$addr))]>;</p><p>}</p></font></font></div><div> </div><div>Thanks in advance,</div><div>Markus</div></div>