<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 7, 2015, at 6:40 PM, Chris.Dewhurst via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hi,<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I have a task to complete and I’m getting stuck. I can’t find anything comparable in the documentation. The shortest explanation I can give is as follows: I need to use double-precision floating point values for floating-point multiplies. I’ll not go into why: That would take the discussion away from the essential problem. E.g.<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">  Replace:<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; text-align: justify;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(0, 112, 192);" class="">  fmuls %f20,%f21,%f8<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-family: 'Times New Roman', serif;" class=""> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: justify;" class=""><span lang="EN-US" style="font-family: 'Times New Roman', serif;" class="">  with the sequence:<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: justify;" class=""><span lang="EN-US" style="font-family: 'Times New Roman', serif;" class=""> </span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; text-align: justify;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(0, 112, 192);" class="">  fstod %f20,%f0<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; text-align: justify;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(0, 112, 192);" class="">  fstod %f21,%f2<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; text-align: justify;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(0, 112, 192);" class="">  fmuld %f0,%f2,%f8<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">This is for a Sparc derived back-end and I’m already at the MachineInstr phase. The essential code I have now is as follows, but it doesn’t work. I’ve had much larger pieces of code, but I believe my mistake lies somewhere in here. I’m not sure if I’m heading down the right path with this. Please, any help would be appreciated – or any reference to an example, even better.<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">[code is iterating through the MachineBasicBlock – this code is pretty straightforward and you can probably guess what’s in it]<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">   <span class="Apple-converted-space"> </span></span><b class=""><span style="font-size: 10pt; font-family: monospace; color: rgb(127, 0, 85);" class="">if</span></b><span style="font-size: 10pt; font-family: monospace;" class=""><span class="Apple-converted-space"> </span>(Opcode ==<span class="Apple-converted-space"> </span><u class="">SP::FMULS</u>)</span><span style="font-size: 10pt; font-family: monospace;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">      {</span><span style="font-size: 10pt; font-family: monospace;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 10pt; font-family: monospace; color: rgb(0, 80, 50);" class="">MachineOperand</span><span style="font-size: 10pt; font-family: monospace;" class="">& MO = MI.getOperand(0);</span><span style="font-size: 10pt; font-family: monospace;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 10pt; font-family: monospace; color: rgb(0, 80, 50);" class="">DebugLoc</span><span style="font-size: 10pt; font-family: monospace;" class=""><span class="Apple-converted-space"> </span>DL = MBBI->getDebugLoc();</span><span style="font-size: 10pt; font-family: monospace;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">       <span class="Apple-converted-space"> </span><u class="">BuildMI</u>(MBB, MBBI, DL, TII.<u class="">get</u>(<u class="">SP::FSTOD</u>), MO.getReg());</span></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>Looks like this MI will write to the final destination register (%f8 in your example), which is not what you want IIUC.</div><div><br class=""></div><div>You need to create a new register for the double (%f0) using:</div><div><br class=""></div><div><div style="margin: 0px;" class=""><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">    </span><span style="color: rgb(4, 51, 255); font-family: Menlo; font-size: 11px;" class="">const</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class=""> </span><font color="#3495af" face="Menlo" class=""><span style="font-size: 11px;" class="">TargetRegisterClass</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class=""> *DoubleRC = ….</span></font></div><div style="margin: 0px;" class=""><div style="color: rgb(52, 149, 175); font-family: Menlo; font-size: 11px; margin: 0px;" class=""><span style="color: rgb(0, 0, 0);" class="">    </span><span style="color: rgb(4, 51, 255);" class="">unsigned</span><span style="color: rgb(0, 0, 0);" class=""> f0 = </span>MRI<span style="color: rgb(0, 0, 0);" class="">.</span>createVirtualRegister<span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(0, 0, 0);" class="">DoubleRC</span><span style="color: rgb(0, 0, 0);" class="">);</span></div><div style="color: rgb(52, 149, 175); font-family: Menlo; font-size: 11px;" class=""><div style="margin: 0px;" class=""><span style="color: rgb(0, 0, 0);" class="">    </span><span style="color: rgb(4, 51, 255);" class="">unsigned</span><span style="color: rgb(0, 0, 0);" class=""> f2 = </span>MRI<span style="color: rgb(0, 0, 0);" class="">.</span>createVirtualRegister<span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(0, 0, 0);" class="">DoubleRC</span><span style="color: rgb(0, 0, 0);" class="">);</span></div></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font></div><div class=""><br class=""></div></div></div>And then you can try to build your sequence with something that will look like:</div><div><br class="">        BuildMI(MBB, MBBI, DL, TII.get(SP::FSTOD), f0).addReg(MI.getOperand(1).getReg());<br class="">        BuildMI(MBB, MBBI, DL, TII.get(SP::FSTOD), ).addReg(MI.getOperand(2).getReg());<br class="">        BuildMI(MBB, MBBI, DL, TII.get(FMULD), MO.getReg()).addReg(f0).addReg(f2);<br class=""><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; orphans: auto; text-align: start; text-indent: 0px; widows: auto;"><div style="margin: 0cm 0cm 0.0001pt;" class=""><span class=""><font color="#000000" class=""><o:p class=""></o:p></font></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">           [ Then we’d do the second fstod and the fmuld, but I’ve not included this because the basic problem of generating the MachineInstr has happened already for this first MachineInstr]</span></div></div></div></blockquote><div><br class=""></div><div>(You haven’t really described what problem you have though).</div><div><br class=""></div><div><div>— </div><div>Mehdi</div><div><br class=""><br class=""></div><div><br class=""></div></div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; orphans: auto; text-align: start; text-indent: 0px; widows: auto;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt; font-family: monospace;" class=""><o:p class=""></o:p></span></div><div style="font-family: Calibri, sans-serif; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0cm 0cm 0.0001pt;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">        MI.eraseFromParent();</span><span style="font-size: 10pt; font-family: monospace;" class=""><o:p class=""></o:p></span></div><div style="font-family: Calibri, sans-serif; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0cm 0cm 0.0001pt;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">      }<o:p class=""></o:p></span></div><div style="font-family: Calibri, sans-serif; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0cm 0cm 0.0001pt;" class=""><span style="font-size: 10pt; font-family: monospace;" class=""> </span></div><div style="font-family: Calibri, sans-serif; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0cm 0cm 0.0001pt;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">Chris Dewhurst,<o:p class=""></o:p></span></div><div style="font-family: Calibri, sans-serif; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0cm 0cm 0.0001pt;" class=""><span style="font-size: 10pt; font-family: monospace;" class="">University of Limerick, Ireland</span><o:p class=""></o:p></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">LLVM Developers mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:llvm-dev@lists.llvm.org" style="color: rgb(149, 79, 114); text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">llvm-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" style="color: rgb(149, 79, 114); text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></div><br class=""></body></html>