mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Refactor to new GetNumElements function.
No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3380f6a4d0
commit
b308b62e6a
@ -483,10 +483,9 @@ static std::string Duplicate(unsigned nElts, StringRef typestr,
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the definition for this intrinsic, e.g. "a + b" for OpAdd.
|
static unsigned GetNumElements(StringRef typestr, bool &quad) {
|
||||||
static std::string GenOpString(OpKind op, const std::string &proto,
|
quad = false;
|
||||||
StringRef typestr) {
|
bool dummy = false;
|
||||||
bool dummy, quad = false;
|
|
||||||
char type = ClassifyType(typestr, quad, dummy, dummy);
|
char type = ClassifyType(typestr, quad, dummy, dummy);
|
||||||
unsigned nElts = 0;
|
unsigned nElts = 0;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -496,7 +495,19 @@ static std::string GenOpString(OpKind op, const std::string &proto,
|
|||||||
case 'l': nElts = 1; break;
|
case 'l': nElts = 1; break;
|
||||||
case 'h': nElts = 4; break;
|
case 'h': nElts = 4; break;
|
||||||
case 'f': nElts = 2; break;
|
case 'f': nElts = 2; break;
|
||||||
|
default:
|
||||||
|
throw "unhandled type!";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (quad) nElts <<= 1;
|
||||||
|
return nElts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the definition for this intrinsic, e.g. "a + b" for OpAdd.
|
||||||
|
static std::string GenOpString(OpKind op, const std::string &proto,
|
||||||
|
StringRef typestr) {
|
||||||
|
bool quad;
|
||||||
|
unsigned nElts = GetNumElements(typestr, quad);
|
||||||
|
|
||||||
std::string ts = TypeString(proto[0], typestr);
|
std::string ts = TypeString(proto[0], typestr);
|
||||||
std::string s;
|
std::string s;
|
||||||
@ -516,19 +527,19 @@ static std::string GenOpString(OpKind op, const std::string &proto,
|
|||||||
s += "a - b";
|
s += "a - b";
|
||||||
break;
|
break;
|
||||||
case OpMulN:
|
case OpMulN:
|
||||||
s += "a * " + Duplicate(nElts << (int)quad, typestr, "b");
|
s += "a * " + Duplicate(nElts, typestr, "b");
|
||||||
break;
|
break;
|
||||||
case OpMul:
|
case OpMul:
|
||||||
s += "a * b";
|
s += "a * b";
|
||||||
break;
|
break;
|
||||||
case OpMlaN:
|
case OpMlaN:
|
||||||
s += "a + (b * " + Duplicate(nElts << (int)quad, typestr, "c") + ")";
|
s += "a + (b * " + Duplicate(nElts, typestr, "c") + ")";
|
||||||
break;
|
break;
|
||||||
case OpMla:
|
case OpMla:
|
||||||
s += "a + (b * c)";
|
s += "a + (b * c)";
|
||||||
break;
|
break;
|
||||||
case OpMlsN:
|
case OpMlsN:
|
||||||
s += "a - (b * " + Duplicate(nElts << (int)quad, typestr, "c") + ")";
|
s += "a - (b * " + Duplicate(nElts, typestr, "c") + ")";
|
||||||
break;
|
break;
|
||||||
case OpMls:
|
case OpMls:
|
||||||
s += "a - (b * c)";
|
s += "a - (b * c)";
|
||||||
@ -583,7 +594,7 @@ static std::string GenOpString(OpKind op, const std::string &proto,
|
|||||||
s += "(((float64x2_t)a)[0])";
|
s += "(((float64x2_t)a)[0])";
|
||||||
break;
|
break;
|
||||||
case OpDup:
|
case OpDup:
|
||||||
s += Duplicate(nElts << (int)quad, typestr, "a");
|
s += Duplicate(nElts, typestr, "a");
|
||||||
break;
|
break;
|
||||||
case OpSelect:
|
case OpSelect:
|
||||||
// ((0 & 1) | (~0 & 2))
|
// ((0 & 1) | (~0 & 2))
|
||||||
@ -593,26 +604,29 @@ static std::string GenOpString(OpKind op, const std::string &proto,
|
|||||||
break;
|
break;
|
||||||
case OpRev16:
|
case OpRev16:
|
||||||
s += "__builtin_shufflevector(a, a";
|
s += "__builtin_shufflevector(a, a";
|
||||||
for (unsigned i = 2; i <= nElts << (int)quad; i += 2)
|
for (unsigned i = 2; i <= nElts; i += 2)
|
||||||
for (unsigned j = 0; j != 2; ++j)
|
for (unsigned j = 0; j != 2; ++j)
|
||||||
s += ", " + utostr(i - j - 1);
|
s += ", " + utostr(i - j - 1);
|
||||||
s += ")";
|
s += ")";
|
||||||
break;
|
break;
|
||||||
case OpRev32:
|
case OpRev32: {
|
||||||
nElts >>= 1;
|
unsigned WordElts = nElts >> (1 + (int)quad);
|
||||||
s += "__builtin_shufflevector(a, a";
|
s += "__builtin_shufflevector(a, a";
|
||||||
for (unsigned i = nElts; i <= nElts << (1 + (int)quad); i += nElts)
|
for (unsigned i = WordElts; i <= nElts; i += WordElts)
|
||||||
for (unsigned j = 0; j != nElts; ++j)
|
for (unsigned j = 0; j != WordElts; ++j)
|
||||||
s += ", " + utostr(i - j - 1);
|
s += ", " + utostr(i - j - 1);
|
||||||
s += ")";
|
s += ")";
|
||||||
break;
|
break;
|
||||||
case OpRev64:
|
}
|
||||||
|
case OpRev64: {
|
||||||
|
unsigned DblWordElts = nElts >> (int)quad;
|
||||||
s += "__builtin_shufflevector(a, a";
|
s += "__builtin_shufflevector(a, a";
|
||||||
for (unsigned i = nElts; i <= nElts << (int)quad; i += nElts)
|
for (unsigned i = DblWordElts; i <= nElts; i += DblWordElts)
|
||||||
for (unsigned j = 0; j != nElts; ++j)
|
for (unsigned j = 0; j != DblWordElts; ++j)
|
||||||
s += ", " + utostr(i - j - 1);
|
s += ", " + utostr(i - j - 1);
|
||||||
s += ")";
|
s += ")";
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw "unknown OpKind!";
|
throw "unknown OpKind!";
|
||||||
break;
|
break;
|
||||||
@ -678,19 +692,8 @@ static unsigned GetNeonEnum(const std::string &proto, StringRef typestr) {
|
|||||||
// Generate the definition for this intrinsic, e.g. __builtin_neon_cls(a)
|
// Generate the definition for this intrinsic, e.g. __builtin_neon_cls(a)
|
||||||
static std::string GenBuiltin(const std::string &name, const std::string &proto,
|
static std::string GenBuiltin(const std::string &name, const std::string &proto,
|
||||||
StringRef typestr, ClassKind ck) {
|
StringRef typestr, ClassKind ck) {
|
||||||
bool dummy, quad = false;
|
bool quad;
|
||||||
char type = ClassifyType(typestr, quad, dummy, dummy);
|
unsigned nElts = GetNumElements(typestr, quad);
|
||||||
unsigned nElts = 0;
|
|
||||||
switch (type) {
|
|
||||||
case 'c': nElts = 8; break;
|
|
||||||
case 's': nElts = 4; break;
|
|
||||||
case 'i': nElts = 2; break;
|
|
||||||
case 'l': nElts = 1; break;
|
|
||||||
case 'h': nElts = 4; break;
|
|
||||||
case 'f': nElts = 2; break;
|
|
||||||
}
|
|
||||||
if (quad) nElts <<= 1;
|
|
||||||
|
|
||||||
char arg = 'a';
|
char arg = 'a';
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user