1*700637cbSDimitry Andric //===------------------ InterpBuiltinBitCast.h ------------------*- C++ -*-===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric
9*700637cbSDimitry Andric #ifndef LLVM_CLANG_AST_INTERP_BUILTIN_BIT_CAST_H
10*700637cbSDimitry Andric #define LLVM_CLANG_AST_INTERP_BUILTIN_BIT_CAST_H
11*700637cbSDimitry Andric
12*700637cbSDimitry Andric #include "BitcastBuffer.h"
13*700637cbSDimitry Andric #include <cstddef>
14*700637cbSDimitry Andric
15*700637cbSDimitry Andric namespace clang {
16*700637cbSDimitry Andric namespace interp {
17*700637cbSDimitry Andric class Pointer;
18*700637cbSDimitry Andric class InterpState;
19*700637cbSDimitry Andric class CodePtr;
20*700637cbSDimitry Andric class Context;
21*700637cbSDimitry Andric
swapBytes(std::byte * M,size_t N)22*700637cbSDimitry Andric inline static void swapBytes(std::byte *M, size_t N) {
23*700637cbSDimitry Andric for (size_t I = 0; I != (N / 2); ++I)
24*700637cbSDimitry Andric std::swap(M[I], M[N - 1 - I]);
25*700637cbSDimitry Andric }
26*700637cbSDimitry Andric
27*700637cbSDimitry Andric bool DoBitCast(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
28*700637cbSDimitry Andric std::byte *Buff, Bits BitWidth, Bits FullBitWidth,
29*700637cbSDimitry Andric bool &HasIndeterminateBits);
30*700637cbSDimitry Andric bool DoBitCastPtr(InterpState &S, CodePtr OpPC, const Pointer &FromPtr,
31*700637cbSDimitry Andric Pointer &ToPtr);
32*700637cbSDimitry Andric bool DoBitCastPtr(InterpState &S, CodePtr OpPC, const Pointer &FromPtr,
33*700637cbSDimitry Andric Pointer &ToPtr, size_t Size);
34*700637cbSDimitry Andric bool readPointerToBuffer(const Context &Ctx, const Pointer &FromPtr,
35*700637cbSDimitry Andric BitcastBuffer &Buffer, bool ReturnOnUninit);
36*700637cbSDimitry Andric
37*700637cbSDimitry Andric bool DoMemcpy(InterpState &S, CodePtr OpPC, const Pointer &SrcPtr,
38*700637cbSDimitry Andric const Pointer &DestPtr, Bits Size);
39*700637cbSDimitry Andric
40*700637cbSDimitry Andric } // namespace interp
41*700637cbSDimitry Andric } // namespace clang
42*700637cbSDimitry Andric
43*700637cbSDimitry Andric #endif
44