#include <cassert>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <vector>
#define GENERATE_NEON
#define GENERATE_NEON_INS
struct Operator;
static inline unsigned short MakeMask(unsigned V0, unsigned V1,
unsigned V2, unsigned V3) { … }
static unsigned getMaskElt(unsigned Mask, unsigned Elt) { … }
static unsigned setMaskElt(unsigned Mask, unsigned Elt, unsigned NewVal) { … }
static bool isValidMask(unsigned short Mask) { … }
static bool hasUndefElements(unsigned short Mask) { … }
static bool isOnlyLHSMask(unsigned short Mask) { … }
#if 0
static unsigned short getLHSOnlyMask(unsigned short Mask) {
return Mask & 0xBBBB;
}
#endif
static unsigned getCompressedMask(unsigned short Mask) { … }
static void PrintMask(unsigned i, std::ostream &OS) { … }
struct ShuffleVal { … };
static ShuffleVal ShufTab[65536];
static std::vector<Operator*> TheOperators;
struct Operator { … };
#ifdef GENERATE_NEON_INS
static Operator InsOp(0, "ins", 15, 1);
#endif
static const char *getZeroCostOpName(unsigned short Op) { … }
static void PrintOperation(unsigned ValNo, unsigned short Vals[]) { … }
static unsigned getNumEntered() { … }
static void EvaluateOps(unsigned short Elt, unsigned short Vals[],
unsigned &NumVals) { … }
int main() { … }
#ifdef GENERATE_ALTIVEC
enum {
OP_COPY = 0,
OP_VMRGHW,
OP_VMRGLW,
OP_VSPLTISW0,
OP_VSPLTISW1,
OP_VSPLTISW2,
OP_VSPLTISW3,
OP_VSLDOI4,
OP_VSLDOI8,
OP_VSLDOI12
};
struct vmrghw : public Operator {
vmrghw() : Operator(0x0415, "vmrghw", OP_VMRGHW) {}
} the_vmrghw;
struct vmrglw : public Operator {
vmrglw() : Operator(0x2637, "vmrglw", OP_VMRGLW) {}
} the_vmrglw;
template<unsigned Elt>
struct vspltisw : public Operator {
vspltisw(const char *N, unsigned Opc)
: Operator(MakeMask(Elt, Elt, Elt, Elt), N, Opc) {}
};
vspltisw<0> the_vspltisw0("vspltisw0", OP_VSPLTISW0);
vspltisw<1> the_vspltisw1("vspltisw1", OP_VSPLTISW1);
vspltisw<2> the_vspltisw2("vspltisw2", OP_VSPLTISW2);
vspltisw<3> the_vspltisw3("vspltisw3", OP_VSPLTISW3);
template<unsigned N>
struct vsldoi : public Operator {
vsldoi(const char *Name, unsigned Opc)
: Operator(MakeMask(N&7, (N+1)&7, (N+2)&7, (N+3)&7), Name, Opc) {
}
};
vsldoi<1> the_vsldoi1("vsldoi4" , OP_VSLDOI4);
vsldoi<2> the_vsldoi2("vsldoi8" , OP_VSLDOI8);
vsldoi<3> the_vsldoi3("vsldoi12", OP_VSLDOI12);
#endif
#ifdef GENERATE_NEON
enum { … };
struct vrev : public Operator { … } the_vrev;
template<unsigned Elt>
struct vdup : public Operator { … };
vdup<0> the_vdup0("vdup0", OP_VDUP0);
vdup<1> the_vdup1("vdup1", OP_VDUP1);
vdup<2> the_vdup2("vdup2", OP_VDUP2);
vdup<3> the_vdup3("vdup3", OP_VDUP3);
template<unsigned N>
struct vext : public Operator { … };
vext<1> the_vext1("vext1", OP_VEXT1);
vext<2> the_vext2("vext2", OP_VEXT2);
vext<3> the_vext3("vext3", OP_VEXT3);
struct vuzpl : public Operator { … } the_vuzpl;
struct vuzpr : public Operator { … } the_vuzpr;
struct vzipl : public Operator { … } the_vzipl;
struct vzipr : public Operator { … } the_vzipr;
struct vtrnl : public Operator { … } the_vtrnl;
struct vtrnr : public Operator { … } the_vtrnr;
#endif