<div dir="ltr">Those are the actions for the type legalizer. They specify how to legalize a type that has no supported operations and isn't assigned to any register class by your target. The action will be applied to every operation on that type.<div><br></div><div>I assume v32i16 is otherwise supported for your target and only division is missing. If that's the case you'll need to define a Custom lowering operation for your target. So you'll need to call setOperationAction(ISD::SDIV, v32i16, Custom) from your TargetLowering constructor.  Then write custom code in LowerOperation to custom handle v32i16 ISD::SDIV. From there you can split the operands, SIGN_EXTEND each to v16i32 do the SDIV, TRUNCATE the results back to v16i16, and use a CONCAT_VECTORS to join them back to v32i16.</div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 16, 2020 at 7:23 PM 林政宗 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><div style="margin:0px">Hi,</div><div style="margin:0px"><br></div><div style="margin:0px">I am writing a new backend and I met some problem.</div><div style="margin:0px">I want to support in IR: sdiv v32i16 %a, %b. But the target only support sdiv v16i32 %a, %b natively.</div><div style="margin:0px">Could I promote v32i16 to v32i32, split v32i32 to two v16i32 , truncate v16i32 to v16i16 and merge two v16i16 into one v32i16?</div><div style="margin:0px">Is this way possible?</div><div style="margin:0px">I saw the code fragment in TargetLowering.h:</div><div style="margin:0px">============================================================</div><div style="margin:0px"> 169  /// This enum indicates whether a types are legal for a target, and if not,<br> 170  /// what action should be used to make them valid.<br> 171  enum LegalizeTypeAction : uint8_t {<br> 172    TypeLegal,           // The target natively supports this type.<br> 173    TypePromoteInteger,  // Replace this integer with a larger one.<br> 174    TypeExpandInteger,   // Split this integer into two of half the size.<br> 175    TypeSoftenFloat,     // Convert this float to a same size integer type.<br> 176    TypeExpandFloat,     // Split this float into two of half the size.<br> 177    TypeScalarizeVector, // Replace this one-element vector with its element.<br> 178    TypeSplitVector,     // Split this vector into two of half the size.<br> 179    TypeWidenVector,     // This vector should be widened into a larger vector.<br> 180    TypePromoteFloat,    // Replace this float with a larger one.<br> 181    TypeSoftPromoteHalf, // Soften half to i16 and use float to do arithmetic.<br> 182  };</div><div style="margin:0px">=============================================================</div><div style="margin:0px">I don't quite understand the action <span style="float:none;background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:Arial;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline">TypeWidenVector. What does it do?  Does this action do like promote v32i16 to v32i32?</span></div><div style="margin:0px">If this way is possible, where should I set the <span style="float:none;background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:Arial;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline">LegalizeTypeAction in the source code?</span></div><div style="margin:0px">Is it in the constructor of class XXXTargetLowering? And How could I set the action to manipulate the process as I want?</div><div style="margin:0px">Thanks!</div><div style="margin:0px"><br></div><div style="margin:0px">Best regards,</div><div style="margin:0px">Jerry</div><div style="margin:0px"><br></div></div><br><br><span title="neteasefooter"><p> </p></span>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>