Kaynağa Gözat

Refactor value store code to use separate files. (#4477)

This is in anticipation of making the integer value store be customized
heavily. I'd like to extract it from the common code when doing that, so
first disentangling them here without any intended change in
functionality or behavior to enable that.

I've tried to update `#include`s to be as minimal as I can and added a
few missing includes spotted in the process.

I've split the test for value store to include what was easy focused on
just the value store templates rather than the unified shared value
stores.

This might surface some opportunities for adding more tests, but for
this PR, just doing the minimal restructuring.
Chandler Carruth 1 yıl önce
ebeveyn
işleme
4148161e24
40 değiştirilmiş dosya ile 400 ekleme ve 299 silme
  1. 36 2
      toolchain/base/BUILD
  2. 86 0
      toolchain/base/shared_value_stores.h
  3. 60 0
      toolchain/base/shared_value_stores_test.cpp
  4. 115 0
      toolchain/base/value_ids.h
  5. 1 168
      toolchain/base/value_store.h
  6. 31 78
      toolchain/base/value_store_test.cpp
  7. 3 1
      toolchain/check/BUILD
  8. 1 1
      toolchain/check/check.h
  9. 5 5
      toolchain/check/context.h
  10. 2 2
      toolchain/check/eval.cpp
  11. 2 0
      toolchain/check/lexical_lookup.h
  12. 1 1
      toolchain/driver/BUILD
  13. 1 1
      toolchain/driver/format_subcommand.cpp
  14. 1 1
      toolchain/language_server/BUILD
  15. 1 1
      toolchain/language_server/server.cpp
  16. 6 6
      toolchain/lex/BUILD
  17. 1 1
      toolchain/lex/lex.cpp
  18. 1 1
      toolchain/lex/lex.h
  19. 1 1
      toolchain/lex/tokenized_buffer.cpp
  20. 1 1
      toolchain/lex/tokenized_buffer.h
  21. 1 1
      toolchain/lex/tokenized_buffer_benchmark.cpp
  22. 1 1
      toolchain/lex/tokenized_buffer_fuzzer.cpp
  23. 1 1
      toolchain/lex/tokenized_buffer_test.cpp
  24. 1 1
      toolchain/lex/tokenized_buffer_test_helpers.h
  25. 4 3
      toolchain/parse/BUILD
  26. 1 1
      toolchain/parse/handle_import_and_package.cpp
  27. 1 1
      toolchain/parse/parse_fuzzer.cpp
  28. 1 0
      toolchain/parse/tree.h
  29. 1 1
      toolchain/parse/tree_test.cpp
  30. 7 3
      toolchain/sem_ir/BUILD
  31. 1 1
      toolchain/sem_ir/file.cpp
  32. 15 10
      toolchain/sem_ir/file.h
  33. 1 1
      toolchain/sem_ir/formatter.cpp
  34. 1 0
      toolchain/sem_ir/generic.h
  35. 1 1
      toolchain/sem_ir/ids.h
  36. 1 0
      toolchain/sem_ir/impl.h
  37. 1 0
      toolchain/sem_ir/inst.h
  38. 1 1
      toolchain/sem_ir/inst_namer.cpp
  39. 2 0
      toolchain/sem_ir/name.h
  40. 1 1
      toolchain/sem_ir/type.h

+ 36 - 2
toolchain/base/BUILD

@@ -42,15 +42,24 @@ cc_library(
     ],
 )
 
+cc_library(
+    name = "value_ids",
+    hdrs = ["value_ids.h"],
+    deps = [
+        ":index_base",
+        "//common:ostream",
+        "@llvm-project//llvm:Support",
+    ],
+)
+
 cc_library(
     name = "value_store",
     hdrs = ["value_store.h"],
     deps = [
-        ":index_base",
         ":mem_usage",
         ":yaml",
         "//common:check",
-        "//common:hashing",
+        "//common:hashtable_key_context",
         "//common:ostream",
         "//common:set",
         "@llvm-project//llvm:Support",
@@ -62,6 +71,7 @@ cc_test(
     size = "small",
     srcs = ["value_store_test.cpp"],
     deps = [
+        ":value_ids",
         ":value_store",
         "//testing/base:gtest_main",
         "//testing/base:test_raw_ostream",
@@ -70,6 +80,30 @@ cc_test(
     ],
 )
 
+cc_library(
+    name = "shared_value_stores",
+    hdrs = ["shared_value_stores.h"],
+    deps = [
+        ":mem_usage",
+        ":value_ids",
+        ":value_store",
+        ":yaml",
+    ],
+)
+
+cc_test(
+    name = "shared_value_stores_test",
+    size = "small",
+    srcs = ["shared_value_stores_test.cpp"],
+    deps = [
+        ":shared_value_stores",
+        "//testing/base:gtest_main",
+        "//testing/base:test_raw_ostream",
+        "//toolchain/testing:yaml_test_helpers",
+        "@googletest//:gtest",
+    ],
+)
+
 cc_library(
     name = "yaml",
     hdrs = ["yaml.h"],

+ 86 - 0
toolchain/base/shared_value_stores.h

@@ -0,0 +1,86 @@
+// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#ifndef CARBON_TOOLCHAIN_BASE_SHARED_VALUE_STORES_H_
+#define CARBON_TOOLCHAIN_BASE_SHARED_VALUE_STORES_H_
+
+#include "toolchain/base/mem_usage.h"
+#include "toolchain/base/value_ids.h"
+#include "toolchain/base/value_store.h"
+#include "toolchain/base/yaml.h"
+
+namespace Carbon {
+
+// Stores that will be used across compiler phases for a given compilation unit.
+// This is provided mainly so that they don't need to be passed separately.
+class SharedValueStores : public Yaml::Printable<SharedValueStores> {
+ public:
+  // Provide types that can be used by APIs to forward access to these stores.
+  using IntStore = CanonicalValueStore<IntId>;
+  using RealStore = ValueStore<RealId>;
+  using FloatStore = CanonicalValueStore<FloatId>;
+  using IdentifierStore = CanonicalValueStore<IdentifierId>;
+  using StringLiteralStore = CanonicalValueStore<StringLiteralValueId>;
+
+  explicit SharedValueStores() = default;
+
+  // Not copyable or movable.
+  SharedValueStores(const SharedValueStores&) = delete;
+  auto operator=(const SharedValueStores&) -> SharedValueStores& = delete;
+
+  auto identifiers() -> IdentifierStore& { return identifiers_; }
+  auto identifiers() const -> const IdentifierStore& { return identifiers_; }
+  auto ints() -> IntStore& { return ints_; }
+  auto ints() const -> const IntStore& { return ints_; }
+  auto reals() -> RealStore& { return reals_; }
+  auto reals() const -> const RealStore& { return reals_; }
+  auto floats() -> FloatStore& { return floats_; }
+  auto floats() const -> const FloatStore& { return floats_; }
+  auto string_literal_values() -> StringLiteralStore& {
+    return string_literals_;
+  }
+  auto string_literal_values() const -> const StringLiteralStore& {
+    return string_literals_;
+  }
+
+  auto OutputYaml(std::optional<llvm::StringRef> filename = std::nullopt) const
+      -> Yaml::OutputMapping {
+    return Yaml::OutputMapping([&, filename](Yaml::OutputMapping::Map map) {
+      if (filename) {
+        map.Add("filename", *filename);
+      }
+      map.Add("shared_values",
+              Yaml::OutputMapping([&](Yaml::OutputMapping::Map map) {
+                map.Add("ints", ints_.OutputYaml());
+                map.Add("reals", reals_.OutputYaml());
+                map.Add("identifiers", identifiers_.OutputYaml());
+                map.Add("strings", string_literals_.OutputYaml());
+              }));
+    });
+  }
+
+  // Collects memory usage for the various shared stores.
+  auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const
+      -> void {
+    mem_usage.Collect(MemUsage::ConcatLabel(label, "ints_"), ints_);
+    mem_usage.Collect(MemUsage::ConcatLabel(label, "reals_"), reals_);
+    mem_usage.Collect(MemUsage::ConcatLabel(label, "floats_"), floats_);
+    mem_usage.Collect(MemUsage::ConcatLabel(label, "identifiers_"),
+                      identifiers_);
+    mem_usage.Collect(MemUsage::ConcatLabel(label, "string_literals_"),
+                      string_literals_);
+  }
+
+ private:
+  IntStore ints_;
+  RealStore reals_;
+  FloatStore floats_;
+
+  IdentifierStore identifiers_;
+  StringLiteralStore string_literals_;
+};
+
+}  // namespace Carbon
+
+#endif  // CARBON_TOOLCHAIN_BASE_SHARED_VALUE_STORES_H_

+ 60 - 0
toolchain/base/shared_value_stores_test.cpp

@@ -0,0 +1,60 @@
+// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#include "toolchain/base/shared_value_stores.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "testing/base/test_raw_ostream.h"
+#include "toolchain/testing/yaml_test_helpers.h"
+
+namespace Carbon::Testing {
+namespace {
+
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+
+auto MatchSharedValues(testing::Matcher<Yaml::MappingValue> ints,
+                       testing::Matcher<Yaml::MappingValue> reals,
+                       testing::Matcher<Yaml::MappingValue> identifiers,
+                       testing::Matcher<Yaml::MappingValue> strings) -> auto {
+  return Yaml::IsYaml(Yaml::Sequence(ElementsAre(Yaml::Mapping(ElementsAre(Pair(
+      "shared_values",
+      Yaml::Mapping(ElementsAre(Pair("ints", Yaml::Mapping(ints)),
+                                Pair("reals", Yaml::Mapping(reals)),
+                                Pair("identifiers", Yaml::Mapping(identifiers)),
+                                Pair("strings", Yaml::Mapping(strings))))))))));
+}
+
+TEST(SharedValueStores, PrintEmpty) {
+  SharedValueStores value_stores;
+  TestRawOstream out;
+  value_stores.Print(out);
+  EXPECT_THAT(Yaml::Value::FromText(out.TakeStr()),
+              MatchSharedValues(IsEmpty(), IsEmpty(), IsEmpty(), IsEmpty()));
+}
+
+TEST(SharedValueStores, PrintVals) {
+  SharedValueStores value_stores;
+  llvm::APInt apint(64, 8, /*isSigned=*/true);
+  value_stores.ints().Add(apint);
+  value_stores.reals().Add(
+      Real{.mantissa = apint, .exponent = apint, .is_decimal = true});
+  value_stores.identifiers().Add("a");
+  value_stores.string_literal_values().Add("foo'\"baz");
+  TestRawOstream out;
+  value_stores.Print(out);
+
+  EXPECT_THAT(Yaml::Value::FromText(out.TakeStr()),
+              MatchSharedValues(
+                  ElementsAre(Pair("int0", Yaml::Scalar("8"))),
+                  ElementsAre(Pair("real0", Yaml::Scalar("8*10^8"))),
+                  ElementsAre(Pair("identifier0", Yaml::Scalar("a"))),
+                  ElementsAre(Pair("string0", Yaml::Scalar("foo'\"baz")))));
+}
+
+}  // namespace
+}  // namespace Carbon::Testing

+ 115 - 0
toolchain/base/value_ids.h

@@ -0,0 +1,115 @@
+// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#ifndef CARBON_TOOLCHAIN_BASE_VALUE_IDS_H_
+#define CARBON_TOOLCHAIN_BASE_VALUE_IDS_H_
+
+#include "common/ostream.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/YAMLParser.h"
+#include "toolchain/base/index_base.h"
+
+namespace Carbon {
+
+// The value of a real literal token.
+//
+// This is either a dyadic fraction (mantissa * 2^exponent) or a decadic
+// fraction (mantissa * 10^exponent).
+//
+// These values are not canonicalized, because we don't expect them to repeat
+// and don't use them in SemIR values.
+class Real : public Printable<Real> {
+ public:
+  auto Print(llvm::raw_ostream& output_stream) const -> void {
+    mantissa.print(output_stream, /*isSigned=*/false);
+    output_stream << "*" << (is_decimal ? "10" : "2") << "^" << exponent;
+  }
+
+  // The mantissa, represented as an unsigned integer.
+  llvm::APInt mantissa;
+
+  // The exponent, represented as a signed integer.
+  llvm::APInt exponent;
+
+  // If false, the value is mantissa * 2^exponent.
+  // If true, the value is mantissa * 10^exponent.
+  // TODO: This field increases Real from 32 bytes to 40 bytes. Consider
+  // changing how it's tracked for space savings.
+  bool is_decimal;
+};
+
+// Corresponds to an integer value represented by an APInt. This is used both
+// for integer literal tokens, which are unsigned and have an unspecified
+// bit-width, and integer values in SemIR, which have a signedness and bit-width
+// matching their type.
+struct IntId : public IdBase, public Printable<IntId> {
+  using ValueType = llvm::APInt;
+  static const IntId Invalid;
+  using IdBase::IdBase;
+  auto Print(llvm::raw_ostream& out) const -> void {
+    out << "int";
+    IdBase::Print(out);
+  }
+};
+constexpr IntId IntId::Invalid(IntId::InvalidIndex);
+
+// Corresponds to a float value represented by an APFloat. This is used for
+// floating-point values in SemIR.
+struct FloatId : public IdBase, public Printable<FloatId> {
+  using ValueType = llvm::APFloat;
+  static const FloatId Invalid;
+  using IdBase::IdBase;
+  auto Print(llvm::raw_ostream& out) const -> void {
+    out << "float";
+    IdBase::Print(out);
+  }
+};
+constexpr FloatId FloatId::Invalid(FloatId::InvalidIndex);
+
+// Corresponds to a Real value.
+struct RealId : public IdBase, public Printable<RealId> {
+  using ValueType = Real;
+  static const RealId Invalid;
+  using IdBase::IdBase;
+  auto Print(llvm::raw_ostream& out) const -> void {
+    out << "real";
+    IdBase::Print(out);
+  }
+};
+constexpr RealId RealId::Invalid(RealId::InvalidIndex);
+
+// Corresponds to StringRefs for identifiers.
+//
+// `NameId` relies on the values of this type other than `Invalid` all being
+// non-negative.
+struct IdentifierId : public IdBase, public Printable<IdentifierId> {
+  using ValueType = llvm::StringRef;
+  static const IdentifierId Invalid;
+  using IdBase::IdBase;
+  auto Print(llvm::raw_ostream& out) const -> void {
+    out << "identifier";
+    IdBase::Print(out);
+  }
+};
+constexpr IdentifierId IdentifierId::Invalid(IdentifierId::InvalidIndex);
+
+// Corresponds to StringRefs for string literals.
+struct StringLiteralValueId : public IdBase,
+                              public Printable<StringLiteralValueId> {
+  using ValueType = llvm::StringRef;
+  static const StringLiteralValueId Invalid;
+  using IdBase::IdBase;
+  auto Print(llvm::raw_ostream& out) const -> void {
+    out << "string";
+    IdBase::Print(out);
+  }
+};
+constexpr StringLiteralValueId StringLiteralValueId::Invalid(
+    StringLiteralValueId::InvalidIndex);
+
+}  // namespace Carbon
+
+#endif  // CARBON_TOOLCHAIN_BASE_VALUE_IDS_H_

+ 1 - 168
toolchain/base/value_store.h

@@ -8,116 +8,18 @@
 #include <type_traits>
 
 #include "common/check.h"
+#include "common/hashtable_key_context.h"
 #include "common/ostream.h"
 #include "common/set.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/YAMLParser.h"
-#include "toolchain/base/index_base.h"
 #include "toolchain/base/mem_usage.h"
 #include "toolchain/base/yaml.h"
 
 namespace Carbon {
 
-// The value of a real literal token.
-//
-// This is either a dyadic fraction (mantissa * 2^exponent) or a decadic
-// fraction (mantissa * 10^exponent).
-//
-// These values are not canonicalized, because we don't expect them to repeat
-// and don't use them in SemIR values.
-class Real : public Printable<Real> {
- public:
-  auto Print(llvm::raw_ostream& output_stream) const -> void {
-    mantissa.print(output_stream, /*isSigned=*/false);
-    output_stream << "*" << (is_decimal ? "10" : "2") << "^" << exponent;
-  }
-
-  // The mantissa, represented as an unsigned integer.
-  llvm::APInt mantissa;
-
-  // The exponent, represented as a signed integer.
-  llvm::APInt exponent;
-
-  // If false, the value is mantissa * 2^exponent.
-  // If true, the value is mantissa * 10^exponent.
-  // TODO: This field increases Real from 32 bytes to 40 bytes. Consider
-  // changing how it's tracked for space savings.
-  bool is_decimal;
-};
-
-// Corresponds to an integer value represented by an APInt. This is used both
-// for integer literal tokens, which are unsigned and have an unspecified
-// bit-width, and integer values in SemIR, which have a signedness and bit-width
-// matching their type.
-struct IntId : public IdBase, public Printable<IntId> {
-  using ValueType = llvm::APInt;
-  static const IntId Invalid;
-  using IdBase::IdBase;
-  auto Print(llvm::raw_ostream& out) const -> void {
-    out << "int";
-    IdBase::Print(out);
-  }
-};
-constexpr IntId IntId::Invalid(IntId::InvalidIndex);
-
-// Corresponds to a float value represented by an APFloat. This is used for
-// floating-point values in SemIR.
-struct FloatId : public IdBase, public Printable<FloatId> {
-  using ValueType = llvm::APFloat;
-  static const FloatId Invalid;
-  using IdBase::IdBase;
-  auto Print(llvm::raw_ostream& out) const -> void {
-    out << "float";
-    IdBase::Print(out);
-  }
-};
-constexpr FloatId FloatId::Invalid(FloatId::InvalidIndex);
-
-// Corresponds to a Real value.
-struct RealId : public IdBase, public Printable<RealId> {
-  using ValueType = Real;
-  static const RealId Invalid;
-  using IdBase::IdBase;
-  auto Print(llvm::raw_ostream& out) const -> void {
-    out << "real";
-    IdBase::Print(out);
-  }
-};
-constexpr RealId RealId::Invalid(RealId::InvalidIndex);
-
-// Corresponds to StringRefs for identifiers.
-//
-// `NameId` relies on the values of this type other than `Invalid` all being
-// non-negative.
-struct IdentifierId : public IdBase, public Printable<IdentifierId> {
-  using ValueType = llvm::StringRef;
-  static const IdentifierId Invalid;
-  using IdBase::IdBase;
-  auto Print(llvm::raw_ostream& out) const -> void {
-    out << "identifier";
-    IdBase::Print(out);
-  }
-};
-constexpr IdentifierId IdentifierId::Invalid(IdentifierId::InvalidIndex);
-
-// Corresponds to StringRefs for string literals.
-struct StringLiteralValueId : public IdBase,
-                              public Printable<StringLiteralValueId> {
-  using ValueType = llvm::StringRef;
-  static const StringLiteralValueId Invalid;
-  using IdBase::IdBase;
-  auto Print(llvm::raw_ostream& out) const -> void {
-    out << "string";
-    IdBase::Print(out);
-  }
-};
-constexpr StringLiteralValueId StringLiteralValueId::Invalid(
-    StringLiteralValueId::InvalidIndex);
-
 namespace Internal {
 
 // Used as a parent class for non-printable types. This is just for
@@ -297,75 +199,6 @@ auto CanonicalValueStore<IdT>::Reserve(size_t size) -> void {
   values_.Reserve(size);
 }
 
-using FloatValueStore = CanonicalValueStore<FloatId>;
-
-// Stores that will be used across compiler phases for a given compilation unit.
-// This is provided mainly so that they don't need to be passed separately.
-class SharedValueStores : public Yaml::Printable<SharedValueStores> {
- public:
-  explicit SharedValueStores() = default;
-
-  // Not copyable or movable.
-  SharedValueStores(const SharedValueStores&) = delete;
-  auto operator=(const SharedValueStores&) -> SharedValueStores& = delete;
-
-  auto identifiers() -> CanonicalValueStore<IdentifierId>& {
-    return identifiers_;
-  }
-  auto identifiers() const -> const CanonicalValueStore<IdentifierId>& {
-    return identifiers_;
-  }
-  auto ints() -> CanonicalValueStore<IntId>& { return ints_; }
-  auto ints() const -> const CanonicalValueStore<IntId>& { return ints_; }
-  auto reals() -> ValueStore<RealId>& { return reals_; }
-  auto reals() const -> const ValueStore<RealId>& { return reals_; }
-  auto floats() -> FloatValueStore& { return floats_; }
-  auto floats() const -> const FloatValueStore& { return floats_; }
-  auto string_literal_values() -> CanonicalValueStore<StringLiteralValueId>& {
-    return string_literals_;
-  }
-  auto string_literal_values() const
-      -> const CanonicalValueStore<StringLiteralValueId>& {
-    return string_literals_;
-  }
-
-  auto OutputYaml(std::optional<llvm::StringRef> filename = std::nullopt) const
-      -> Yaml::OutputMapping {
-    return Yaml::OutputMapping([&, filename](Yaml::OutputMapping::Map map) {
-      if (filename) {
-        map.Add("filename", *filename);
-      }
-      map.Add("shared_values",
-              Yaml::OutputMapping([&](Yaml::OutputMapping::Map map) {
-                map.Add("ints", ints_.OutputYaml());
-                map.Add("reals", reals_.OutputYaml());
-                map.Add("identifiers", identifiers_.OutputYaml());
-                map.Add("strings", string_literals_.OutputYaml());
-              }));
-    });
-  }
-
-  // Collects memory usage for the various shared stores.
-  auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const
-      -> void {
-    mem_usage.Collect(MemUsage::ConcatLabel(label, "ints_"), ints_);
-    mem_usage.Collect(MemUsage::ConcatLabel(label, "reals_"), reals_);
-    mem_usage.Collect(MemUsage::ConcatLabel(label, "floats_"), floats_);
-    mem_usage.Collect(MemUsage::ConcatLabel(label, "identifiers_"),
-                      identifiers_);
-    mem_usage.Collect(MemUsage::ConcatLabel(label, "string_literals_"),
-                      string_literals_);
-  }
-
- private:
-  CanonicalValueStore<IntId> ints_;
-  ValueStore<RealId> reals_;
-  FloatValueStore floats_;
-
-  CanonicalValueStore<IdentifierId> identifiers_;
-  CanonicalValueStore<StringLiteralValueId> string_literals_;
-};
-
 }  // namespace Carbon
 
 #endif  // CARBON_TOOLCHAIN_BASE_VALUE_STORE_H_

+ 31 - 78
toolchain/base/value_store_test.cpp

@@ -7,29 +7,25 @@
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
-#include "testing/base/test_raw_ostream.h"
-#include "toolchain/testing/yaml_test_helpers.h"
+#include "toolchain/base/value_ids.h"
 
 namespace Carbon::Testing {
 namespace {
 
-using ::testing::ElementsAre;
 using ::testing::Eq;
-using ::testing::IsEmpty;
 using ::testing::Not;
-using ::testing::Pair;
 
 TEST(ValueStore, Int) {
-  SharedValueStores value_stores;
-  IntId id1 = value_stores.ints().Add(llvm::APInt(64, 1));
-  IntId id2 = value_stores.ints().Add(llvm::APInt(64, 2));
+  CanonicalValueStore<IntId> ints;
+  IntId id1 = ints.Add(llvm::APInt(64, 1));
+  IntId id2 = ints.Add(llvm::APInt(64, 2));
 
   ASSERT_TRUE(id1.is_valid());
   ASSERT_TRUE(id2.is_valid());
   EXPECT_THAT(id1, Not(Eq(id2)));
 
-  EXPECT_THAT(value_stores.ints().Get(id1), Eq(1));
-  EXPECT_THAT(value_stores.ints().Get(id2), Eq(2));
+  EXPECT_THAT(ints.Get(id1), Eq(1));
+  EXPECT_THAT(ints.Get(id2), Eq(2));
 }
 
 TEST(ValueStore, Real) {
@@ -40,20 +36,20 @@ TEST(ValueStore, Real) {
              .exponent = llvm::APInt(64, 22),
              .is_decimal = false};
 
-  SharedValueStores value_stores;
-  RealId id1 = value_stores.reals().Add(real1);
-  RealId id2 = value_stores.reals().Add(real2);
+  ValueStore<RealId> reals;
+  RealId id1 = reals.Add(real1);
+  RealId id2 = reals.Add(real2);
 
   ASSERT_TRUE(id1.is_valid());
   ASSERT_TRUE(id2.is_valid());
   EXPECT_THAT(id1, Not(Eq(id2)));
 
-  const auto& real1_copy = value_stores.reals().Get(id1);
+  const auto& real1_copy = reals.Get(id1);
   EXPECT_THAT(real1.mantissa, Eq(real1_copy.mantissa));
   EXPECT_THAT(real1.exponent, Eq(real1_copy.exponent));
   EXPECT_THAT(real1.is_decimal, Eq(real1_copy.is_decimal));
 
-  const auto& real2_copy = value_stores.reals().Get(id2);
+  const auto& real2_copy = reals.Get(id2);
   EXPECT_THAT(real2.mantissa, Eq(real2_copy.mantissa));
   EXPECT_THAT(real2.exponent, Eq(real2_copy.exponent));
   EXPECT_THAT(real2.is_decimal, Eq(real2_copy.is_decimal));
@@ -63,100 +59,57 @@ TEST(ValueStore, Float) {
   llvm::APFloat float1(1.0);
   llvm::APFloat float2(2.0);
 
-  SharedValueStores value_stores;
-  FloatId id1 = value_stores.floats().Add(float1);
-  FloatId id2 = value_stores.floats().Add(float2);
+  CanonicalValueStore<FloatId> floats;
+  FloatId id1 = floats.Add(float1);
+  FloatId id2 = floats.Add(float2);
 
   ASSERT_TRUE(id1.is_valid());
   ASSERT_TRUE(id2.is_valid());
   EXPECT_THAT(id1, Not(Eq(id2)));
 
-  EXPECT_THAT(value_stores.floats().Get(id1).compare(float1),
-              Eq(llvm::APFloatBase::cmpEqual));
-  EXPECT_THAT(value_stores.floats().Get(id2).compare(float2),
-              Eq(llvm::APFloatBase::cmpEqual));
+  EXPECT_THAT(floats.Get(id1).compare(float1), Eq(llvm::APFloatBase::cmpEqual));
+  EXPECT_THAT(floats.Get(id2).compare(float2), Eq(llvm::APFloatBase::cmpEqual));
 }
 
 TEST(ValueStore, Identifiers) {
   std::string a = "a";
   std::string b = "b";
-  SharedValueStores value_stores;
+  CanonicalValueStore<IdentifierId> identifiers;
 
   // Make sure reserve works, we use it with identifiers.
-  value_stores.identifiers().Reserve(100);
+  identifiers.Reserve(100);
 
-  auto a_id = value_stores.identifiers().Add(a);
-  auto b_id = value_stores.identifiers().Add(b);
+  auto a_id = identifiers.Add(a);
+  auto b_id = identifiers.Add(b);
 
   ASSERT_TRUE(a_id.is_valid());
   ASSERT_TRUE(b_id.is_valid());
   EXPECT_THAT(a_id, Not(Eq(b_id)));
 
-  EXPECT_THAT(value_stores.identifiers().Get(a_id), Eq(a));
-  EXPECT_THAT(value_stores.identifiers().Get(b_id), Eq(b));
+  EXPECT_THAT(identifiers.Get(a_id), Eq(a));
+  EXPECT_THAT(identifiers.Get(b_id), Eq(b));
 
-  EXPECT_THAT(value_stores.identifiers().Lookup(a), Eq(a_id));
-  EXPECT_THAT(value_stores.identifiers().Lookup("c"),
-              Eq(IdentifierId::Invalid));
+  EXPECT_THAT(identifiers.Lookup(a), Eq(a_id));
+  EXPECT_THAT(identifiers.Lookup("c"), Eq(IdentifierId::Invalid));
 }
 
 TEST(ValueStore, StringLiterals) {
   std::string a = "a";
   std::string b = "b";
-  SharedValueStores value_stores;
+  CanonicalValueStore<StringLiteralValueId> string_literals;
 
-  auto a_id = value_stores.string_literal_values().Add(a);
-  auto b_id = value_stores.string_literal_values().Add(b);
+  auto a_id = string_literals.Add(a);
+  auto b_id = string_literals.Add(b);
 
   ASSERT_TRUE(a_id.is_valid());
   ASSERT_TRUE(b_id.is_valid());
   EXPECT_THAT(a_id, Not(Eq(b_id)));
 
-  EXPECT_THAT(value_stores.string_literal_values().Get(a_id), Eq(a));
-  EXPECT_THAT(value_stores.string_literal_values().Get(b_id), Eq(b));
+  EXPECT_THAT(string_literals.Get(a_id), Eq(a));
+  EXPECT_THAT(string_literals.Get(b_id), Eq(b));
 
-  EXPECT_THAT(value_stores.string_literal_values().Lookup(a), Eq(a_id));
-  EXPECT_THAT(value_stores.string_literal_values().Lookup("c"),
-              Eq(StringLiteralValueId::Invalid));
-}
-
-auto MatchSharedValues(testing::Matcher<Yaml::MappingValue> ints,
-                       testing::Matcher<Yaml::MappingValue> reals,
-                       testing::Matcher<Yaml::MappingValue> identifiers,
-                       testing::Matcher<Yaml::MappingValue> strings) -> auto {
-  return Yaml::IsYaml(Yaml::Sequence(ElementsAre(Yaml::Mapping(ElementsAre(Pair(
-      "shared_values",
-      Yaml::Mapping(ElementsAre(Pair("ints", Yaml::Mapping(ints)),
-                                Pair("reals", Yaml::Mapping(reals)),
-                                Pair("identifiers", Yaml::Mapping(identifiers)),
-                                Pair("strings", Yaml::Mapping(strings))))))))));
-}
-
-TEST(ValueStore, PrintEmpty) {
-  SharedValueStores value_stores;
-  TestRawOstream out;
-  value_stores.Print(out);
-  EXPECT_THAT(Yaml::Value::FromText(out.TakeStr()),
-              MatchSharedValues(IsEmpty(), IsEmpty(), IsEmpty(), IsEmpty()));
-}
-
-TEST(ValueStore, PrintVals) {
-  SharedValueStores value_stores;
-  llvm::APInt apint(64, 8, /*isSigned=*/true);
-  value_stores.ints().Add(apint);
-  value_stores.reals().Add(
-      Real{.mantissa = apint, .exponent = apint, .is_decimal = true});
-  value_stores.identifiers().Add("a");
-  value_stores.string_literal_values().Add("foo'\"baz");
-  TestRawOstream out;
-  value_stores.Print(out);
-
-  EXPECT_THAT(Yaml::Value::FromText(out.TakeStr()),
-              MatchSharedValues(
-                  ElementsAre(Pair("int0", Yaml::Scalar("8"))),
-                  ElementsAre(Pair("real0", Yaml::Scalar("8*10^8"))),
-                  ElementsAre(Pair("identifier0", Yaml::Scalar("a"))),
-                  ElementsAre(Pair("string0", Yaml::Scalar("foo'\"baz")))));
+  EXPECT_THAT(string_literals.Lookup(a), Eq(a_id));
+  EXPECT_THAT(string_literals.Lookup("c"), Eq(StringLiteralValueId::Invalid));
 }
 
 }  // namespace

+ 3 - 1
toolchain/check/BUILD

@@ -117,7 +117,7 @@ cc_library(
         "//common:vlog",
         "//toolchain/base:kind_switch",
         "//toolchain/base:pretty_stack_trace_function",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:format_providers",
         "//toolchain/lex:token_index",
@@ -241,6 +241,8 @@ cc_library(
         "//common:set",
         "//common:vlog",
         "//toolchain/base:index_base",
+        "//toolchain/base:value_ids",
+        "//toolchain/base:value_store",
         "//toolchain/sem_ir:file",
         "//toolchain/sem_ir:ids",
         "@llvm-project//llvm:Support",

+ 1 - 1
toolchain/check/check.h

@@ -6,7 +6,7 @@
 #define CARBON_TOOLCHAIN_CHECK_CHECK_H_
 
 #include "common/ostream.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/check/sem_ir_diagnostic_converter.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/lex/tokenized_buffer.h"

+ 5 - 5
toolchain/check/context.h

@@ -484,13 +484,13 @@ class Context {
 
   // Directly expose SemIR::File data accessors for brevity in calls.
 
-  auto identifiers() -> CanonicalValueStore<IdentifierId>& {
+  auto identifiers() -> SharedValueStores::IdentifierStore& {
     return sem_ir().identifiers();
   }
-  auto ints() -> CanonicalValueStore<IntId>& { return sem_ir().ints(); }
-  auto reals() -> ValueStore<RealId>& { return sem_ir().reals(); }
-  auto floats() -> FloatValueStore& { return sem_ir().floats(); }
-  auto string_literal_values() -> CanonicalValueStore<StringLiteralValueId>& {
+  auto ints() -> SharedValueStores::IntStore& { return sem_ir().ints(); }
+  auto reals() -> SharedValueStores::RealStore& { return sem_ir().reals(); }
+  auto floats() -> SharedValueStores::FloatStore& { return sem_ir().floats(); }
+  auto string_literal_values() -> SharedValueStores::StringLiteralStore& {
     return sem_ir().string_literal_values();
   }
   auto entity_names() -> SemIR::EntityNameStore& {

+ 2 - 2
toolchain/check/eval.cpp

@@ -112,8 +112,8 @@ class EvalContext {
         context().constant_values().GetInstId(GetConstantValue(id)));
   }
 
-  auto ints() -> CanonicalValueStore<IntId>& { return sem_ir().ints(); }
-  auto floats() -> FloatValueStore& { return sem_ir().floats(); }
+  auto ints() -> SharedValueStores::IntStore& { return sem_ir().ints(); }
+  auto floats() -> SharedValueStores::FloatStore& { return sem_ir().floats(); }
   auto entity_names() -> SemIR::EntityNameStore& {
     return sem_ir().entity_names();
   }

+ 2 - 0
toolchain/check/lexical_lookup.h

@@ -6,6 +6,8 @@
 #ifndef CARBON_TOOLCHAIN_CHECK_LEXICAL_LOOKUP_H_
 #define CARBON_TOOLCHAIN_CHECK_LEXICAL_LOOKUP_H_
 
+#include "toolchain/base/value_ids.h"
+#include "toolchain/base/value_store.h"
 #include "toolchain/check/scope_index.h"
 #include "toolchain/sem_ir/ids.h"
 

+ 1 - 1
toolchain/driver/BUILD

@@ -111,7 +111,7 @@ cc_library(
         "//common:version",
         "//common:vlog",
         "//toolchain/base:pretty_stack_trace_function",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/check",
         "//toolchain/codegen",
         "//toolchain/diagnostics:diagnostic_emitter",

+ 1 - 1
toolchain/driver/format_subcommand.cpp

@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_consumer.h"
 #include "toolchain/format/format.h"
 #include "toolchain/lex/lex.h"

+ 1 - 1
toolchain/language_server/BUILD

@@ -19,7 +19,7 @@ cc_library(
     deps = [
         "//common:error",
         "//common:ostream",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:null_diagnostics",
         "//toolchain/lex",
         "//toolchain/lex:tokenized_buffer",

+ 1 - 1
toolchain/language_server/server.cpp

@@ -4,7 +4,7 @@
 
 #include "toolchain/language_server/server.h"
 
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/null_diagnostics.h"
 #include "toolchain/lex/lex.h"
 #include "toolchain/parse/node_kind.h"

+ 6 - 6
toolchain/lex/BUILD

@@ -191,7 +191,7 @@ cc_library(
         ":tokenized_buffer",
         "//common:check",
         "//common:variant_helpers",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/source:source_buffer",
         "@llvm-project//llvm:Support",
@@ -223,7 +223,7 @@ cc_library(
         "//common:string_helpers",
         "//toolchain/base:index_base",
         "//toolchain/base:mem_usage",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/source:source_buffer",
         "@llvm-project//llvm:Support",
@@ -238,7 +238,7 @@ cc_library(
         ":lex",
         ":tokenized_buffer",
         "//common:check",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "@googletest//:gtest",
         "@llvm-project//llvm:Support",
     ],
@@ -255,7 +255,7 @@ cc_test(
         ":tokenized_buffer_test_helpers",
         "//testing/base:gtest_main",
         "//testing/base:test_raw_ostream",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:mocks",
         "//toolchain/testing:compile_helper",
@@ -274,7 +274,7 @@ cc_fuzz_test(
         ":lex",
         "//common:check",
         "//testing/fuzzing:libfuzzer_header",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:null_diagnostics",
         "@llvm-project//llvm:Support",
@@ -292,7 +292,7 @@ cc_binary(
         "//common:check",
         "//testing/base:benchmark_main",
         "//testing/base:source_gen_lib",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:null_diagnostics",
         "@abseil-cpp//absl/random",

+ 1 - 1
toolchain/lex/lex.cpp

@@ -12,7 +12,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Compiler.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/lex/character_set.h"
 #include "toolchain/lex/helpers.h"
 #include "toolchain/lex/numeric_literal.h"

+ 1 - 1
toolchain/lex/lex.h

@@ -5,7 +5,7 @@
 #ifndef CARBON_TOOLCHAIN_LEX_LEX_H_
 #define CARBON_TOOLCHAIN_LEX_LEX_H_
 
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/lex/tokenized_buffer.h"
 #include "toolchain/source/source_buffer.h"

+ 1 - 1
toolchain/lex/tokenized_buffer.cpp

@@ -12,7 +12,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/lex/character_set.h"
 #include "toolchain/lex/numeric_literal.h"

+ 1 - 1
toolchain/lex/tokenized_buffer.h

@@ -16,7 +16,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "toolchain/base/index_base.h"
 #include "toolchain/base/mem_usage.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/lex/token_index.h"
 #include "toolchain/lex/token_kind.h"

+ 1 - 1
toolchain/lex/tokenized_buffer_benchmark.cpp

@@ -12,7 +12,7 @@
 #include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/StringExtras.h"
 #include "testing/base/source_gen.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/diagnostics/null_diagnostics.h"
 #include "toolchain/lex/lex.h"

+ 1 - 1
toolchain/lex/tokenized_buffer_fuzzer.cpp

@@ -7,7 +7,7 @@
 #include "common/check.h"
 #include "llvm/ADT/StringRef.h"
 #include "testing/fuzzing/libfuzzer.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/null_diagnostics.h"
 #include "toolchain/lex/lex.h"
 

+ 1 - 1
toolchain/lex/tokenized_buffer_test.cpp

@@ -14,7 +14,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "testing/base/test_raw_ostream.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/diagnostics/mocks.h"
 #include "toolchain/lex/lex.h"

+ 1 - 1
toolchain/lex/tokenized_buffer_test_helpers.h

@@ -8,7 +8,7 @@
 #include <gmock/gmock.h>
 
 #include "common/check.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/lex/tokenized_buffer.h"
 
 namespace Carbon::Testing {

+ 4 - 3
toolchain/parse/BUILD

@@ -94,7 +94,7 @@ cc_library(
         "//common:check",
         "//common:ostream",
         "//toolchain/base:pretty_stack_trace_function",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:format_providers",
         "//toolchain/lex:token_kind",
@@ -127,6 +127,7 @@ cc_library(
         "//common:error",
         "//common:ostream",
         "//common:struct_reflection",
+        "//toolchain/base:value_store",
         "//toolchain/lex:tokenized_buffer",
         "@llvm-project//llvm:Support",
     ],
@@ -143,7 +144,7 @@ cc_test(
         "//common:ostream",
         "//testing/base:gtest_main",
         "//testing/base:test_raw_ostream",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:mocks",
         "//toolchain/lex",
@@ -164,7 +165,7 @@ cc_fuzz_test(
         ":parse",
         "//common:check",
         "//testing/fuzzing:libfuzzer_header",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/diagnostics:null_diagnostics",
         "//toolchain/lex",

+ 1 - 1
toolchain/parse/handle_import_and_package.cpp

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/lex/token_kind.h"
 #include "toolchain/lex/tokenized_buffer.h"
 #include "toolchain/parse/context.h"

+ 1 - 1
toolchain/parse/parse_fuzzer.cpp

@@ -7,7 +7,7 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "testing/fuzzing/libfuzzer.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/null_diagnostics.h"
 #include "toolchain/lex/lex.h"
 #include "toolchain/parse/parse.h"

+ 1 - 0
toolchain/parse/tree.h

@@ -13,6 +13,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/iterator_range.h"
+#include "toolchain/base/value_store.h"
 #include "toolchain/lex/tokenized_buffer.h"
 #include "toolchain/parse/node_ids.h"
 #include "toolchain/parse/node_kind.h"

+ 1 - 1
toolchain/parse/tree_test.cpp

@@ -10,7 +10,7 @@
 #include <forward_list>
 
 #include "testing/base/test_raw_ostream.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/diagnostics/mocks.h"
 #include "toolchain/lex/lex.h"

+ 7 - 3
toolchain/sem_ir/BUILD

@@ -36,7 +36,8 @@ cc_library(
         "//common:check",
         "//common:ostream",
         "//toolchain/base:index_base",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
+        "//toolchain/base:value_ids",
         "//toolchain/diagnostics:diagnostic_emitter",
         "//toolchain/parse:node_kind",
         "//toolchain/sem_ir:builtin_inst_kind",
@@ -75,6 +76,7 @@ cc_library(
         "//common:ostream",
         "//common:struct_reflection",
         "//toolchain/base:index_base",
+        "//toolchain/base:value_store",
         "@llvm-project//llvm:Support",
     ],
 )
@@ -127,6 +129,8 @@ cc_library(
         "//common:ostream",
         "//common:set",
         "//toolchain/base:kind_switch",
+        "//toolchain/base:shared_value_stores",
+        "//toolchain/base:value_ids",
         "//toolchain/base:value_store",
         "//toolchain/base:yaml",
         "//toolchain/lex:token_kind",
@@ -159,7 +163,7 @@ cc_library(
         ":inst_kind",
         "//common:ostream",
         "//toolchain/base:kind_switch",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/lex:tokenized_buffer",
         "//toolchain/parse:tree",
         "@llvm-project//llvm:Support",
@@ -177,7 +181,7 @@ cc_library(
         ":inst_namer",
         "//common:ostream",
         "//toolchain/base:kind_switch",
-        "//toolchain/base:value_store",
+        "//toolchain/base:shared_value_stores",
         "//toolchain/lex:tokenized_buffer",
         "//toolchain/parse:tree",
         "@llvm-project//llvm:Support",

+ 1 - 1
toolchain/sem_ir/file.cpp

@@ -8,7 +8,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "toolchain/base/kind_switch.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/base/yaml.h"
 #include "toolchain/parse/node_ids.h"
 #include "toolchain/sem_ir/builtin_inst_kind.h"

+ 15 - 10
toolchain/sem_ir/file.h

@@ -10,6 +10,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/base/value_store.h"
 #include "toolchain/base/yaml.h"
 #include "toolchain/sem_ir/class.h"
@@ -73,29 +74,33 @@ class File : public Printable<File> {
   auto library_id() const -> SemIR::LibraryNameId { return library_id_; }
 
   // Directly expose SharedValueStores members.
-  auto identifiers() -> CanonicalValueStore<IdentifierId>& {
+  auto identifiers() -> SharedValueStores::IdentifierStore& {
     return value_stores_->identifiers();
   }
-  auto identifiers() const -> const CanonicalValueStore<IdentifierId>& {
+  auto identifiers() const -> const SharedValueStores::IdentifierStore& {
     return value_stores_->identifiers();
   }
-  auto ints() -> CanonicalValueStore<IntId>& { return value_stores_->ints(); }
-  auto ints() const -> const CanonicalValueStore<IntId>& {
+  auto ints() -> SharedValueStores::IntStore& { return value_stores_->ints(); }
+  auto ints() const -> const SharedValueStores::IntStore& {
     return value_stores_->ints();
   }
-  auto reals() -> ValueStore<RealId>& { return value_stores_->reals(); }
-  auto reals() const -> const ValueStore<RealId>& {
+  auto reals() -> SharedValueStores::RealStore& {
     return value_stores_->reals();
   }
-  auto floats() -> FloatValueStore& { return value_stores_->floats(); }
-  auto floats() const -> const FloatValueStore& {
+  auto reals() const -> const SharedValueStores::RealStore& {
+    return value_stores_->reals();
+  }
+  auto floats() -> SharedValueStores::FloatStore& {
+    return value_stores_->floats();
+  }
+  auto floats() const -> const SharedValueStores::FloatStore& {
     return value_stores_->floats();
   }
-  auto string_literal_values() -> CanonicalValueStore<StringLiteralValueId>& {
+  auto string_literal_values() -> SharedValueStores::StringLiteralStore& {
     return value_stores_->string_literal_values();
   }
   auto string_literal_values() const
-      -> const CanonicalValueStore<StringLiteralValueId>& {
+      -> const SharedValueStores::StringLiteralStore& {
     return value_stores_->string_literal_values();
   }
 

+ 1 - 1
toolchain/sem_ir/formatter.cpp

@@ -9,7 +9,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include "toolchain/base/kind_switch.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/lex/tokenized_buffer.h"
 #include "toolchain/parse/tree.h"
 #include "toolchain/sem_ir/builtin_function_kind.h"

+ 1 - 0
toolchain/sem_ir/generic.h

@@ -6,6 +6,7 @@
 #define CARBON_TOOLCHAIN_SEM_IR_GENERIC_H_
 
 #include "common/set.h"
+#include "toolchain/base/value_store.h"
 #include "toolchain/sem_ir/ids.h"
 
 namespace Carbon::SemIR {

+ 1 - 1
toolchain/sem_ir/ids.h

@@ -8,7 +8,7 @@
 #include "common/check.h"
 #include "common/ostream.h"
 #include "toolchain/base/index_base.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/value_ids.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/parse/node_ids.h"
 #include "toolchain/sem_ir/builtin_inst_kind.h"

+ 1 - 0
toolchain/sem_ir/impl.h

@@ -6,6 +6,7 @@
 #define CARBON_TOOLCHAIN_SEM_IR_IMPL_H_
 
 #include "common/map.h"
+#include "toolchain/base/value_store.h"
 #include "toolchain/sem_ir/entity_with_params_base.h"
 #include "toolchain/sem_ir/ids.h"
 

+ 1 - 0
toolchain/sem_ir/inst.h

@@ -13,6 +13,7 @@
 #include "common/ostream.h"
 #include "common/struct_reflection.h"
 #include "toolchain/base/index_base.h"
+#include "toolchain/base/value_store.h"
 #include "toolchain/sem_ir/block_value_store.h"
 #include "toolchain/sem_ir/builtin_inst_kind.h"
 #include "toolchain/sem_ir/id_kind.h"

+ 1 - 1
toolchain/sem_ir/inst_namer.cpp

@@ -6,7 +6,7 @@
 
 #include "common/ostream.h"
 #include "toolchain/base/kind_switch.h"
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/lex/tokenized_buffer.h"
 #include "toolchain/parse/tree.h"
 #include "toolchain/sem_ir/builtin_function_kind.h"

+ 2 - 0
toolchain/sem_ir/name.h

@@ -5,6 +5,8 @@
 #ifndef CARBON_TOOLCHAIN_SEM_IR_NAME_H_
 #define CARBON_TOOLCHAIN_SEM_IR_NAME_H_
 
+#include "toolchain/base/value_ids.h"
+#include "toolchain/base/value_store.h"
 #include "toolchain/sem_ir/ids.h"
 
 namespace Carbon::SemIR {

+ 1 - 1
toolchain/sem_ir/type.h

@@ -5,7 +5,7 @@
 #ifndef CARBON_TOOLCHAIN_SEM_IR_TYPE_H_
 #define CARBON_TOOLCHAIN_SEM_IR_TYPE_H_
 
-#include "toolchain/base/value_store.h"
+#include "toolchain/base/shared_value_stores.h"
 #include "toolchain/sem_ir/constant.h"
 #include "toolchain/sem_ir/ids.h"
 #include "toolchain/sem_ir/inst.h"