make tblgen emit the entire Intrinsic::getAttributes method,
authorChris Lattner <sabre@nondot.org>
Mon, 12 Jan 2009 01:18:58 +0000 (01:18 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Jan 2009 01:18:58 +0000 (01:18 +0000)
not a random piece of it.  No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62066 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Function.cpp
utils/TableGen/IntrinsicEmitter.cpp

index 8eaff880ee40613451609298b049af7692cfefa7..bda2eff4c99c3b48140e1ac7938f8e6fa225f742 100644 (file)
@@ -359,20 +359,11 @@ const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
   return FunctionType::get(ResultTy, ArgTys, IsVarArg); 
 }
 
-AttrListPtr Intrinsic::getAttributes(ID id) {
-  Attributes Attr = Attribute::None;
-
+/// This defines the "Intrinsic::getAttributes(ID id)" method.
 #define GET_INTRINSIC_ATTRIBUTES
 #include "llvm/Intrinsics.gen"
 #undef GET_INTRINSIC_ATTRIBUTES
 
-  // Intrinsics cannot throw exceptions.
-  Attr |= Attribute::NoUnwind;
-
-  AttributeWithIndex PAWI = AttributeWithIndex::get(~0, Attr);
-  return AttrListPtr::get(&PAWI, 1);
-}
-
 Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, 
                                     unsigned numTys) {
   // There can never be multiple globals with the same name of different types,
index 86e83e591116a3b46727ac21d47ea8980d383a4e..714e73f22cd43c72f7d9abb38ad31e9f0f3d1f5f 100644 (file)
@@ -387,10 +387,14 @@ void IntrinsicEmitter::EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints,
   OS << "#endif\n\n";
 }
 
+/// EmitAttributes - This emits the Intrinsic::getAttributes method.
 void IntrinsicEmitter::
 EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
   OS << "// Add parameter attributes that are not common to all intrinsics.\n";
   OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
+  OS << "AttrListPtr Intrinsic::getAttributes(ID id) {";
+  OS << "  // No intrinsic can throw exceptions.\n";
+  OS << "  Attributes Attr = Attribute::NoUnwind;\n";
   OS << "  switch (id) {\n";
   OS << "  default: break;\n";
   for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
@@ -415,6 +419,9 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
   OS << "    Attr |= Attribute::ReadOnly; // These do not write memory.\n";
   OS << "    break;\n";
   OS << "  }\n";
+  OS << "  AttributeWithIndex PAWI = AttributeWithIndex::get(~0, Attr);\n";
+  OS << "  return AttrListPtr::get(&PAWI, 1);\n";
+  OS << "}\n";
   OS << "#endif\n\n";
 }