thunk.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_THUNK_H_
  5. #define CARBON_TOOLCHAIN_CHECK_THUNK_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/check/deferred_definition_worklist.h"
  8. #include "toolchain/sem_ir/ids.h"
  9. namespace Carbon::Check {
  10. // Given a function signature and a callee function, build a thunk that matches
  11. // the given signature and calls the specified callee. Returns the callee
  12. // unchanged if it can be used directly.
  13. auto BuildThunk(Context& context, SemIR::FunctionId signature_id,
  14. SemIR::SpecificId signature_specific_id,
  15. SemIR::InstId callee_id) -> SemIR::InstId;
  16. // Builds a call to a function that forwards a call argument list built for
  17. // `function_id` to a call to `callee_id`, for use when building a call from a
  18. // thunk to its target. This is like `PerformCall`, except that it takes a list
  19. // of call arguments for `function_id`, not a syntactic argument list.
  20. auto PerformThunkCall(Context& context, SemIR::LocId loc_id,
  21. SemIR::FunctionId function_id,
  22. llvm::ArrayRef<SemIR::InstId> call_arg_ids,
  23. SemIR::InstId callee_id) -> SemIR::InstId;
  24. // Builds the definition for a thunk whose definition was deferred until the end
  25. // of the enclosing scope.
  26. auto BuildThunkDefinition(Context& context,
  27. DeferredDefinitionWorklist::DefineThunk&& task)
  28. -> void;
  29. } // namespace Carbon::Check
  30. #endif // CARBON_TOOLCHAIN_CHECK_THUNK_H_