aggregate.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  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_LOWER_AGGREGATE_H_
  5. #define CARBON_TOOLCHAIN_LOWER_AGGREGATE_H_
  6. #include "llvm/ADT/Twine.h"
  7. #include "llvm/IR/Value.h"
  8. #include "toolchain/lower/function_context.h"
  9. #include "toolchain/sem_ir/ids.h"
  10. namespace Carbon::Lower {
  11. // Extracts an element of an aggregate, such as a struct, tuple, or class, by
  12. // index. Depending on the expression category and value representation of the
  13. // aggregate input, this will either produce a value or a reference.
  14. auto GetAggregateElement(FunctionContext& context, SemIR::InstId aggr_inst_id,
  15. SemIR::ElementIndex idx, SemIR::InstId result_inst_id,
  16. llvm::Twine name) -> llvm::Value*;
  17. // Emits the value representation for a struct or tuple whose elements are the
  18. // contents of `refs_id`.
  19. auto EmitAggregateValueRepr(FunctionContext& context,
  20. SemIR::InstId value_inst_id,
  21. SemIR::InstBlockId refs_id) -> llvm::Value*;
  22. // Emits the initialization for a struct or tuple.
  23. auto EmitAggregateInitializer(FunctionContext& context,
  24. SemIR::InstId init_inst_id,
  25. SemIR::InstBlockId refs_id, llvm::Twine name)
  26. -> llvm::Value*;
  27. } // namespace Carbon::Lower
  28. #endif // CARBON_TOOLCHAIN_LOWER_AGGREGATE_H_