[llvm-commits] [PATCH] TypeLegalizer refactoring (a part of vector-select support)
Duncan Sands
baldrick at free.fr
Wed May 18 05:02:06 PDT 2011
Hi Nadav,
> @@ -1814,6 +1732,74 @@
>
> ValueTypeActionImpl ValueTypeActions;
>
> + typedef std::pair<LegalizeAction, EVT> LegalizeKind;
> +
> + LegalizeKind
> + getTypeConversion(LLVMContext &Context, EVT VT) const {
did you try defining this out-of-line? It is rather big to be in a header
file. Last time I tried to do this I failed due to circular library
dependencies being created, but perhaps things are better now.
> + // If this is a simple type, use the ComputeRegisterProp mechanism.
> + if (VT.isSimple()) {
> + assert((unsigned)VT.getSimpleVT().SimpleTy <
> + array_lengthof(TransformToType));
> + EVT NVT = TransformToType[VT.getSimpleVT().SimpleTy];
> + LegalizeAction LA = ValueTypeActions.getTypeAction(VT.getSimpleVT());
> + /*assert(ValueTypeActions.getTypeAction(NVT) != Promote &&
> + "Promote may not follow Expand or Promote");*/
did you mean to comment out this assertion?
> + return LegalizeKind(LA, NVT);
> + }
> +
> + // Handle Extended Scalar Types.
> + if (!VT.isVector()) {
> +
> + assert(VT.isInteger() && "Float types must be simple");
> + unsigned BitSize = VT.getSizeInBits();
> + // First promote to a power-of-two size, then expand if necessary.
> + if (BitSize < 8 || !isPowerOf2_32(BitSize)) {
> + return LegalizeKind(Promote, VT.getRoundIntegerType(Context));
> + }
No need for curly brackets.
> + return LegalizeKind(Expand,
> + EVT::getIntegerVT(Context, VT.getSizeInBits()/2));
> + }
> +
> + // Handle vector types.
> + unsigned NumElts = VT.getVectorNumElements();
> + EVT EltVT = VT.getVectorElementType();
> +
> + // Vectors with only one element are always scalarized.
> + if (NumElts == 1) {
> + return LegalizeKind(Expand, EltVT);
> + }
No need for curly brackets.
Otherwise it looks good. Thanks for working on this!
Ciao, Duncan.
More information about the llvm-commits
mailing list