]> granicus.if.org Git - llvm/commitdiff
Invert the MC -> Object dependency.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 3 Jul 2014 02:01:39 +0000 (02:01 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 3 Jul 2014 02:01:39 +0000 (02:01 +0000)
Now that we have a lib/MC/MCAnalysis, the dependency was there just because
of two helper classes. Move the two over to MC.

This will allow IRObjectFile to parse inline assembly.

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

22 files changed:
include/llvm/MC/StringTableBuilder.h [moved from include/llvm/Object/StringTableBuilder.h with 94% similarity]
include/llvm/MC/YAML.h [moved from include/llvm/Object/YAML.h with 77% similarity]
include/llvm/Object/COFFYAML.h
include/llvm/Object/ELFYAML.h
lib/MC/CMakeLists.txt
lib/MC/ELFObjectWriter.cpp
lib/MC/LLVMBuild.txt
lib/MC/MCAnalysis/MCModuleYAML.cpp
lib/MC/StringTableBuilder.cpp [moved from lib/Object/StringTableBuilder.cpp with 96% similarity]
lib/MC/YAML.cpp [moved from lib/Object/YAML.cpp with 78% similarity]
lib/Object/CMakeLists.txt
lib/Object/LLVMBuild.txt
tools/obj2yaml/coff2yaml.cpp
tools/obj2yaml/elf2yaml.cpp
tools/yaml2obj/yaml2elf.cpp
unittests/CMakeLists.txt
unittests/MC/CMakeLists.txt
unittests/MC/StringTableBuilderTest.cpp [moved from unittests/Object/StringTableBuilderTest.cpp with 95% similarity]
unittests/MC/YAMLTest.cpp [moved from unittests/Object/YAMLTest.cpp with 93% similarity]
unittests/Makefile
unittests/Object/CMakeLists.txt [deleted file]
unittests/Object/Makefile [deleted file]

similarity index 94%
rename from include/llvm/Object/StringTableBuilder.h
rename to include/llvm/MC/StringTableBuilder.h
index c61e216bdf9bd074599d12a1f1b4f2c904ac9baf..065e9e06e2c91eb85067a11de08f885a45d6ff10 100644 (file)
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_OBJECT_STRINGTABLE_BUILDER_H
-#define LLVM_OBJECT_STRINGTABLE_BUILDER_H
+#ifndef LLVM_MC_STRINGTABLE_BUILDER_H
+#define LLVM_MC_STRINGTABLE_BUILDER_H
 
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
similarity index 77%
rename from include/llvm/Object/YAML.h
rename to include/llvm/MC/YAML.h
index 1792e8b62677331e64838990096c8e6593306502..383cdc6785fabbc3e1d578a34d3d9b9bebbcf03b 100644 (file)
@@ -1,26 +1,10 @@
-//===- YAML.h - YAMLIO utilities for object files ---------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file declares utility classes for handling the YAML representation of
-// object files.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_OBJECT_YAML_H
-#define LLVM_OBJECT_YAML_H
+#ifndef LLVM_MC_YAML_H
+#define LLVM_MC_YAML_H
 
 #include "llvm/Support/YAMLTraits.h"
 
 namespace llvm {
-namespace object {
 namespace yaml {
-
 /// \brief Specialized YAMLIO scalar type for representing a binary blob.
 ///
 /// A typical use case would be to represent the content of a section in a
@@ -100,18 +84,11 @@ inline bool operator==(const BinaryRef &LHS, const BinaryRef &RHS) {
   return LHS.DataIsHexString == RHS.DataIsHexString && LHS.Data == RHS.Data;
 }
 
-}
-}
-
-namespace yaml {
-template <> struct ScalarTraits<object::yaml::BinaryRef> {
-  static void output(const object::yaml::BinaryRef &, void *,
-                     llvm::raw_ostream &);
-  static StringRef input(StringRef, void *, object::yaml::BinaryRef &);
+template <> struct ScalarTraits<BinaryRef> {
+  static void output(const BinaryRef &, void *, llvm::raw_ostream &);
+  static StringRef input(StringRef, void *, BinaryRef &);
   static bool mustQuote(StringRef S) { return needsQuotes(S); }
 };
 }
-
 }
-
 #endif
index 3f48e07f575a33231e2b5fa77af4f406a42b6a5d..4aba08f75ddc90e14591e3d4f9b0100f84104299 100644 (file)
@@ -15,7 +15,7 @@
 #define LLVM_OBJECT_COFFYAML_H
 
 #include "llvm/ADT/Optional.h"
-#include "llvm/Object/YAML.h"
+#include "llvm/MC/YAML.h"
 #include "llvm/Support/COFF.h"
 
 namespace llvm {
@@ -49,7 +49,7 @@ namespace COFFYAML {
   struct Section {
     COFF::section Header;
     unsigned Alignment;
-    object::yaml::BinaryRef SectionData;
+    yaml::BinaryRef SectionData;
     std::vector<Relocation> Relocations;
     StringRef Name;
     Section();
index 42eeb0ef752c5ddeff206c05c23f527efebb5c1a..fc8cc95816553b223d80adcfec1c92c9131ed7a7 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef LLVM_OBJECT_ELFYAML_H
 #define LLVM_OBJECT_ELFYAML_H
 
-#include "llvm/Object/YAML.h"
+#include "llvm/MC/YAML.h"
 #include "llvm/Support/ELF.h"
 
 namespace llvm {
@@ -83,7 +83,7 @@ struct Section {
   virtual ~Section();
 };
 struct RawContentSection : Section {
-  object::yaml::BinaryRef Content;
+  yaml::BinaryRef Content;
   llvm::yaml::Hex64 Size;
   RawContentSection() : Section(SectionKind::RawContent) {}
   static bool classof(const Section *S) {
index f62894cab39cdfb82fd39e4dd16b248e835cd356..330519ece009a3f54963da86dc688fb8956751a4 100644 (file)
@@ -43,9 +43,11 @@ add_llvm_library(LLVMMC
   MCValue.cpp
   MCWin64EH.cpp
   MachObjectWriter.cpp
+  StringTableBuilder.cpp
   SubtargetFeature.cpp
   WinCOFFObjectWriter.cpp
   WinCOFFStreamer.cpp
+  YAML.cpp
   )
 
 add_subdirectory(MCAnalysis)
index 87f6ec0f3d13f1d98e75eb5b6e71244b9ca8dad0..ead05351458c7ce25fd11fbb63f5f945adc93496 100644 (file)
@@ -28,7 +28,7 @@
 #include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCValue.h"
-#include "llvm/Object/StringTableBuilder.h"
+#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Endian.h"
index da9995d6c579b6b6edd4751e8312a895e2c5f43f..3fcb50b97c6d399e05f09cd5a889c88505c71e3a 100644 (file)
@@ -22,4 +22,4 @@ subdirectories = MCAnalysis MCDisassembler MCParser
 type = Library
 name = MC
 parent = Libraries
-required_libraries = Object Support
+required_libraries = Support
index c51c62e928d6798324cf22b2c7908405eb687408..876b06de9c90691e864ca662122ec8ec414f6869 100644 (file)
@@ -17,7 +17,7 @@
 #include "llvm/MC/MCAnalysis/MCFunction.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
-#include "llvm/Object/YAML.h"
+#include "llvm/MC/YAML.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/MathExtras.h"
@@ -102,7 +102,7 @@ struct Atom {
   uint64_t Size;
 
   std::vector<Inst> Insts;
-  object::yaml::BinaryRef Data;
+  yaml::BinaryRef Data;
 };
 
 struct BasicBlock {
similarity index 96%
rename from lib/Object/StringTableBuilder.cpp
rename to lib/MC/StringTableBuilder.cpp
index 9152834a296637f8d9083cfe1dd9a9f09f196249..db58ece5c86679486d2586309cb1ccb6039c7773 100644 (file)
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Object/StringTableBuilder.h"
 
 using namespace llvm;
 
similarity index 78%
rename from lib/Object/YAML.cpp
rename to lib/MC/YAML.cpp
index 61e9da30395970221b36e7fcd2cb0a5fd62c45a1..067e91a26d3779a04bc3d5d141cec48adf73cc19 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Object/YAML.h"
+#include "llvm/MC/YAML.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cctype>
 
 using namespace llvm;
-using namespace object::yaml;
 
-void yaml::ScalarTraits<object::yaml::BinaryRef>::output(
-    const object::yaml::BinaryRef &Val, void *, llvm::raw_ostream &Out) {
+void yaml::ScalarTraits<yaml::BinaryRef>::output(
+    const yaml::BinaryRef &Val, void *, llvm::raw_ostream &Out) {
   Val.writeAsHex(Out);
 }
 
-StringRef yaml::ScalarTraits<object::yaml::BinaryRef>::input(
-    StringRef Scalar, void *, object::yaml::BinaryRef &Val) {
+StringRef yaml::ScalarTraits<yaml::BinaryRef>::input(StringRef Scalar, void *,
+                                                     yaml::BinaryRef &Val) {
   if (Scalar.size() % 2 != 0)
     return "BinaryRef hex string must contain an even number of nybbles.";
   // TODO: Can we improve YAMLIO to permit a more accurate diagnostic here?
@@ -34,11 +33,11 @@ StringRef yaml::ScalarTraits<object::yaml::BinaryRef>::input(
   for (unsigned I = 0, N = Scalar.size(); I != N; ++I)
     if (!isxdigit(Scalar[I]))
       return "BinaryRef hex string must contain only hex digits.";
-  Val = object::yaml::BinaryRef(Scalar);
+  Val = yaml::BinaryRef(Scalar);
   return StringRef();
 }
 
-void BinaryRef::writeAsBinary(raw_ostream &OS) const {
+void yaml::BinaryRef::writeAsBinary(raw_ostream &OS) const {
   if (!DataIsHexString) {
     OS.write((const char *)Data.data(), Data.size());
     return;
@@ -50,7 +49,7 @@ void BinaryRef::writeAsBinary(raw_ostream &OS) const {
   }
 }
 
-void BinaryRef::writeAsHex(raw_ostream &OS) const {
+void yaml::BinaryRef::writeAsHex(raw_ostream &OS) const {
   if (binary_size() == 0)
     return;
   if (DataIsHexString) {
index cd8c9efe7b018aad72b989ceeb72ac1289339430..00bf1e30c217019a4fa1d8c91370dc100a47e6e8 100644 (file)
@@ -12,7 +12,5 @@ add_llvm_library(LLVMObject
   MachOUniversal.cpp
   Object.cpp
   ObjectFile.cpp
-  StringTableBuilder.cpp
   SymbolicFile.cpp
-  YAML.cpp
   )
index 7813832ef7ec175ab6dcb57546c11c4953d12b85..d64ac8722f550537919aab69c39650d7dffd3261 100644 (file)
@@ -19,4 +19,4 @@
 type = Library
 name = Object
 parent = Libraries
-required_libraries = BitReader Core Support
+required_libraries = BitReader Core Support MC
index 48462f69fc5da73139d5340ababf2a472a0a74c1..fed4533a982c9f58f8ec0fe7310cbc36aeb3a9a0 100644 (file)
@@ -61,7 +61,7 @@ void COFFDumper::dumpSections(unsigned NumSections) {
 
     ArrayRef<uint8_t> sectionData;
     Obj.getSectionContents(Sect, sectionData);
-    Sec.SectionData = object::yaml::BinaryRef(sectionData);
+    Sec.SectionData = yaml::BinaryRef(sectionData);
 
     std::vector<COFFYAML::Relocation> Relocations;
     for (const auto &Reloc : Section.relocations()) {
index c817e1526daeb15284b242019da8695d4bb3f79b..8b53ee770a622948c50c8c1e20e996f20ec6fad9 100644 (file)
@@ -268,7 +268,7 @@ ELFDumper<ELFT>::dumpContentSection(const Elf_Shdr *Shdr) {
   ErrorOr<ArrayRef<uint8_t>> ContentOrErr = Obj.getSectionContents(Shdr);
   if (std::error_code EC = ContentOrErr.getError())
     return EC;
-  S->Content = object::yaml::BinaryRef(ContentOrErr.get());
+  S->Content = yaml::BinaryRef(ContentOrErr.get());
   S->Size = S->Content.binary_size();
 
   return S.release();
index 467969d21d7f1cffa4a3398a11c332ea8252d245..6eeecaedcabd74400f64a56fe8167ad41ebc558b 100644 (file)
@@ -14,9 +14,9 @@
 
 #include "yaml2obj.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/ELFYAML.h"
-#include "llvm/Object/StringTableBuilder.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/YAMLTraits.h"
index bbab2a12b53407ffb60162b231d20d762bbee3a8..65930b5e4a1bff16b03d3a5a8ca6dcd3af0f9a0d 100644 (file)
@@ -21,7 +21,6 @@ add_subdirectory(IR)
 add_subdirectory(LineEditor)
 add_subdirectory(Linker)
 add_subdirectory(MC)
-add_subdirectory(Object)
 add_subdirectory(Option)
 add_subdirectory(Support)
 add_subdirectory(Transforms)
index 496056ecf59058810dbace2210b6a582dc1bbfbc..e2beab22ff997f11701d74a53aecd004eb62996e 100644 (file)
@@ -4,4 +4,6 @@ set(LLVM_LINK_COMPONENTS
 
 add_llvm_unittest(MCTests
   MCAtomTest.cpp
+  StringTableBuilderTest.cpp
+  YAMLTest.cpp
   )
similarity index 95%
rename from unittests/Object/StringTableBuilderTest.cpp
rename to unittests/MC/StringTableBuilderTest.cpp
index 130eb4a3d73d6c5f66006dbffd9fcd04ddd600e1..d30dc6222d23e333a748033c715cd58642106c9c 100644 (file)
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/MC/StringTableBuilder.h"
 #include "gtest/gtest.h"
-#include "llvm/Object/StringTableBuilder.h"
 #include <string>
 
 using namespace llvm;
similarity index 93%
rename from unittests/Object/YAMLTest.cpp
rename to unittests/MC/YAMLTest.cpp
index 1eb1113ae6b87d2a8d316cd9e80d84e49a31650a..09709ad73fc7ceb10f80aa57d7aefcdf7d1b677b 100644 (file)
@@ -7,14 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Object/YAML.h"
+#include "llvm/MC/YAML.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
 
 struct BinaryHolder {
-  object::yaml::BinaryRef Binary;
+  yaml::BinaryRef Binary;
 };
 
 namespace llvm {
index 37f654065ce92aba7f29c0e47b3caec42e0be66e..603e7d58f8c704909bbf0c81513db1e496d20e4e 100644 (file)
@@ -10,7 +10,7 @@
 LEVEL = ..
 
 PARALLEL_DIRS = ADT Analysis Bitcode CodeGen DebugInfo ExecutionEngine IR \
-               LineEditor Linker MC Object Option Support Transforms
+               LineEditor Linker MC Option Support Transforms
 
 include $(LEVEL)/Makefile.config
 include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/unittests/Object/CMakeLists.txt b/unittests/Object/CMakeLists.txt
deleted file mode 100644 (file)
index 580a894..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-set(LLVM_LINK_COMPONENTS
-  Object
-  Support
-  )
-
-add_llvm_unittest(ObjectTests
-  StringTableBuilderTest.cpp
-  YAMLTest.cpp
-  )
diff --git a/unittests/Object/Makefile b/unittests/Object/Makefile
deleted file mode 100644 (file)
index 9062149..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- unittests/Object/Makefile ---------------------------*- Makefile -*-===##
-#
-#                     The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-TESTNAME = Object
-LINK_COMPONENTS := object
-
-include $(LEVEL)/Makefile.config
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest