<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" style="word-wrap: break-word;">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Once again, thank you.<br>
<br>
I will add these explanations to my assembler journal and we may end up with some documentation by the time I am done.<br>
<br>
Jack<br>
<br>
<div style="font-family: Times New Roman; color: rgb(0, 0, 0); font-size: 16px;">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF467908"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Jim Grosbach [grosbach@apple.com]<br>
<b>Sent:</b> Thursday, February 02, 2012 4:50 PM<br>
<b>To:</b> Carter, Jack<br>
<b>Cc:</b> List<br>
<b>Subject:</b> Re: HELP - tblgen -gen-asm-matcher restrictions on .td content<br>
</font><br>
</div>
<div></div>
<div>Hi Jack,<br>
<div>
<div>On Jan 25, 2012, at 6:45 PM, "Carter, Jack" <<a href="mailto:jcarter@mips.com" target="_blank">jcarter@mips.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">
<div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 10pt;">
I'm trying to generate MipsGenAsmMatcher.inc for MipsAsmParser.cpp.<span class="Apple-converted-space"> </span><br>
<br>
What added restrictions for the .td file contents are there for tblgen -gen-asm-matcher?<br>
<br>
</div>
</div>
</blockquote>
<div><br>
</div>
Lots, as you're finding, almost all of them completely undocumented. :(</div>
<div><br>
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">
<div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 10pt;">
For the Mips platform we create the following .inc files through tblgen.<br>
<br>
tablegen(LLVM MipsGenRegisterInfo.inc -gen-register-info)<br>
tablegen(LLVM MipsGenInstrInfo.inc -gen-instr-info)<br>
tablegen(LLVM MipsGenCodeEmitter.inc -gen-emitter)<br>
tablegen(LLVM MipsGenMCCodeEmitter.inc -gen-emitter -mc-emitter)<br>
tablegen(LLVM MipsGenAsmWriter.inc -gen-asm-writer)<br>
tablegen(LLVM MipsGenDAGISel.inc -gen-dag-isel)<br>
tablegen(LLVM MipsGenCallingConv.inc -gen-callingconv)<br>
tablegen(LLVM MipsGenSubtargetInfo.inc -gen-subtarget)<br>
add_public_tablegen_target(MipsCommonTableGen)<br>
<br>
When I started trying to generate MipsGenAsmMatcher.inc for the assembler I started getting errors.<br>
<br>
tblgen -gen-asm-matcher -I ~/workarea/asm/llvm/include/  Mips.tdIncluded from Mips.td:24:<br>
MipsInstrInfo.td:833:14: error: Instruction 'LWL' has no tokens<br>
defm LWL     : LoadUnAlign32<0x22>;<br>
<br>
How does it get a token?<br>
<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>From the assembly string used by the instruction printer. That's saying there's a variant in the multi class expansion that doesn't have a string associated with it that can be used to derive the syntax.</div>
<br>
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">
<div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 10pt;">
Commenting out this code I got farther and found that a register that didn't have a formal def in MipsRegisterInfo.td would get flagged.<br>
<br>
     !strconcat(instr_asm, "\t$$zero, $rs, $rt"),<br>
<br>
% tblgen -gen-asm-matcher -I ~/workarea/asm/llvm/include/  Mips.td<br>
Included from Mips.td:24:<br>
Included from MipsInstrInfo.td:1120:<br>
Mips64InstrInfo.td:173:1: error: error: unable to find operand: 'zero'<br>
def DSDIV    : Div64<MipsDivRem, 0x1e, "ddiv", IIIdiv>;<br>
^<br>
<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>That's a bug/limitation of the asm matcher. For something similar, see X86InstrInfo.td's commented out definition of ShiftRotateByOneAlias.</div>
<div><br>
</div>
<div>-Jim</div>
<br>
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">
<div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 10pt;">
Any information on this would be great.<br>
<br>
Cheers,<br>
<br>
Jack<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>