Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ class IRTranslator : public MachineFunctionPass {

StackProtectorDescriptor SPDescriptor;

bool mayTranslateUserTypes(const User &U) const;

/// Switch analysis and optimization.
class GISelSwitchLowering : public SwitchCG::SwitchLowering {
public:
Expand Down
27 changes: 16 additions & 11 deletions llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ LLVM_ABI LegalizeMutation changeElementCountTo(unsigned TypeIdx,
LLVM_ABI LegalizeMutation changeElementSizeTo(unsigned TypeIdx,
unsigned FromTypeIdx);

/// Change the scalar size or element size to have the same scalar size as the
/// type \p NewTy. Unlike changeElementTo, this discards pointer types and only
/// changes the size.
LLVM_ABI LegalizeMutation changeElementSizeTo(unsigned TypeIdx, LLT NewTy);

/// Widen the scalar type or vector element type for the given type index to the
/// next power of 2.
LLVM_ABI LegalizeMutation widenScalarOrEltToNextPow2(unsigned TypeIdx,
Expand Down Expand Up @@ -1048,7 +1053,7 @@ class LegalizeRuleSet {
using namespace LegalizeMutations;
return actionIf(LegalizeAction::WidenScalar,
scalarOrEltNarrowerThan(TypeIdx, Ty.getScalarSizeInBits()),
changeElementTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}

/// Ensure the scalar or element is at least as wide as Ty.
Expand All @@ -1059,7 +1064,7 @@ class LegalizeRuleSet {
return actionIf(LegalizeAction::WidenScalar,
all(Predicate, scalarOrEltNarrowerThan(
TypeIdx, Ty.getScalarSizeInBits())),
changeElementTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}

/// Ensure the vector size is at least as wide as VectorSize by promoting the
Expand All @@ -1078,7 +1083,8 @@ class LegalizeRuleSet {
const LLT VecTy = Query.Types[TypeIdx];
unsigned NumElts = VecTy.getNumElements();
unsigned MinSize = VectorSize / NumElts;
LLT NewTy = LLT::fixed_vector(NumElts, LLT::scalar(MinSize));
LLT NewTy = LLT::fixed_vector(
NumElts, VecTy.getElementType().changeElementSize(MinSize));
return std::make_pair(TypeIdx, NewTy);
});
}
Expand All @@ -1089,7 +1095,7 @@ class LegalizeRuleSet {
using namespace LegalizeMutations;
return actionIf(LegalizeAction::WidenScalar,
scalarNarrowerThan(TypeIdx, Ty.getSizeInBits()),
changeTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}
LegalizeRuleSet &minScalar(bool Pred, unsigned TypeIdx, const LLT Ty) {
if (!Pred)
Expand All @@ -1110,7 +1116,7 @@ class LegalizeRuleSet {
QueryTy.getSizeInBits() < Ty.getSizeInBits() &&
Predicate(Query);
},
changeTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}

/// Ensure the scalar is at most as wide as Ty.
Expand All @@ -1119,7 +1125,7 @@ class LegalizeRuleSet {
using namespace LegalizeMutations;
return actionIf(LegalizeAction::NarrowScalar,
scalarOrEltWiderThan(TypeIdx, Ty.getScalarSizeInBits()),
changeElementTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}

/// Ensure the scalar is at most as wide as Ty.
Expand All @@ -1128,7 +1134,7 @@ class LegalizeRuleSet {
using namespace LegalizeMutations;
return actionIf(LegalizeAction::NarrowScalar,
scalarWiderThan(TypeIdx, Ty.getSizeInBits()),
changeTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}

/// Conditionally limit the maximum size of the scalar.
Expand All @@ -1146,7 +1152,7 @@ class LegalizeRuleSet {
QueryTy.getSizeInBits() > Ty.getSizeInBits() &&
Predicate(Query);
},
changeElementTo(typeIdx(TypeIdx), Ty));
changeElementSizeTo(typeIdx(TypeIdx), Ty));
}

/// Limit the range of scalar sizes to MinTy and MaxTy.
Expand Down Expand Up @@ -1211,9 +1217,8 @@ class LegalizeRuleSet {
Predicate(Query);
},
[=](const LegalityQuery &Query) {
LLT T = Query.Types[LargeTypeIdx];
if (T.isPointerVector())
T = T.changeElementType(LLT::scalar(T.getScalarSizeInBits()));
LLT T = Query.Types[TypeIdx].changeElementSize(
Query.Types[LargeTypeIdx].getScalarSizeInBits());
return std::make_pair(TypeIdx, T);
});
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/LowLevelTypeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ LLVM_ABI LLT getLLTForMVT(MVT Ty);
/// Get the appropriate floating point arithmetic semantic based on the bit size
/// of the given scalar LLT.
LLVM_ABI const llvm::fltSemantics &getFltSemanticForLLT(LLT Ty);
}
} // namespace llvm

#endif // LLVM_CODEGEN_LOWLEVELTYPEUTILS_H
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/TargetLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class LLVM_ABI TargetLoweringBase {
/// G_INSERT_VECTOR_ELT, G_EXTRACT_VECTOR_ELT,
/// G_INSERT_SUBVECTOR, and G_EXTRACT_SUBVECTOR
LLT getVectorIdxLLT(const DataLayout &DL) const {
return LLT::scalar(getVectorIdxWidth(DL));
return LLT::integer(getVectorIdxWidth(DL));
}

/// Returns the type to be used for the EVL/AVL operand of VP nodes:
Expand Down
Loading