eval.h 1.1 KB

123456789101112131415161718192021222324252627282930
  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_EVAL_H_
  5. #define CARBON_TOOLCHAIN_CHECK_EVAL_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. #include "toolchain/sem_ir/inst.h"
  9. namespace Carbon::Check {
  10. // Determines the phase of the instruction `inst`, and returns its constant
  11. // value if it has constant phase. If it has runtime phase, returns
  12. // `SemIR::ConstantId::NotConstant`.
  13. auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst)
  14. -> SemIR::ConstantId;
  15. // Evaluates the eval block for a region of a specific. Produces a block
  16. // containing the evaluated constant values of the instructions in the eval
  17. // block.
  18. auto TryEvalBlockForSpecific(Context& context, SemIRLoc loc,
  19. SemIR::SpecificId specific_id,
  20. SemIR::GenericInstIndex::Region region)
  21. -> SemIR::InstBlockId;
  22. } // namespace Carbon::Check
  23. #endif // CARBON_TOOLCHAIN_CHECK_EVAL_H_