]> granicus.if.org Git - llvm/commitdiff
[Bitcode] Move Bitstream to a separate library
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Wed, 3 Jul 2019 22:40:07 +0000 (22:40 +0000)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Wed, 3 Jul 2019 22:40:07 +0000 (22:40 +0000)
This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/.

This is needed to avoid a circular dependency when using the bitstream
code for parsing optimization remarks.

Since Bitcode uses Core for the IR part:

libLLVMRemarks -> Bitcode -> Core

and Core uses libLLVMRemarks to generate remarks (see
IR/RemarkStreamer.cpp):

Core -> libLLVMRemarks

we need to separate the Bitstream and Bitcode part.

For clang-doc, it seems that it doesn't need the whole bitcode layer, so
I updated the CMake to only use the bitstream part.

Differential Revision: https://reviews.llvm.org/D63899

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

27 files changed:
include/llvm/Bitcode/BitcodeReader.h
include/llvm/Bitcode/LLVMBitCodes.h
include/llvm/Bitstream/BitCodes.h [moved from include/llvm/Bitcode/BitCodes.h with 96% similarity]
include/llvm/Bitstream/BitstreamReader.h [moved from include/llvm/Bitcode/BitstreamReader.h with 99% similarity]
include/llvm/Bitstream/BitstreamWriter.h [moved from include/llvm/Bitcode/BitstreamWriter.h with 99% similarity]
include/llvm/Support/JSON.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Reader/CMakeLists.txt
lib/Bitcode/Reader/LLVMBuild.txt
lib/Bitcode/Reader/MetadataLoader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Bitstream/CMakeLists.txt [new file with mode: 0644]
lib/Bitstream/LLVMBuild.txt [new file with mode: 0644]
lib/Bitstream/Reader/BitstreamReader.cpp [moved from lib/Bitcode/Reader/BitstreamReader.cpp with 99% similarity]
lib/Bitstream/Reader/CMakeLists.txt [new file with mode: 0644]
lib/Bitstream/Reader/LLVMBuild.txt [new file with mode: 0644]
lib/CMakeLists.txt
lib/LLVMBuild.txt
tools/llvm-bcanalyzer/CMakeLists.txt
tools/llvm-bcanalyzer/LLVMBuild.txt
tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
unittests/Bitcode/CMakeLists.txt
unittests/Bitstream/BitstreamReaderTest.cpp [moved from unittests/Bitcode/BitstreamReaderTest.cpp with 98% similarity]
unittests/Bitstream/BitstreamWriterTest.cpp [moved from unittests/Bitcode/BitstreamWriterTest.cpp with 97% similarity]
unittests/Bitstream/CMakeLists.txt [new file with mode: 0644]
unittests/CMakeLists.txt
utils/GenLibDeps.pl

index 3e8e7edf79ce064a8bfbd1d8e47d4b1e14cd1f01..ba61da733bea98517241e8bfdf562d954621329e 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
index 3a0e1cc2b2c60a9df6db4f0e784eed680a3b1edb..5f3f7b1bd37e0969f9b5449a647db537bbc3af8e 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef LLVM_BITCODE_LLVMBITCODES_H
 #define LLVM_BITCODE_LLVMBITCODES_H
 
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
 
 namespace llvm {
 namespace bitc {
similarity index 96%
rename from include/llvm/Bitcode/BitCodes.h
rename to include/llvm/Bitstream/BitCodes.h
index a0d8dfd68bf7177554b19b717d2feb0d26fe5d02..60de9622947ab815f4a07eee765b99aad107fe00 100644 (file)
@@ -1,4 +1,4 @@
-//===- BitCodes.h - Enum values for the bitcode format ----------*- C++ -*-===//
+//===- BitCodes.h - Enum values for the bitstream format --------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This header Bitcode enum values.
+// This header defines bitstream enum values.
 //
 // The enum values defined in this file should be considered permanent.  If
 // new features are added, they should have values added at the end of the
@@ -14,8 +14,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_BITCODE_BITCODES_H
-#define LLVM_BITCODE_BITCODES_H
+#ifndef LLVM_BITSTREAM_BITCODES_H
+#define LLVM_BITSTREAM_BITCODES_H
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/DataTypes.h"
@@ -23,7 +23,7 @@
 #include <cassert>
 
 namespace llvm {
-/// Offsets of the 32-bit fields of bitcode wrapper header.
+/// Offsets of the 32-bit fields of bitstream wrapper header.
 static const unsigned BWH_MagicField = 0 * 4;
 static const unsigned BWH_VersionField = 1 * 4;
 static const unsigned BWH_OffsetField = 2 * 4;
similarity index 99%
rename from include/llvm/Bitcode/BitstreamReader.h
rename to include/llvm/Bitstream/BitstreamReader.h
index c8ed77fded83cec0052c1f2c555fa268d66790cc..ccb4a492b9d56b330cb1a7d3f90ed99e2c832d88 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_BITCODE_BITSTREAMREADER_H
-#define LLVM_BITCODE_BITSTREAMREADER_H
+#ifndef LLVM_BITSTREAM_BITSTREAMREADER_H
+#define LLVM_BITSTREAM_BITSTREAMREADER_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
@@ -550,4 +550,4 @@ public:
 
 } // end llvm namespace
 
-#endif // LLVM_BITCODE_BITSTREAMREADER_H
+#endif // LLVM_BITSTREAM_BITSTREAMREADER_H
similarity index 99%
rename from include/llvm/Bitcode/BitstreamWriter.h
rename to include/llvm/Bitstream/BitstreamWriter.h
index cd5b614d105390b4aa0cd1ae5a00e85cb87a027d..c0ead19dc71db65c08e83fc861b7d2dc10c8b88b 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_BITCODE_BITSTREAMWRITER_H
-#define LLVM_BITCODE_BITSTREAMWRITER_H
+#ifndef LLVM_BITSTREAM_BITSTREAMWRITER_H
+#define LLVM_BITSTREAM_BITSTREAMWRITER_H
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
 #include "llvm/Support/Endian.h"
 #include <vector>
 
index fb6a6d4e19a77e28746b0836a92afae3b5f28386..0ca41097dddd92945de77d446c18b58007a3dc24 100644 (file)
@@ -39,7 +39,7 @@
 ///
 /// - LLVM bitstream is a space- and CPU- efficient binary format. Typically it
 ///   encodes LLVM IR ("bitcode"), but it can be a container for other data.
-///   Low-level reader/writer libraries are in Bitcode/Bitstream*.h
+///   Low-level reader/writer libraries are in Bitstream/Bitstream*.h
 ///
 //===---------------------------------------------------------------------===//
 
index fa4fbdcea5b7988b89875be5ca6c02b9e2418504..9e0c397d743900e2e90f8c09173fbbadf9862fcd 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Argument.h"
index c24216ffa7086445a5482d928c74e9b160c97038..c9e1c00d10e3f27a32ab1cc464f2cd5ce9492057 100644 (file)
@@ -1,7 +1,6 @@
 add_llvm_library(LLVMBitReader
   BitReader.cpp
   BitcodeReader.cpp
-  BitstreamReader.cpp
   MetadataLoader.cpp
   ValueList.cpp
 
index c43f819750c5a2b7da1541bb73156bd23163bb76..2eafab53c58b25556e4fb5006afdfda9fa9d687c 100644 (file)
@@ -18,4 +18,4 @@
 type = Library
 name = BitReader
 parent = Bitcode
-required_libraries = Core Support
+required_libraries = BitstreamReader Core Support
index 03f9c950ef01289012429d368c892209829b54ab..24620ed10d7479bed814a6de293176588a250dd5 100644 (file)
@@ -22,7 +22,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Bitcode/BitcodeReader.h"
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/IR/Argument.h"
 #include "llvm/IR/Attributes.h"
index e8d9fb8f62e380b2db43ac6ca23abe4c3bfc6160..90de4688c8ca88f0dbde5457396bfbb1669f25da 100644 (file)
@@ -24,8 +24,8 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/Bitcode/BitCodes.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitCodes.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Attributes.h"
diff --git a/lib/Bitstream/CMakeLists.txt b/lib/Bitstream/CMakeLists.txt
new file mode 100644 (file)
index 0000000..49def15
--- /dev/null
@@ -0,0 +1,2 @@
+add_subdirectory(Reader)
+# The writer is header-only.
diff --git a/lib/Bitstream/LLVMBuild.txt b/lib/Bitstream/LLVMBuild.txt
new file mode 100644 (file)
index 0000000..1dfb6d2
--- /dev/null
@@ -0,0 +1,23 @@
+;===- ./lib/Bitstream/LLVMBuild.txt ----------------------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[common]
+subdirectories = Reader
+
+[component_0]
+type = Group
+name = Bitstream
+parent = Libraries
similarity index 99%
rename from lib/Bitcode/Reader/BitstreamReader.cpp
rename to lib/Bitstream/Reader/BitstreamReader.cpp
index 2f29ce29db0121a3f4cd67b3de647f7d583b85fc..a4a97ced545791c3a01973a534aaf0b536d2f80a 100644 (file)
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/ADT/StringRef.h"
 #include <cassert>
 #include <string>
diff --git a/lib/Bitstream/Reader/CMakeLists.txt b/lib/Bitstream/Reader/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f91e450
--- /dev/null
@@ -0,0 +1,7 @@
+add_llvm_library(LLVMBitstreamReader
+  BitstreamReader.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Bitcode
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Bitstream
+  )
diff --git a/lib/Bitstream/Reader/LLVMBuild.txt b/lib/Bitstream/Reader/LLVMBuild.txt
new file mode 100644 (file)
index 0000000..8ef4276
--- /dev/null
@@ -0,0 +1,21 @@
+;===- ./lib/Bitstream/Reader/LLVMBuild.txt ---------------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = BitstreamReader
+parent = Bitstream
+required_libraries = Support
index c458927e3cd0b63c2f468bf77b3674209957b36d..17313df0ecf6d545bb341d8688f36f6e2602459a 100644 (file)
@@ -7,6 +7,7 @@ add_subdirectory(IRReader)
 add_subdirectory(CodeGen)
 add_subdirectory(BinaryFormat)
 add_subdirectory(Bitcode)
+add_subdirectory(Bitstream)
 add_subdirectory(Transforms)
 add_subdirectory(Linker)
 add_subdirectory(Analysis)
index 3b5e71d6ef1de11127a8a693fef49cbbd5c03ff5..4c039176267c331d5e77939dccc456d71230f61d 100644 (file)
@@ -19,6 +19,7 @@ subdirectories =
  Analysis
  AsmParser
  Bitcode
+ Bitstream
  CodeGen
  DebugInfo
  Demangle
index 15d51ee7a9d75d6bba97d625a953703b9f6d448c..0d541e1fde3c561e3ba86b535a24751405de2540 100644 (file)
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   BitReader
+  BitstreamReader
   Support
   )
 
index 281d60246e9d23b5cafceb045f1ac09ba709b741..c3b69110747eacb40c99bc79477db0300f2768d6 100644 (file)
@@ -18,4 +18,4 @@
 type = Tool
 name = llvm-bcanalyzer
 parent = Tools
-required_libraries = BitReader
+required_libraries = BitReader BitstreamReader Support
index 29f6778d331db437d83b0e15adf0d7ef847502cd..774432a5921e1a375cefb7afd4940996f38ec4a2 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitcodeReader.h"
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Format.h"
index 4d06f8008d389eb56ea8e6bd710e4c9fb5bf64c4..7e9d1bc43fefe6e75c34c0124d412e81e457672b 100644 (file)
@@ -8,6 +8,4 @@ set(LLVM_LINK_COMPONENTS
 
 add_llvm_unittest(BitcodeTests
   BitReaderTest.cpp
-  BitstreamReaderTest.cpp
-  BitstreamWriterTest.cpp
   )
similarity index 98%
rename from unittests/Bitcode/BitstreamReaderTest.cpp
rename to unittests/Bitstream/BitstreamReaderTest.cpp
index 89657d9e992510513fda807ff0477a0dc8142a62..f58af220f2d131f13299eb38e9990466c6962d3e 100644 (file)
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
similarity index 97%
rename from unittests/Bitcode/BitstreamWriterTest.cpp
rename to unittests/Bitstream/BitstreamWriterTest.cpp
index ef4696c8c173398cd786f67a65a1caa8c8d920b0..993c5aadee2d4fb0a9ac057bd19f1f4a9271463d 100644 (file)
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
diff --git a/unittests/Bitstream/CMakeLists.txt b/unittests/Bitstream/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a620034
--- /dev/null
@@ -0,0 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  BitstreamReader
+  )
+
+add_llvm_unittest(BitstreamTests
+  BitstreamReaderTest.cpp
+  BitstreamWriterTest.cpp
+  )
index 68fa8533baf0113e694466549fdbf8a8d0962205..6bb2fb8eb9239ed0e155873aebd117ce98cc8c88 100644 (file)
@@ -13,6 +13,7 @@ add_subdirectory(Analysis)
 add_subdirectory(AsmParser)
 add_subdirectory(BinaryFormat)
 add_subdirectory(Bitcode)
+add_subdirectory(Bitstream)
 add_subdirectory(CodeGen)
 add_subdirectory(DebugInfo)
 add_subdirectory(Demangle)
index 9b65e900c53e8d0b931fc8eb6c5248e6cd7ef228..42afa6a11fc00667afb6965fd26749ce3afe6dc5 100755 (executable)
@@ -96,6 +96,8 @@ if ($PEROBJ) {
     $libpath =~ s/^AsmPrinter/CodeGen\/AsmPrinter/;
     $libpath =~ s/^BitReader/Bitcode\/Reader/;
     $libpath =~ s/^BitWriter/Bitcode\/Writer/;
+    $libpath =~ s/^BitstreamReader/Bitstream\/Reader/;
+    $libpath =~ s/^BitstreamWriter/Bitstream\/Writer/;
     $libpath =~ s/^MSIL/Target\/MSIL/;
     $libpath =~ s/^Core/IR/;
     $libpath =~ s/^Instrumentation/Transforms\/Instrumentation/;
@@ -136,6 +138,8 @@ if ($PEROBJ) {
     $libpath =~ s/^AsmPrinter/CodeGen\/AsmPrinter/;
     $libpath =~ s/^BitReader/Bitcode\/Reader/;
     $libpath =~ s/^BitWriter/Bitcode\/Writer/;
+    $libpath =~ s/^BitstreamReader/Bitstream\/Reader/;
+    $libpath =~ s/^BitstreamWriter/Bitstream\/Writer/;
     $libpath =~ s/^MSIL/Target\/MSIL/;
     $libpath =~ s/^Core/VMCore/;
     $libpath =~ s/^Instrumentation/Transforms\/Instrumentation/;