literal.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_LITERAL_H_
  5. #define CARBON_TOOLCHAIN_CHECK_LITERAL_H_
  6. #include "toolchain/base/value_ids.h"
  7. #include "toolchain/check/context.h"
  8. #include "toolchain/lex/token_info.h"
  9. #include "toolchain/sem_ir/ids.h"
  10. namespace Carbon::Check {
  11. // Forms an IntValue instruction with type `IntLiteral` for a given literal
  12. // integer value, which is assumed to be unsigned.
  13. auto MakeIntLiteral(Context& context, Parse::NodeId node_id, IntId int_id)
  14. -> SemIR::InstId;
  15. // Forms an integer type expression for either an `iN` or `uN` literal.
  16. auto MakeIntTypeLiteral(Context& context, Parse::NodeId node_id,
  17. SemIR::IntKind int_kind, IntId size_id)
  18. -> SemIR::InstId;
  19. // Forms an integer type of the specified kind and bit-width.
  20. auto MakeIntType(Context& context, Parse::NodeId node_id,
  21. SemIR::IntKind int_kind, IntId size_id) -> SemIR::TypeId;
  22. // Forms a floating point type expression for `fN` literal.
  23. auto MakeFloatTypeLiteral(Context& context, Parse::NodeId node_id,
  24. IntId size_id) -> SemIR::InstId;
  25. // Forms a string literal value instruction for a given string literal.
  26. auto MakeStringLiteral(Context& context, Parse::StringLiteralId node_id,
  27. StringLiteralValueId value_id) -> SemIR::InstId;
  28. // Forms a string literal type expression for a `str` literal.
  29. auto MakeStringTypeLiteral(Context& context, Parse::NodeId node_id)
  30. -> SemIR::InstId;
  31. // Forms a string type.
  32. auto MakeStringType(Context& context, Parse::NodeId node_id) -> SemIR::TypeId;
  33. } // namespace Carbon::Check
  34. #endif // CARBON_TOOLCHAIN_CHECK_LITERAL_H_