From: Chris Lattner Date: Tue, 17 Aug 2004 03:08:28 +0000 (+0000) Subject: Do not #include files into the llvm namespace X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2c38413b3f5420f45f2f8220b21862246d446dd0;p=oota-llvm.git Do not #include files into the llvm namespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15849 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index 7b3a5046c3c..64debe27f80 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -27,6 +27,7 @@ static bool isIdentChar(char C) { void AsmWriterEmitter::run(std::ostream &O) { EmitSourceFileHeader("Assembly Writer Source Fragment", O); + O << "namespace llvm {\n\n"; CodeGenTarget Target; @@ -103,5 +104,5 @@ void AsmWriterEmitter::run(std::ostream &O) { O << " }\n" " return true;\n" "}\n"; - EmitSourceFileTail(O); + O << "} // End llvm namespace \n"; } diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 689465cbf80..906f4d6c724 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -24,6 +24,7 @@ void CodeEmitterGen::run(std::ostream &o) { std::vector Insts = Records.getAllDerivedDefinitions("Instruction"); EmitSourceFileHeader("Machine Code Emitter", o); + o << "namespace llvm {\n\n"; std::string Namespace = Insts[0]->getValueAsString("Namespace") + "::"; // Emit function declaration @@ -225,5 +226,5 @@ void CodeEmitterGen::run(std::ostream &o) { << " return Value;\n" << "}\n"; - EmitSourceFileTail(o); + o << "} // End llvm namespace \n"; } diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 3470b2d01b7..0596f439cf5 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -20,6 +20,7 @@ using namespace llvm; // runEnums - Print out enum values for all of the instructions. void InstrInfoEmitter::runEnums(std::ostream &OS) { EmitSourceFileHeader("Target Instruction Enum Values", OS); + OS << "namespace llvm {\n\n"; CodeGenTarget Target; @@ -45,7 +46,7 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) { OS << " };\n"; if (!Namespace.empty()) OS << "}\n"; - EmitSourceFileTail(OS); + OS << "} // End llvm namespace \n"; } void InstrInfoEmitter::printDefList(ListInit *LI, const std::string &Name, @@ -63,6 +64,8 @@ void InstrInfoEmitter::printDefList(ListInit *LI, const std::string &Name, // run - Emit the main instruction description records for the target... void InstrInfoEmitter::run(std::ostream &OS) { EmitSourceFileHeader("Target Instruction Descriptors", OS); + OS << "namespace llvm {\n\n"; + CodeGenTarget Target; const std::string &TargetName = Target.getName(); Record *InstrInfo = Target.getInstructionSet(); @@ -92,7 +95,7 @@ void InstrInfoEmitter::run(std::ostream &OS) { if (II->second.TheDef != PHI) emitRecord(II->second, ++i, InstrInfo, OS); OS << "};\n"; - EmitSourceFileTail(OS); + OS << "} // End llvm namespace \n"; } void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num, diff --git a/utils/TableGen/InstrSelectorEmitter.cpp b/utils/TableGen/InstrSelectorEmitter.cpp index 5fb83c87555..f6ca2a22e46 100644 --- a/utils/TableGen/InstrSelectorEmitter.cpp +++ b/utils/TableGen/InstrSelectorEmitter.cpp @@ -982,6 +982,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) { EmitSourceFileHeader("Instruction Selector for the " + Target.getName() + " target", OS); + OS << "namespace llvm {\n\n"; // Output the slot number enums... OS << "\nenum { // Slot numbers...\n" @@ -1291,6 +1292,5 @@ void InstrSelectorEmitter::run(std::ostream &OS) { << " }\n\n N->addValue(Val); // Do not ever recalculate this\n" << " return Val;\n}\n\n"; } - EmitSourceFileTail(OS); + OS << "} // End llvm namespace \n"; } - diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index b8f79c9d93a..4ed1a0fe8c5 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -29,6 +29,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) { std::string Namespace = Registers[0].TheDef->getValueAsString("Namespace"); EmitSourceFileHeader("Target Register Enum Values", OS); + OS << "namespace llvm {\n\n"; if (!Namespace.empty()) OS << "namespace " << Namespace << " {\n"; @@ -40,7 +41,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) { OS << " };\n"; if (!Namespace.empty()) OS << "}\n"; - EmitSourceFileTail(OS); + OS << "} // End llvm namespace \n"; } void RegisterInfoEmitter::runHeader(std::ostream &OS) { @@ -51,6 +52,8 @@ void RegisterInfoEmitter::runHeader(std::ostream &OS) { OS << "#include \"llvm/Target/MRegisterInfo.h\"\n\n"; + OS << "namespace llvm {\n\n"; + OS << "struct " << ClassName << " : public MRegisterInfo {\n" << " " << ClassName << "(int CallFrameSetupOpcode = -1, int CallFrameDestroyOpcode = -1);\n" @@ -67,7 +70,7 @@ void RegisterInfoEmitter::runHeader(std::ostream &OS) { OS << " extern TargetRegisterClass *" << Name << "RegisterClass;\n"; } OS << "} // end of namespace " << TargetName << "\n\n"; - EmitSourceFileTail(OS); + OS << "} // End llvm namespace \n"; } // RegisterInfoEmitter::run - Main register file description emitter. @@ -76,6 +79,8 @@ void RegisterInfoEmitter::run(std::ostream &OS) { CodeGenTarget Target; EmitSourceFileHeader("Register Information Source Fragment", OS); + OS << "namespace llvm {\n\n"; + // Start out by emitting each of the register classes... to do this, we build // a set of registers which belong to a register class, this is to ensure that // each register is only in a single register class. @@ -236,5 +241,5 @@ void RegisterInfoEmitter::run(std::ostream &OS) { for (unsigned i = 0, e = CSR.size(); i != e; ++i) OS << getQualifiedName(CSR[i]) << ", "; OS << " 0\n };\n return CalleeSaveRegs;\n}\n\n"; - EmitSourceFileTail(OS); + OS << "} // End llvm namespace \n"; } diff --git a/utils/TableGen/TableGenBackend.cpp b/utils/TableGen/TableGenBackend.cpp index b98ff0a4242..3e418f6ce67 100644 --- a/utils/TableGen/TableGenBackend.cpp +++ b/utils/TableGen/TableGenBackend.cpp @@ -21,11 +21,7 @@ void TableGenBackend::EmitSourceFileHeader(const std::string &Desc, OS << "//===- TableGen'erated file -------------------------------------*-" " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate" "d file, do not edit!\n//\n//===------------------------------------" - "----------------------------------===//\n\nnamespace llvm {\n\n"; -} - -void TableGenBackend::EmitSourceFileTail( std::ostream& OS ) const { - OS << "} // End llvm namespace \n"; + "----------------------------------===//\n\n"; } /// getQualifiedName - Return the name of the specified record, with a diff --git a/utils/TableGen/TableGenBackend.h b/utils/TableGen/TableGenBackend.h index 869d7e939d7..deeb385f692 100644 --- a/utils/TableGen/TableGenBackend.h +++ b/utils/TableGen/TableGenBackend.h @@ -36,10 +36,6 @@ public: // Useful helper routines... /// ostream. void EmitSourceFileHeader(const std::string &Desc, std::ostream &OS) const; - /// EmitSourceFileTail - Output an LLVm styelf ile tail to the specified - /// ostream. - void EmitSourceFileTail( std::ostream& OS ) const; - /// getQualifiedName - Return the name of the specified record, with a /// namespace qualifier if the record contains one. std::string getQualifiedName(Record *R) const;