Checkpoint; handle 'int' and 'void' correctly

llvm-svn: 105316
This commit is contained in:
Nate Begeman 2010-06-02 07:14:28 +00:00
parent d86d60f91d
commit 68d0518b92
1 changed files with 52 additions and 25 deletions

View File

@ -23,6 +23,27 @@
using namespace llvm; using namespace llvm;
enum OpKind {
OpNone,
OpAdd,
OpSub,
OpMul,
OpMla,
OpMls,
OpEq,
OpGe,
OpLe,
OpGt,
OpLt,
OpNeg,
OpNot,
OpAnd,
OpOr,
OpXor,
OpAndNot,
OpOrNot
};
static void ParseTypes(Record *r, std::string &s, static void ParseTypes(Record *r, std::string &s,
SmallVectorImpl<StringRef> &TV) { SmallVectorImpl<StringRef> &TV) {
const char *data = s.data(); const char *data = s.data();
@ -103,10 +124,9 @@ static std::string TypeString(const char mod, StringRef typestr) {
// Based on the modifying character, change the type and width if necessary. // Based on the modifying character, change the type and width if necessary.
switch (mod) { switch (mod) {
case 'v': case 'v':
type = 'v'; return "void";
scal = true; case 'i':
usgn = false; return "int";
break;
case 't': case 't':
if (poly) { if (poly) {
poly = false; poly = false;
@ -128,11 +148,6 @@ static std::string TypeString(const char mod, StringRef typestr) {
case 'n': case 'n':
type = Widen(type); type = Widen(type);
break; break;
case 'i':
type = 'i';
scal = true;
usgn = false;
break;
case 'l': case 'l':
type = 'l'; type = 'l';
scal = true; scal = true;
@ -196,9 +211,6 @@ static std::string TypeString(const char mod, StringRef typestr) {
break; break;
s += quad ? "x4" : "x2"; s += quad ? "x4" : "x2";
break; break;
case 'v':
s += "void";
break;
default: default:
throw "unhandled type!"; throw "unhandled type!";
break; break;
@ -284,6 +296,18 @@ static std::string GenArgs(const std::string &proto, StringRef typestr) {
return s; return s;
} }
static OpKind ParseOp(Record *R) {
return OpNone;
}
static std::string GenOpstring(OpKind op) {
return "";
}
static std::string GenBuiltin(std::string &name) {
return "";
}
void NeonEmitter::run(raw_ostream &OS) { void NeonEmitter::run(raw_ostream &OS) {
EmitSourceFileHeader("ARM NEON Header", OS); EmitSourceFileHeader("ARM NEON Header", OS);
@ -302,8 +326,6 @@ void NeonEmitter::run(raw_ostream &OS) {
std::vector<Record*> RV = Records.getAllDerivedDefinitions("Inst"); std::vector<Record*> RV = Records.getAllDerivedDefinitions("Inst");
// Initialize Type Map
// Unique the return+pattern types, and assign them. // Unique the return+pattern types, and assign them.
for (unsigned i = 0, e = RV.size(); i != e; ++i) { for (unsigned i = 0, e = RV.size(); i != e; ++i) {
Record *R = RV[i]; Record *R = RV[i];
@ -314,24 +336,29 @@ void NeonEmitter::run(raw_ostream &OS) {
SmallVector<StringRef, 16> TypeVec; SmallVector<StringRef, 16> TypeVec;
ParseTypes(R, Types, TypeVec); ParseTypes(R, Types, TypeVec);
OpKind k = ParseOp(R);
for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) {
assert(!Proto.empty() && ""); assert(!Proto.empty() && "");
SmallString<128> Prototype; // Return type
Prototype += TypeString(Proto[0], TypeVec[ti]); OS << TypeString(Proto[0], TypeVec[ti]);
Prototype += " ";
Prototype += MangleName(name, TypeVec[ti]);
Prototype += GenArgs(Proto, TypeVec[ti]);
OS << Prototype << ";\n"; // Function name with type suffix
OS << " " << MangleName(name, TypeVec[ti]);
// gen definition // Function arguments
OS << GenArgs(Proto, TypeVec[ti]);
// if (opcode)
// gen opstring // Definition.
OS << " { ";
// gen builtin (args) if (k != OpNone)
OS << GenOpstring(k);
else
OS << GenBuiltin(name);
OS << "}\n";
} }
OS << "\n"; OS << "\n";
} }