<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 'Segoe UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>Hi Andrea</div><div><span style="font-family: "" segoe="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">    Thank you your replying.</span></div><div><span style="font-family: "" segoe="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" segoe="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">    I do like your letter. Add following to line to </span></span><span style="font-family: 'Segoe UI', Tahoma; line-height: normal; font-size: 10.5pt; background-color: window;">MipsISelLowering.cpp. As your words,  </span><span style="font-family: 'Segoe UI', Tahoma; line-height: normal; font-size: 10.5pt; background-color: window;"> </span><span style="font-family: 'Segoe UI', Tahoma; line-height: normal; font-size: 10.5pt; background-color: window;">@llvm.convert.to.fp16  can compile successfully. However, the runtime is not right.</span></div><div><span style="font-family: 'Segoe UI', Tahoma; line-height: normal; font-size: 10.5pt; background-color: window;"><br></span></div><div><span style="font-family: "" segoe="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" segoe="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><div style="font-family: 'Segoe UI', Tahoma; line-height: normal;">+  setOperationAction(ISD::FP16_TO_FP32, MVT::f32, Expand);</div><div style="font-family: 'Segoe UI', Tahoma; line-height: normal;">+  setOperationAction(ISD::FP32_TO_FP16, MVT::i32, Expand);</div><div style="font-family: 'Segoe UI', Tahoma; line-height: normal;"><br></div><div style="font-family: 'Segoe UI', Tahoma; line-height: normal;">Robin</div></span></span></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>yalong@multicorewareinc.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:andrea.dibiagio@gmail.com">Andrea Di Biagio</a></div><div><b>Date:</b> 2014-07-09 14:20</div><div><b>To:</b> <a href="mailto:Matthew.Arsenault@amd.com">Matt Arsenault</a></div><div><b>CC:</b> <a href="mailto:yalong@multicorewareinc.com">yalong@multicorewareinc.com</a>; <a href="mailto:kevinqindev@gmail.com">Kevin Qin</a>; <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev</a></div><div><b>Subject:</b> Re: [LLVMdev] Help!!!!Help!!!! " LLVM ERROR: Cannot select: 0x9fc9680: i32 = fp32_to_fp16 0x9fc0750 [ID=16] " problem!!!!!!!!!!!!!!!!!!</div></div></div><div><div>Not sure if this can help, but</div>
<div>if you really really want to have minimal half float support on Mips,</div>
<div>then one thing you could try to do is to hack MipsISelLowering.cpp</div>
<div>adding rules to expand float-half conversion SDNodes into library</div>
<div>calls.</div>
<div> </div>
<div>+  setOperationAction(ISD::FP16_TO_FP32, MVT::f32, Expand);</div>
<div>+  setOperationAction(ISD::FP32_TO_FP16, MVT::i32, Expand);</div>
<div> </div>
<div>(The MVT::i32 on the second rule is required because type i16 is</div>
<div>promoted to i32).</div>
<div> </div>
<div>If you then convert every occurrence of 'fptrunc' from float to half</div>
<div>with calls to @llvm.convert.to.fp16, then you should be able to</div>
<div>compile (hopefully) with no errors.</div>
<div>That means, in your original example you would convert the following</div>
<div>IR statement:</div>
<div>  %Vt3_1 = fptrunc float %Vt_2 to half</div>
<div>into</div>
<div>  %Vt3_1 = call i16 @llvm.convert.to.fp16(float %Vt_2)</div>
<div> </div>
<div>The downside is that you will have to add definitions for</div>
<div>'__gnu_f2h_ieee' and '__gnu_h2f_ieee' in the compiler runtime. That is</div>
<div>because the backend will expand all the float-half conversions into</div>
<div>library calls...</div>
<div>This workaround should work assuming that a) you can hack the backend,</div>
<div>and b) it is acceptable (i.e. a reasonable solution in your case) to</div>
<div>have a library call for every float-half conversion in your code.</div>
<div> </div>
<div>On Wed, Jul 9, 2014 at 8:51 PM, Matt Arsenault</div>
<div><Matthew.Arsenault@amd.com> wrote:</div>
<div>> I think that support for the half type is only implemented for ARM. Last I</div>
<div>> tried to use it, I found that none of it works even on x86, and the current</div>
<div>> handling of the half conversion SDNodes seem to rely on ARM specific</div>
<div>> assumptions</div>
<div> </div>
<div>Just for the record,</div>
<div>since revision 212293 (committed only five days ago), the x86 backend</div>
<div>supports float half conversions.</div>
<div>On x86, if the target has F16C, there are ISel patterns to map</div>
<div>float-half conversions to specific instructions. If there is no F16C</div>
<div>support, then the backend expands float-half conversions into runtime</div>
<div>library calls.</div>
<div> </div>
<div>Cheers,</div>
<div>Andrea</div>
</div></blockquote>
</body></html>