diff --git a/toolchain/base/BUILD b/toolchain/base/BUILD index 9a2e802fa334..ec307eab6827 100644 --- a/toolchain/base/BUILD +++ b/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"], diff --git a/toolchain/base/shared_value_stores.h b/toolchain/base/shared_value_stores.h new file mode 100644 index 000000000000..1a9d38d586e9 --- /dev/null +++ b/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 { + public: + // Provide types that can be used by APIs to forward access to these stores. + using IntStore = CanonicalValueStore; + using RealStore = ValueStore; + using FloatStore = CanonicalValueStore; + using IdentifierStore = CanonicalValueStore; + using StringLiteralStore = CanonicalValueStore; + + 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 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_ diff --git a/toolchain/base/shared_value_stores_test.cpp b/toolchain/base/shared_value_stores_test.cpp new file mode 100644 index 000000000000..430d0931fa20 --- /dev/null +++ b/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 +#include + +#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 ints, + testing::Matcher reals, + testing::Matcher identifiers, + testing::Matcher 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 diff --git a/toolchain/base/value_ids.h b/toolchain/base/value_ids.h new file mode 100644 index 000000000000..e632a5589b0f --- /dev/null +++ b/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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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_ diff --git a/toolchain/base/value_store.h b/toolchain/base/value_store.h index 97d216da8678..e1bc3e9b137d 100644 --- a/toolchain/base/value_store.h +++ b/toolchain/base/value_store.h @@ -8,116 +8,18 @@ #include #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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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::Reserve(size_t size) -> void { values_.Reserve(size); } -using FloatValueStore = CanonicalValueStore; - -// 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 { - public: - explicit SharedValueStores() = default; - - // Not copyable or movable. - SharedValueStores(const SharedValueStores&) = delete; - auto operator=(const SharedValueStores&) -> SharedValueStores& = delete; - - auto identifiers() -> CanonicalValueStore& { - return identifiers_; - } - auto identifiers() const -> const CanonicalValueStore& { - return identifiers_; - } - auto ints() -> CanonicalValueStore& { return ints_; } - auto ints() const -> const CanonicalValueStore& { return ints_; } - auto reals() -> ValueStore& { return reals_; } - auto reals() const -> const ValueStore& { return reals_; } - auto floats() -> FloatValueStore& { return floats_; } - auto floats() const -> const FloatValueStore& { return floats_; } - auto string_literal_values() -> CanonicalValueStore& { - return string_literals_; - } - auto string_literal_values() const - -> const CanonicalValueStore& { - return string_literals_; - } - - auto OutputYaml(std::optional 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 ints_; - ValueStore reals_; - FloatValueStore floats_; - - CanonicalValueStore identifiers_; - CanonicalValueStore string_literals_; -}; - } // namespace Carbon #endif // CARBON_TOOLCHAIN_BASE_VALUE_STORE_H_ diff --git a/toolchain/base/value_store_test.cpp b/toolchain/base/value_store_test.cpp index af45eec63370..569a9fab6cdc 100644 --- a/toolchain/base/value_store_test.cpp +++ b/toolchain/base/value_store_test.cpp @@ -7,29 +7,25 @@ #include #include -#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 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 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 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 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 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 ints, - testing::Matcher reals, - testing::Matcher identifiers, - testing::Matcher 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 diff --git a/toolchain/check/BUILD b/toolchain/check/BUILD index caaea7ce223b..0f7f755b4780 100644 --- a/toolchain/check/BUILD +++ b/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", diff --git a/toolchain/check/check.h b/toolchain/check/check.h index 6becf76cbc0f..01403dfa264e 100644 --- a/toolchain/check/check.h +++ b/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" diff --git a/toolchain/check/context.h b/toolchain/check/context.h index 82f57fb0ec79..009b70bd50d1 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -484,13 +484,13 @@ class Context { // Directly expose SemIR::File data accessors for brevity in calls. - auto identifiers() -> CanonicalValueStore& { + auto identifiers() -> SharedValueStores::IdentifierStore& { return sem_ir().identifiers(); } - auto ints() -> CanonicalValueStore& { return sem_ir().ints(); } - auto reals() -> ValueStore& { return sem_ir().reals(); } - auto floats() -> FloatValueStore& { return sem_ir().floats(); } - auto string_literal_values() -> CanonicalValueStore& { + 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& { diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 56343adc8648..f314ab2d4c5e 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -112,8 +112,8 @@ class EvalContext { context().constant_values().GetInstId(GetConstantValue(id))); } - auto ints() -> CanonicalValueStore& { 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(); } diff --git a/toolchain/check/lexical_lookup.h b/toolchain/check/lexical_lookup.h index 3a0ee1cc691f..1b6780a1c01a 100644 --- a/toolchain/check/lexical_lookup.h +++ b/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" diff --git a/toolchain/driver/BUILD b/toolchain/driver/BUILD index 31f93e720ead..9cc9bfc1eb5a 100644 --- a/toolchain/driver/BUILD +++ b/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", diff --git a/toolchain/driver/format_subcommand.cpp b/toolchain/driver/format_subcommand.cpp index 33af433b0ca0..c99addf0138b 100644 --- a/toolchain/driver/format_subcommand.cpp +++ b/toolchain/driver/format_subcommand.cpp @@ -6,7 +6,7 @@ #include -#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" diff --git a/toolchain/language_server/BUILD b/toolchain/language_server/BUILD index ecc6928cd95e..f9acb5376361 100644 --- a/toolchain/language_server/BUILD +++ b/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", diff --git a/toolchain/language_server/server.cpp b/toolchain/language_server/server.cpp index f6dd9ffb39cb..582b4ae14552 100644 --- a/toolchain/language_server/server.cpp +++ b/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" diff --git a/toolchain/lex/BUILD b/toolchain/lex/BUILD index faa255e9d240..08e2f0bb0d5f 100644 --- a/toolchain/lex/BUILD +++ b/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", diff --git a/toolchain/lex/lex.cpp b/toolchain/lex/lex.cpp index 728fa25bba27..fa4c942044a2 100644 --- a/toolchain/lex/lex.cpp +++ b/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" diff --git a/toolchain/lex/lex.h b/toolchain/lex/lex.h index aa1841d0746d..9e901148e2d3 100644 --- a/toolchain/lex/lex.h +++ b/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" diff --git a/toolchain/lex/tokenized_buffer.cpp b/toolchain/lex/tokenized_buffer.cpp index 60481c8d6b66..247cf840ce8f 100644 --- a/toolchain/lex/tokenized_buffer.cpp +++ b/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" diff --git a/toolchain/lex/tokenized_buffer.h b/toolchain/lex/tokenized_buffer.h index 766b49df58cd..b958eef20ef5 100644 --- a/toolchain/lex/tokenized_buffer.h +++ b/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" diff --git a/toolchain/lex/tokenized_buffer_benchmark.cpp b/toolchain/lex/tokenized_buffer_benchmark.cpp index 0c319eddc891..5c91ab4e2045 100644 --- a/toolchain/lex/tokenized_buffer_benchmark.cpp +++ b/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" diff --git a/toolchain/lex/tokenized_buffer_fuzzer.cpp b/toolchain/lex/tokenized_buffer_fuzzer.cpp index 986b69e7a1bb..37117bfc0670 100644 --- a/toolchain/lex/tokenized_buffer_fuzzer.cpp +++ b/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" diff --git a/toolchain/lex/tokenized_buffer_test.cpp b/toolchain/lex/tokenized_buffer_test.cpp index f8d2b74ce0bb..1731a1b623d0 100644 --- a/toolchain/lex/tokenized_buffer_test.cpp +++ b/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" diff --git a/toolchain/lex/tokenized_buffer_test_helpers.h b/toolchain/lex/tokenized_buffer_test_helpers.h index b321210affed..85dcf8c84ccd 100644 --- a/toolchain/lex/tokenized_buffer_test_helpers.h +++ b/toolchain/lex/tokenized_buffer_test_helpers.h @@ -8,7 +8,7 @@ #include #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 { diff --git a/toolchain/parse/BUILD b/toolchain/parse/BUILD index 8e72b4174a28..310ff296eeca 100644 --- a/toolchain/parse/BUILD +++ b/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", diff --git a/toolchain/parse/handle_import_and_package.cpp b/toolchain/parse/handle_import_and_package.cpp index 29815b1f9d69..f926ca6d1443 100644 --- a/toolchain/parse/handle_import_and_package.cpp +++ b/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" diff --git a/toolchain/parse/parse_fuzzer.cpp b/toolchain/parse/parse_fuzzer.cpp index 27c513d94314..70c292cd3a95 100644 --- a/toolchain/parse/parse_fuzzer.cpp +++ b/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" diff --git a/toolchain/parse/tree.h b/toolchain/parse/tree.h index 9f1189caa6bf..f68cf68ce7f3 100644 --- a/toolchain/parse/tree.h +++ b/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" diff --git a/toolchain/parse/tree_test.cpp b/toolchain/parse/tree_test.cpp index 4e2c55bee07b..291f06a7bc1c 100644 --- a/toolchain/parse/tree_test.cpp +++ b/toolchain/parse/tree_test.cpp @@ -10,7 +10,7 @@ #include #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" diff --git a/toolchain/sem_ir/BUILD b/toolchain/sem_ir/BUILD index 3264291e21f5..a510ef03c705 100644 --- a/toolchain/sem_ir/BUILD +++ b/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", diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index 958c08c475e9..f1bc6ef83a77 100644 --- a/toolchain/sem_ir/file.cpp +++ b/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" diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index f4ca5dc3e5a7..a138a3346fbc 100644 --- a/toolchain/sem_ir/file.h +++ b/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 { auto library_id() const -> SemIR::LibraryNameId { return library_id_; } // Directly expose SharedValueStores members. - auto identifiers() -> CanonicalValueStore& { + auto identifiers() -> SharedValueStores::IdentifierStore& { return value_stores_->identifiers(); } - auto identifiers() const -> const CanonicalValueStore& { + auto identifiers() const -> const SharedValueStores::IdentifierStore& { return value_stores_->identifiers(); } - auto ints() -> CanonicalValueStore& { return value_stores_->ints(); } - auto ints() const -> const CanonicalValueStore& { + auto ints() -> SharedValueStores::IntStore& { return value_stores_->ints(); } + auto ints() const -> const SharedValueStores::IntStore& { return value_stores_->ints(); } - auto reals() -> ValueStore& { return value_stores_->reals(); } - auto reals() const -> const ValueStore& { + 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 string_literal_values() -> CanonicalValueStore& { + auto floats() const -> const SharedValueStores::FloatStore& { + return value_stores_->floats(); + } + auto string_literal_values() -> SharedValueStores::StringLiteralStore& { return value_stores_->string_literal_values(); } auto string_literal_values() const - -> const CanonicalValueStore& { + -> const SharedValueStores::StringLiteralStore& { return value_stores_->string_literal_values(); } diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index 54f303fab02a..ac67d90a5591 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/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" diff --git a/toolchain/sem_ir/generic.h b/toolchain/sem_ir/generic.h index 6f37d7935b22..baeabd61882e 100644 --- a/toolchain/sem_ir/generic.h +++ b/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 { diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index b767819722b7..15aa2dbb0338 100644 --- a/toolchain/sem_ir/ids.h +++ b/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" diff --git a/toolchain/sem_ir/impl.h b/toolchain/sem_ir/impl.h index 9675d60a0df8..b9c4e76ff8ab 100644 --- a/toolchain/sem_ir/impl.h +++ b/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" diff --git a/toolchain/sem_ir/inst.h b/toolchain/sem_ir/inst.h index 2d03a6adc84b..2152a4ba80c9 100644 --- a/toolchain/sem_ir/inst.h +++ b/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" diff --git a/toolchain/sem_ir/inst_namer.cpp b/toolchain/sem_ir/inst_namer.cpp index 8a3db2548cf5..62463a6692e7 100644 --- a/toolchain/sem_ir/inst_namer.cpp +++ b/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" diff --git a/toolchain/sem_ir/name.h b/toolchain/sem_ir/name.h index e83912c0b64f..ff3127658e47 100644 --- a/toolchain/sem_ir/name.h +++ b/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 { diff --git a/toolchain/sem_ir/type.h b/toolchain/sem_ir/type.h index 69f199c801c9..b09be3cd3490 100644 --- a/toolchain/sem_ir/type.h +++ b/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"