mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Added support to have TableGen provide information if an intrinsic (core
or target) can be overloaded or not. llvm-svn: 65404
This commit is contained in:
parent
936c18daca
commit
c9b4dab417
@ -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);
|
||||
|
@ -18,6 +18,7 @@ namespace llvm {
|
||||
|
||||
class Function;
|
||||
class Module;
|
||||
class Type;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
///
|
||||
@ -40,6 +41,18 @@ public:
|
||||
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; }
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -36,6 +36,9 @@ 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();
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user