14#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64PERFECTSHUFFLE_H
15#define LLVM_LIB_TARGET_AARCH64_AARCH64PERFECTSHUFFLE_H
6593 assert(M.size() == 4 &&
"Expected a 4 entry perfect shuffle");
6597 return E.value() < 0 ||
E.value() == (
int)
E.index();
6601 return E.value() < 0 ||
E.value() == (
int)
E.index() + 4;
6607 unsigned PFIndexes[4];
6608 for (
unsigned i = 0; i != 4; ++i) {
6609 assert(M[i] < 8 &&
"Expected a maximum entry of 8 for shuffle mask");
6613 PFIndexes[i] = M[i];
6617 unsigned PFTableIndex = PFIndexes[0] * 9 * 9 * 9 + PFIndexes[1] * 9 * 9 +
6618 PFIndexes[2] * 9 + PFIndexes[3];
6621 return (PFEntry >> 30) + 1;
6628 unsigned &WhichResultOut) {
6629 if (NumElts % 2 != 0)
6632 unsigned WhichResult = 2;
6633 for (
unsigned i = 0; i != NumElts / 2; i++) {
6634 if (M[i * 2] >= 0) {
6635 WhichResult = ((
unsigned)M[i * 2] == i ? 0 : 1);
6637 }
else if (M[i * 2 + 1] >= 0) {
6638 WhichResult = ((
unsigned)M[i * 2 + 1] == NumElts + i ? 0 : 1);
6642 if (WhichResult == 2)
6646 unsigned Idx = WhichResult * NumElts / 2;
6647 for (
unsigned i = 0; i != NumElts; i += 2) {
6648 if ((M[i] >= 0 && (
unsigned)M[i] !=
Idx) ||
6649 (M[i + 1] >= 0 && (
unsigned)M[i + 1] !=
Idx + NumElts))
6653 WhichResultOut = WhichResult;
6661 unsigned &WhichResultOut) {
6663 unsigned WhichResult = 2;
6664 for (
unsigned i = 0; i != NumElts; i++) {
6666 WhichResult = ((
unsigned)M[i] == i * 2 ? 0 : 1);
6670 if (WhichResult == 2)
6674 for (
unsigned i = 0; i != NumElts; ++i) {
6677 if ((
unsigned)M[i] != 2 * i + WhichResult)
6680 WhichResultOut = WhichResult;
6688 unsigned &WhichResult) {
6689 if (NumElts % 2 != 0)
6691 WhichResult = (M[0] == 0 ? 0 : 1);
6692 for (
unsigned i = 0; i < NumElts; i += 2) {
6693 if ((M[i] >= 0 && (
unsigned)M[i] != i + WhichResult) ||
6694 (M[i + 1] >= 0 && (
unsigned)M[i + 1] != i + NumElts + WhichResult))
6707 "Only possible block sizes for REV are: 16, 32, 64, 128");
6709 unsigned BlockElts = M[0] + 1;
6717 for (
unsigned i = 0; i < NumElts; ++i) {
6720 if ((
unsigned)M[i] != (i - i % BlockElts) + (BlockElts - 1 - i % BlockElts))
6730 unsigned SegmentSize) {
6734 if (SegmentSize * Segments != Mask.size())
6735 return std::nullopt;
6738 if (Lane >= SegmentSize)
6739 return std::nullopt;
6744 const unsigned SegmentIndex =
P.index() / SegmentSize;
6745 return P.value() < 0 ||
6746 unsigned(
P.value()) == Lane + SegmentIndex * SegmentSize;
6750 return std::nullopt;
6755 unsigned SegmentSize) {
6757 if (SegmentSize * Segments != Mask.size())
6763 const unsigned IndexWithinSegment =
P.index() % SegmentSize;
6764 return P.value() < 0 ||
unsigned(
P.value()) == IndexWithinSegment;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static const int BlockSize
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an optimization pass for GlobalISel generic memory operations.
std::optional< unsigned > isDUPQMask(ArrayRef< int > Mask, unsigned Segments, unsigned SegmentSize)
isDUPQMask - matches a splat of equivalent lanes within segments of a given number of elements.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
bool isDUPFirstSegmentMask(ArrayRef< int > Mask, unsigned Segments, unsigned SegmentSize)
isDUPFirstSegmentMask - matches a splat of the first 128b segment.
bool isTRNMask(ArrayRef< int > M, unsigned NumElts, unsigned &WhichResult)
Return true for trn1 or trn2 masks of the form: <0, 8, 2, 10, 4, 12, 6, 14> or <1,...
unsigned getPerfectShuffleCost(llvm::ArrayRef< int > M)
bool isUZPMask(ArrayRef< int > M, unsigned NumElts, unsigned &WhichResultOut)
Return true for uzp1 or uzp2 masks of the form: <0, 2, 4, 6, 8, 10, 12, 14> or <1,...
bool isREVMask(ArrayRef< int > M, unsigned EltSize, unsigned NumElts, unsigned BlockSize)
isREVMask - Check if a vector shuffle corresponds to a REV instruction with the specified blocksize.
bool isZIPMask(ArrayRef< int > M, unsigned NumElts, unsigned &WhichResultOut)
Return true for zip1 or zip2 masks of the form: <0, 8, 1, 9, 2, 10, 3, 11> or <4, 12,...
static const unsigned PerfectShuffleTable[6561+1]