[llvm-commits] [llvm] r151781 - /llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
Jim Grosbach
grosbach at apple.com
Thu Mar 1 09:36:32 PST 2012
Thanks for jumping on all of these, Ben. Very nice improvements!
-Jim
On Feb 29, 2012, at 5:18 PM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Wed Feb 29 19:18:32 2012
> New Revision: 151781
>
> URL: http://llvm.org/viewvc/llvm-project?rev=151781&view=rev
> Log:
> Emit the intrinsic modref info as a lookup table instead of a huge switch.
>
> Shrinks BasicAliasAnalysis.o from 106k to 56k on i386.
>
> Modified:
> llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
>
> Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=151781&r1=151780&r2=151781&view=diff
> ==============================================================================
> --- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Wed Feb 29 19:18:32 2012
> @@ -618,34 +618,36 @@
> /// EmitModRefBehavior - Determine intrinsic alias analysis mod/ref behavior.
> void IntrinsicEmitter::
> EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
> - OS << "// Determine intrinsic alias analysis mod/ref behavior.\n";
> - OS << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n";
> - OS << "switch (iid) {\n";
> - OS << "default:\n return UnknownModRefBehavior;\n";
> + OS << "// Determine intrinsic alias analysis mod/ref behavior.\n"
> + << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n"
> + << "assert(iid <= Intrinsic::" << Ints.back().EnumName << " && "
> + << "\"Unknown intrinsic.\");\n\n";
> +
> + OS << "static const uint8_t IntrinsicModRefBehavior[] = {\n"
> + << " /* invalid */ UnknownModRefBehavior,\n";
> for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
> - if (Ints[i].ModRef == CodeGenIntrinsic::ReadWriteMem)
> - continue;
> - OS << "case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
> - << ":\n";
> + OS << " /* " << TargetPrefix << Ints[i].EnumName << " */ ";
> switch (Ints[i].ModRef) {
> - default:
> - assert(false && "Unknown Mod/Ref type!");
> case CodeGenIntrinsic::NoMem:
> - OS << " return DoesNotAccessMemory;\n";
> + OS << "DoesNotAccessMemory,\n";
> break;
> case CodeGenIntrinsic::ReadArgMem:
> - OS << " return OnlyReadsArgumentPointees;\n";
> + OS << "OnlyReadsArgumentPointees,\n";
> break;
> case CodeGenIntrinsic::ReadMem:
> - OS << " return OnlyReadsMemory;\n";
> + OS << "OnlyReadsMemory,\n";
> break;
> case CodeGenIntrinsic::ReadWriteArgMem:
> - OS << " return OnlyAccessesArgumentPointees;\n";
> + OS << "OnlyAccessesArgumentPointees,\n";
> + break;
> + case CodeGenIntrinsic::ReadWriteMem:
> + OS << "UnknownModRefBehavior,\n";
> break;
> }
> }
> - OS << "}\n";
> - OS << "#endif // GET_INTRINSIC_MODREF_BEHAVIOR\n\n";
> + OS << "};\n\n"
> + << "return static_cast<ModRefBehavior>(IntrinsicModRefBehavior[iid]);\n"
> + << "#endif // GET_INTRINSIC_MODREF_BEHAVIOR\n\n";
> }
>
> void IntrinsicEmitter::
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list