Added support to have TableGen provide information if an intrinsic (core

or target) can be overloaded or not.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mon P Wang 2009-02-24 23:17:49 +00:00
parent d8e880c670
commit 0d52ff1f7b
5 changed files with 51 additions and 2 deletions

View File

@ -49,6 +49,10 @@ namespace Intrinsic {
///
const FunctionType *getType(ID id, const Type **Tys = 0, unsigned numTys = 0);
/// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
/// overloaded.
bool isOverloaded(ID id);
/// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic.
///
AttrListPtr getAttributes(ID id);

View File

@ -18,6 +18,7 @@ namespace llvm {
class Function;
class Module;
class Type;
//---------------------------------------------------------------------------
///
@ -39,7 +40,19 @@ public:
virtual Function *getDeclaration(Module *M, const char *BuiltinName) const {
return 0;
}
// Returns the Function declaration for intrinsic BuiltinName. If the
// intrinsic can be overloaded, uses Tys to return the correct function.
virtual Function *getDeclaration(Module *M, const char *BuiltinName,
const Type **Tys, unsigned numTys) const {
return 0;
}
// Returns true if the Builtin can be overloaded.
virtual bool isOverloaded(Module *M, const char *BuiltinName) const {
return false;
}
virtual unsigned getIntrinsicID(Function *F) const { return 0; }
};

View File

@ -356,6 +356,16 @@ const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
return FunctionType::get(ResultTy, ArgTys, IsVarArg);
}
bool Intrinsic::isOverloaded(ID id) {
const bool OTable[] = {
false,
#define GET_INTRINSIC_OVERLOAD_TABLE
#include "llvm/Intrinsics.gen"
#undef GET_INTRINSIC_OVERLOAD_TABLE
};
return OTable[id];
}
/// This defines the "Intrinsic::getAttributes(ID id)" method.
#define GET_INTRINSIC_ATTRIBUTES
#include "llvm/Intrinsics.gen"

View File

@ -35,7 +35,10 @@ void IntrinsicEmitter::run(std::ostream &OS) {
// Emit the intrinsic ID -> name table.
EmitIntrinsicToNameTable(Ints, OS);
// Emit the intrinsic ID -> overload table.
EmitIntrinsicToOverloadTable(Ints, OS);
// Emit the function name recognizer.
EmitFnNameRecognizer(Ints, OS);
@ -120,6 +123,23 @@ EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
OS << "#endif\n\n";
}
void IntrinsicEmitter::
EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS) {
OS << "// Intrinsic ID to overload table\n";
OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n";
OS << " // Note that entry #0 is the invalid intrinsic!\n";
for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
OS << " ";
if (Ints[i].isOverloaded)
OS << "true";
else
OS << "false";
OS << ",\n";
}
OS << "#endif\n\n";
}
static void EmitTypeForValueType(std::ostream &OS, MVT::SimpleValueType VT) {
if (MVT(VT).isInteger()) {
unsigned BitWidth = MVT(VT).getSizeInBits();

View File

@ -36,6 +36,8 @@ namespace llvm {
std::ostream &OS);
void EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
void EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
void EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
void EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints,