clang 17.0.0git
InterpBuiltin.cpp
Go to the documentation of this file.
1//===--- InterpBuiltin.cpp - Interpreter for the constexpr VM ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8#include "Boolean.h"
9#include "Interp.h"
10#include "PrimType.h"
12
13namespace clang {
14namespace interp {
15
16bool InterpretBuiltin(InterpState &S, CodePtr &PC, unsigned BuiltinID) {
17 APValue Dummy;
18
19 switch (BuiltinID) {
20 case Builtin::BI__builtin_is_constant_evaluated:
21 S.Stk.push<Boolean>(Boolean::from(S.inConstantContext()));
22 return Ret<PT_Bool, true>(S, PC, Dummy);
23 case Builtin::BI__builtin_assume:
24 return RetVoid<true>(S, PC, Dummy);
25 default:
26 return false;
27 }
28
29 return false;
30}
31
32} // namespace interp
33} // namespace clang
Defines enum values for all the target-independent builtin functions.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
Wrapper around boolean types.
Definition: Boolean.h:25
static Boolean from(T Value)
Definition: Boolean.h:91
Pointer into the code segment.
Definition: Source.h:26
Interpreter context.
Definition: InterpState.h:35
bool InterpretBuiltin(InterpState &S, CodePtr &PC, unsigned BuiltinID)
Interpret a builtin function.