mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:21:19 +01:00
Add a basic Core.Print function for ints. (#4078)
We'd been discussing that explorer remains necessary for print, and I was wondering if this kind of approach would be okay (we _probably_ want this to work, based on #2110, albeit with more overloads -- but I don't think there's a good way to support overloads at the moment). ``` ╚╡../bazel-bin/examples/sieve 2 3 5 7 11 13 17 19 23 29 31 37 41 43 ... ```
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "toolchain/sem_ir/builtin_function_kind.h"
|
||||
#include "toolchain/sem_ir/function.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/inst_kind.h"
|
||||
#include "toolchain/sem_ir/typed_insts.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
@@ -709,6 +710,11 @@ static auto MakeConstantForBuiltinCall(Context& context, SemIRLoc loc,
|
||||
case SemIR::BuiltinFunctionKind::None:
|
||||
CARBON_FATAL() << "Not a builtin function.";
|
||||
|
||||
case SemIR::BuiltinFunctionKind::PrintInt: {
|
||||
// Providing a constant result would allow eliding the function call.
|
||||
return SemIR::ConstantId::NotConstant;
|
||||
}
|
||||
|
||||
case SemIR::BuiltinFunctionKind::IntMakeType32: {
|
||||
return context.constant_values().Get(SemIR::InstId::BuiltinIntType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user