From 36a2138cce66a164f08a36c4c5820b133c4590fd Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 1 Mar 2012 02:16:57 +0000 Subject: [PATCH] Emit the "is an intrinsic overloaded" table as a bitfield. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151792 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp | 11 ++++------- lib/VMCore/Function.cpp | 4 ---- utils/TableGen/IntrinsicEmitter.cpp | 17 ++++++++++------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp b/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp index b3651158a37..91aaf940e62 100644 --- a/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp +++ b/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp @@ -74,16 +74,13 @@ lookupGCCName(const char *Name) const { } bool MBlazeIntrinsicInfo::isOverloaded(unsigned IntrID) const { - // Overload Table - const bool OTable[] = { + if (IntrID == 0) + return false; + + unsigned id = IntrID - Intrinsic::num_intrinsics + 1; #define GET_INTRINSIC_OVERLOAD_TABLE #include "MBlazeGenIntrinsics.inc" #undef GET_INTRINSIC_OVERLOAD_TABLE - }; - if (IntrID == 0) - return false; - else - return OTable[IntrID - Intrinsic::num_intrinsics]; } /// This defines the "getAttributes(ID id)" method. diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 8238f632152..af6344ef616 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -372,13 +372,9 @@ FunctionType *Intrinsic::getType(LLVMContext &Context, } bool Intrinsic::isOverloaded(ID id) { - static 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. diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index c5e36239a53..578b3aa2439 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -160,17 +160,20 @@ EmitIntrinsicToNameTable(const std::vector &Ints, void IntrinsicEmitter:: EmitIntrinsicToOverloadTable(const std::vector &Ints, raw_ostream &OS) { - OS << "// Intrinsic ID to overload table\n"; + OS << "// Intrinsic ID to overload bitset\n"; OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n"; - OS << " // Note that entry #0 is the invalid intrinsic!\n"; + OS << "static const uint8_t OTable[] = {\n"; + OS << " 0"; for (unsigned i = 0, e = Ints.size(); i != e; ++i) { - OS << " "; + // Add one to the index so we emit a null bit for the invalid #0 intrinsic. + if ((i+1)%8 == 0) + OS << ",\n 0"; if (Ints[i].isOverloaded) - OS << "true"; - else - OS << "false"; - OS << ",\n"; + OS << " | (1<<" << (i+1)%8 << ')'; } + OS << "\n};\n\n"; + // OTable contains a true bit at the position if the intrinsic is overloaded. + OS << "return (OTable[id/8] & (1 << (id%8))) != 0;\n"; OS << "#endif\n\n"; }