mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Use it in the remaining few places where we currently hardcode `i32`: as the index type in array indexing, as the type for literals in `if` expressions, and as a valid return type for `Run`. In preparation for changing `Core.Int` to be a class. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_CHECK_LITERAL_H_
|
|
#define CARBON_TOOLCHAIN_CHECK_LITERAL_H_
|
|
|
|
#include "toolchain/check/context.h"
|
|
#include "toolchain/sem_ir/ids.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
// Forms an IntValue instruction with type `IntLiteral` for a given literal
|
|
// integer value, which is assumed to be unsigned.
|
|
auto MakeIntLiteral(Context& context, Parse::NodeId node_id, IntId int_id)
|
|
-> SemIR::InstId;
|
|
|
|
// Forms an integer type expression for either an `iN` or `uN` literal.
|
|
auto MakeIntTypeLiteral(Context& context, Parse::NodeId node_id,
|
|
SemIR::IntKind int_kind, IntId size_id)
|
|
-> SemIR::InstId;
|
|
|
|
// Forms an integer type of the specified kind and bit-width.
|
|
auto MakeIntType(Context& context, Parse::NodeId node_id,
|
|
SemIR::IntKind int_kind, IntId size_id) -> SemIR::TypeId;
|
|
|
|
} // namespace Carbon::Check
|
|
|
|
#endif // CARBON_TOOLCHAIN_CHECK_LITERAL_H_
|