[llvm-dev] questions about legalize type for vector
Craig Topper via llvm-dev
llvm-dev at lists.llvm.org
Sat May 16 20:42:49 PDT 2020
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.
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.
~Craig
On Sat, May 16, 2020 at 7:23 PM 林政宗 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:
> Hi,
>
> I am writing a new backend and I met some problem.
> I want to support in IR: sdiv v32i16 %a, %b. But the target only support
> sdiv v16i32 %a, %b natively.
> Could I promote v32i16 to v32i32, split v32i32 to two v16i32 , truncate
> v16i32 to v16i16 and merge two v16i16 into one v32i16?
> Is this way possible?
> I saw the code fragment in TargetLowering.h:
> ============================================================
> 169 /// This enum indicates whether a types are legal for a target, and
> if not,
> 170 /// what action should be used to make them valid.
> 171 enum LegalizeTypeAction : uint8_t {
> 172 TypeLegal, // The target natively supports this type.
> 173 TypePromoteInteger, // Replace this integer with a larger one.
> 174 TypeExpandInteger, // Split this integer into two of half the
> size.
> 175 TypeSoftenFloat, // Convert this float to a same size integer
> type.
> 176 TypeExpandFloat, // Split this float into two of half the size.
> 177 TypeScalarizeVector, // Replace this one-element vector with its
> element.
> 178 TypeSplitVector, // Split this vector into two of half the
> size.
> 179 TypeWidenVector, // This vector should be widened into a
> larger vector.
> 180 TypePromoteFloat, // Replace this float with a larger one.
> 181 TypeSoftPromoteHalf, // Soften half to i16 and use float to do
> arithmetic.
> 182 };
> =============================================================
> I don't quite understand the action TypeWidenVector. What does it do?
> Does this action do like promote v32i16 to v32i32?
> If this way is possible, where should I set the LegalizeTypeAction in the
> source code?
> Is it in the constructor of class XXXTargetLowering? And How could I set
> the action to manipulate the process as I want?
> Thanks!
>
> Best regards,
> Jerry
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200516/e58e2f8a/attachment.html>
More information about the llvm-dev
mailing list