[llvm-dev] questions about legalize type for vector

林政宗 via llvm-dev llvm-dev at lists.llvm.org
Sat May 16 19:23:05 PDT 2020


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200517/ec06448a/attachment.html>


More information about the llvm-dev mailing list