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