ARM NEON:

fix vcvt naming
handle vdup, vcombine with generic vector code

llvm-svn: 105588
This commit is contained in:
Nate Begeman 2010-06-08 00:14:42 +00:00
parent 846bd7992c
commit fe123268a9
2 changed files with 56 additions and 12 deletions

View File

@ -70,6 +70,8 @@ static char Narrow(const char t) {
return 's'; return 's';
case 'l': case 'l':
return 'i'; return 'i';
case 'f':
return 'h';
default: throw "unhandled type in widen!"; default: throw "unhandled type in widen!";
} }
return '\0'; return '\0';
@ -109,13 +111,16 @@ static char ModType(const char mod, char type, bool &quad, bool &poly,
usgn = true; usgn = true;
} }
break; break;
case 'x': case 'u':
usgn = true; usgn = true;
case 'x':
poly = false; poly = false;
if (type == 'f') if (type == 'f')
type = 'i'; type = 'i';
break; break;
case 'f': case 'f':
if (type == 'h')
quad = true;
type = 'f'; type = 'f';
usgn = false; usgn = false;
break; break;
@ -147,6 +152,8 @@ static char ModType(const char mod, char type, bool &quad, bool &poly,
break; break;
case 'h': case 'h':
type = Narrow(type); type = Narrow(type);
if (type == 'h')
quad = false;
break; break;
case 'e': case 'e':
type = Narrow(type); type = Narrow(type);
@ -303,7 +310,9 @@ static std::string BuiltinTypeString(const char mod, StringRef typestr,
return quad ? "V48c" : "V24c"; return quad ? "V48c" : "V24c";
if (mod == '4') if (mod == '4')
return quad ? "V64c" : "V32c"; return quad ? "V64c" : "V32c";
if (mod == 'f')
return quad ? "V4f" : "V2f";
return quad ? "V16c" : "V8c"; return quad ? "V16c" : "V8c";
} }
@ -314,6 +323,8 @@ static std::string BuiltinTypeString(const char mod, StringRef typestr,
return quad ? "V16cV16cV16c" : "V8cV8cV8c"; return quad ? "V16cV16cV16c" : "V8cV8cV8c";
if (mod == '4') if (mod == '4')
return quad ? "V16cV16cV16cV16c" : "V8cV8cV8cV8c"; return quad ? "V16cV16cV16cV16c" : "V8cV8cV8cV8c";
if (mod == 'f')
return quad ? "V4f" : "V2f";
return quad ? "V16c" : "V8c"; return quad ? "V16c" : "V8c";
} }
@ -321,6 +332,9 @@ static std::string BuiltinTypeString(const char mod, StringRef typestr,
// Turn "vst2_lane" into "vst2q_lane_f32", etc. // Turn "vst2_lane" into "vst2q_lane_f32", etc.
static std::string MangleName(const std::string &name, StringRef typestr, static std::string MangleName(const std::string &name, StringRef typestr,
ClassKind ck) { ClassKind ck) {
if (name == "vcvt_f32_f16")
return name;
bool quad = false; bool quad = false;
bool poly = false; bool poly = false;
bool usgn = false; bool usgn = false;
@ -417,14 +431,30 @@ static std::string GenArgs(const std::string &proto, StringRef typestr) {
// than vector types, and the call becomes "a.val + b.val" // than vector types, and the call becomes "a.val + b.val"
static std::string GenOpString(OpKind op, const std::string &proto, static std::string GenOpString(OpKind op, const std::string &proto,
StringRef typestr, bool structTypes = true) { StringRef typestr, bool structTypes = true) {
std::string s("return ");
std::string ts = TypeString(proto[0], typestr); std::string ts = TypeString(proto[0], typestr);
if (structTypes) std::string s = ts + " r; r";
s += "(" + ts + "){";
bool quad, dummy;
char type = ClassifyType(typestr, quad, dummy, dummy);
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;
}
nElts <<= quad;
if (structTypes)
s += ".val";
s += " = ";
std::string a, b, c; std::string a, b, c;
if (proto.size() > 1) if (proto.size() > 1)
a = (structTypes && proto[1] != 'l') ? "a.val" : "a"; a = (structTypes && proto[1] != 'l' && proto[1] != 's') ? "a.val" : "a";
b = structTypes ? "b.val" : "b"; b = structTypes ? "b.val" : "b";
c = structTypes ? "c.val" : "c"; c = structTypes ? "c.val" : "c";
@ -483,14 +513,24 @@ static std::string GenOpString(OpKind op, const std::string &proto,
case OpCast: case OpCast:
s += "(__neon_" + ts + ")" + a; s += "(__neon_" + ts + ")" + a;
break; break;
case OpConcat:
s += "__builtin_shufflevector((__neon_int64x1_t)" + a;
s += ", (__neon_int64x1_t)" + b + ", 0, 1)";
break;
case OpDup:
s += "(__neon_" + ts + "){ ";
for (unsigned i = 0; i != nElts; ++i) {
s += a;
if ((i + 1) < nElts)
s += ", ";
}
s += " }";
break;
default: default:
throw "unknown OpKind!"; throw "unknown OpKind!";
break; break;
} }
s += "; return r;";
if (structTypes)
s += "}";
s += ";";
return s; return s;
} }
@ -498,7 +538,7 @@ static unsigned GetNeonEnum(const std::string &proto, StringRef typestr) {
unsigned mod = proto[0]; unsigned mod = proto[0];
unsigned ret = 0; unsigned ret = 0;
if (mod == 'v') if (mod == 'v' || mod == 'f')
mod = proto[1]; mod = proto[1];
bool quad = false; bool quad = false;

View File

@ -40,7 +40,9 @@ enum OpKind {
OpXor, OpXor,
OpAndNot, OpAndNot,
OpOrNot, OpOrNot,
OpCast OpCast,
OpConcat,
OpDup
}; };
enum ClassKind { enum ClassKind {
@ -79,6 +81,8 @@ namespace llvm {
OpMap["OP_ANDN"] = OpAndNot; OpMap["OP_ANDN"] = OpAndNot;
OpMap["OP_ORN"] = OpOrNot; OpMap["OP_ORN"] = OpOrNot;
OpMap["OP_CAST"] = OpCast; OpMap["OP_CAST"] = OpCast;
OpMap["OP_CONC"] = OpConcat;
OpMap["OP_DUP"] = OpDup;
Record *SI = R.getClass("SInst"); Record *SI = R.getClass("SInst");
Record *II = R.getClass("IInst"); Record *II = R.getClass("IInst");