<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 1:00 PM, Steve King <span dir="ltr"><<a href="mailto:steve@metrokings.com" target="_blank">steve@metrokings.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello LLVM,<br>
<br>
My target has a complex relaxation hierarchy.  Perhaps a modest<br>
TableGen extension would help consolidate most of the work involved in<br>
choosing a relaxed opcode.  I also notice the x86 relaxation code with<br>
a comment wondering if TableGen could improve life.<br>
<br>
Does the following outline sound interesting?<br>
<br>
1) Add a new field of type 'Instruction' to the Instruction class<br>
called "RelaxedInstr"<br>
<br>
2) Target instructions optionally set RelaxedInstr, as in:<br>
<br>
def JMP32 : Instruction<stuff>;  // no relaxation from here<br>
def JMP8 : Instruction<stuff> {<br>
      let RelaxedInstr = JMP32;  // relax to 32-bit jmp<br>
}<br>
<br>
3) The tblgen -gen-instr-info processor uses RelaxedInstruction to<br>
create the RelaxedOpcode field for the corresponding MCInst.  The<br>
RelaxedOpcode field contains the target specific opcode (an<br>
enumeration value) of the specified RelaxedInstr.<br>
<br>
4) From C++, targets access the RelaxedOpcode field as needed, akin to<br>
TSFlags.  This eliminates the headaches of massive opcode switch<br>
statements in targets like mine.<br>
<br>
It's unclear to me how to handle the default value of an 'Instruction'<br>
when no relaxation exists.<br>
<br></blockquote><div><br></div><div>It is possible to get the same result using tablegen instruction mappings.</div><div><a href="http://llvm.org/docs/HowToUseInstrMappings.html">http://llvm.org/docs/HowToUseInstrMappings.html</a></div><div><br></div><div>For Octasic's Opus architecture, we use instruction mappings extensively to describe relation between instructions, including relaxed vs non-relaxed jump opcode. Tablegen will generate the huge switch case automatically.</div><div><br></div><div>Francois Pichet</div><div>Octasic.   </div><div><br></div><div><br></div></div></div></div>