Files
carbon-lang/toolchain/check/literal.h
T
Richard SmithandJon Ross-Perkins e4412a95dd Factor out machinery for forming int type literals. (#4616)
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>
2024-12-03 18:46:27 +00:00

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_