summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2010-06-07 16:00:37 +0000
committerNate Begeman <natebegeman@mac.com>2010-06-07 16:00:37 +0000
commitb0a4e4554eb6c2ebefc9b0b05c4f788bc775bf66 (patch)
treeea0504f0132376b41fa12f5ac6a3e1a895a48904 /utils
parent3a4340d4cb7c8a4914075a93e762f5023f81d084 (diff)
downloadllvm-b0a4e4554eb6c2ebefc9b0b05c4f788bc775bf66.tar.gz
llvm-b0a4e4554eb6c2ebefc9b0b05c4f788bc775bf66.tar.bz2
llvm-b0a4e4554eb6c2ebefc9b0b05c4f788bc775bf66.tar.xz
clang codegen support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/NeonEmitter.cpp156
1 files changed, 83 insertions, 73 deletions
diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp
index 9647666935..2697348c05 100644
--- a/utils/TableGen/NeonEmitter.cpp
+++ b/utils/TableGen/NeonEmitter.cpp
@@ -100,24 +100,9 @@ static char ClassifyType(StringRef ty, bool &quad, bool &poly, bool &usgn) {
return ty[off];
}
-static std::string TypeString(const char mod, StringRef typestr,
- bool ret = false) {
- bool quad = false;
- bool poly = false;
- bool usgn = false;
- bool scal = false;
- bool cnst = false;
- bool pntr = false;
-
- // base type to get the type string for.
- char type = ClassifyType(typestr, quad, poly, usgn);
-
- // Based on the modifying character, change the type and width if necessary.
+static char ModType(const char mod, char type, bool &quad, bool &poly,
+ bool &usgn, bool &scal, bool &cnst, bool &pntr) {
switch (mod) {
- case 'v':
- return "void";
- case 'i':
- return "int";
case 't':
if (poly) {
poly = false;
@@ -155,6 +140,8 @@ static std::string TypeString(const char mod, StringRef typestr,
case 'c':
cnst = true;
case 'p':
+ usgn = false;
+ poly = false;
pntr = true;
scal = true;
break;
@@ -168,6 +155,28 @@ static std::string TypeString(const char mod, StringRef typestr,
default:
break;
}
+ return type;
+}
+
+static std::string TypeString(const char mod, StringRef typestr,
+ bool ret = false) {
+ bool quad = false;
+ bool poly = false;
+ bool usgn = false;
+ bool scal = false;
+ bool cnst = false;
+ bool pntr = false;
+
+ if (mod == 'v')
+ return "void";
+ if (mod == 'i')
+ return "int";
+
+ // base type to get the type string for.
+ char type = ClassifyType(typestr, quad, poly, usgn);
+
+ // Based on the modifying character, change the type and width if necessary.
+ type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr);
SmallString<128> s;
@@ -256,60 +265,11 @@ static std::string BuiltinTypeString(const char mod, StringRef typestr,
char type = ClassifyType(typestr, quad, poly, usgn);
// Based on the modifying character, change the type and width if necessary.
- switch (mod) {
- case 't':
- if (poly) {
- poly = false;
- usgn = true;
- }
- break;
- case 'x':
- usgn = true;
- poly = false;
- if (type == 'f')
- type = 'i';
- break;
- case 'f':
- type = 'f';
- usgn = false;
- break;
- case 'w':
- type = Widen(type);
- quad = true;
- break;
- case 'n':
- type = Widen(type);
- break;
- case 'l':
- type = 'l';
- scal = true;
- usgn = true;
- break;
- case 's':
- scal = true;
- break;
- case 'k':
- quad = true;
- break;
- case 'c':
- cnst = true;
- case 'p':
- type = 'v';
- usgn = false;
- poly = false;
- pntr = true;
- scal = true;
- break;
- case 'h':
- type = Narrow(type);
- break;
- case 'e':
- type = Narrow(type);
- usgn = true;
- break;
- default:
- break;
- }
+ type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr);
+
+ if (pntr)
+ type = 'v';
+
if (type == 'h') {
type = 's';
usgn = true;
@@ -534,6 +494,57 @@ static std::string GenOpString(OpKind op, const std::string &proto,
return s;
}
+static unsigned GetNeonEnum(const std::string &proto, StringRef typestr) {
+ unsigned mod = proto[0];
+ unsigned ret = 0;
+
+ if (mod == 'v')
+ mod = proto[1];
+
+ bool quad = false;
+ bool poly = false;
+ bool usgn = false;
+ bool scal = false;
+ bool cnst = false;
+ bool pntr = false;
+
+ // base type to get the type string for.
+ char type = ClassifyType(typestr, quad, poly, usgn);
+
+ // Based on the modifying character, change the type and width if necessary.
+ type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr);
+
+ if (usgn)
+ ret |= 0x08;
+ if (quad)
+ ret |= 0x10;
+
+ switch (type) {
+ case 'c':
+ ret |= poly ? 5 : 0;
+ break;
+ case 's':
+ ret |= poly ? 6 : 1;
+ break;
+ case 'i':
+ ret |= 2;
+ break;
+ case 'l':
+ ret |= 3;
+ break;
+ case 'h':
+ ret |= 7;
+ break;
+ case 'f':
+ ret |= 4;
+ break;
+ default:
+ throw "unhandled type!";
+ break;
+ }
+ return ret;
+}
+
// Generate the definition for this intrinsic, e.g. __builtin_neon_cls(a)
// If structTypes is true, the NEON types are structs of vector types rather
// than vector types, and the call becomes __builtin_neon_cls(a.val)
@@ -599,9 +610,8 @@ static std::string GenBuiltin(const std::string &name, const std::string &proto,
}
// Extra constant integer to hold type class enum for this function, e.g. s8
- // FIXME: emit actual type num.
if (ck == ClassB)
- s += ", 0";
+ s += ", " + utostr(GetNeonEnum(proto, typestr));
s += ");";