subst.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_CHECK_SUBST_H_
  5. #define CARBON_TOOLCHAIN_CHECK_SUBST_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::Check {
  9. // A substitution that is being performed.
  10. struct Substitution {
  11. // The ID of a `BindSymbolicName` instruction that is being replaced.
  12. SemIR::InstId bind_id;
  13. // The replacement constant value to substitute.
  14. SemIR::ConstantId replacement_id;
  15. };
  16. using Substitutions = llvm::ArrayRef<Substitution>;
  17. // Replaces the `BindSymbolicName` instruction `bind_id` with `replacement_id`
  18. // throughout the constant `const_id`, and returns the substituted value.
  19. auto SubstConstant(Context& context, SemIR::ConstantId const_id,
  20. Substitutions substitutions) -> SemIR::ConstantId;
  21. // Replaces the `BindSymbolicName` instruction `bind_id` with `replacement_id`
  22. // throughout the type `type_id`, and returns the substituted value.
  23. auto SubstType(Context& context, SemIR::TypeId type_id,
  24. Substitutions substitutions) -> SemIR::TypeId;
  25. } // namespace Carbon::Check
  26. #endif // CARBON_TOOLCHAIN_CHECK_SUBST_H_