LLVM
24.0.0git
lib
UBAwareInterpreter
Library.h
Go to the documentation of this file.
1
//===--- Library.h - Library calls for llubi ------------------------------===//
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
//
9
// This file declares common libcalls for llubi.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_TOOLS_LLUBI_LIBRARY_H
14
#define LLVM_TOOLS_LLUBI_LIBRARY_H
15
16
#include "
ExecutorBase.h
"
17
#include "
llvm/UBAwareInterpreter/Context.h
"
18
#include "
llvm/UBAwareInterpreter/Value.h
"
19
#include <optional>
20
#include <string>
21
22
namespace
llvm::ubi
{
23
24
class
Library
{
25
Context
&Ctx;
26
EventHandler
&Handler;
27
const
DataLayout
&DL;
28
ExecutorBase
&Executor;
29
30
std::optional<std::string> readStringFromMemory(
const
Pointer
&Ptr);
31
32
AnyValue
executeMalloc(
StringRef
Name,
Type
*
Type
,
ArrayRef<AnyValue>
Args,
33
MemAllocKind
AllocKind);
34
AnyValue
executeCalloc(
StringRef
Name,
Type
*
Type
,
ArrayRef<AnyValue>
Args,
35
MemAllocKind
AllocKind);
36
AnyValue
executeFree(
ArrayRef<AnyValue>
Args,
unsigned
AS);
37
AnyValue
executeMemTransfer(
ArrayRef<AnyValue>
Args,
Intrinsic::ID
IID);
38
AnyValue
executeMemset(
ArrayRef<AnyValue>
Args);
39
AnyValue
executePuts(
ArrayRef<AnyValue>
Args);
40
AnyValue
executePrintf(
ArrayRef<AnyValue>
Args);
41
AnyValue
executeExit(
ArrayRef<AnyValue>
Args);
42
AnyValue
executeAbort();
43
AnyValue
executeTerminate();
44
45
public
:
46
Library
(
Context
&Ctx,
EventHandler
&Handler,
const
DataLayout
&DL,
47
ExecutorBase
&Executor);
48
49
/// Simulates a libcall. Returns std::nullopt if an unsupported LibFunc is
50
/// passed. Note that the caller is responsible for ensuring the types and
51
/// number of the arguments are correct.
52
std::optional<AnyValue>
executeLibcall
(LibFunc LF,
StringRef
Name,
53
FunctionType
*FuncType,
54
ArrayRef<AnyValue>
Args);
55
};
56
57
}
// namespace llvm::ubi
58
59
#endif
// LLVM_TOOLS_LLUBI_LIBRARY_H
ExecutorBase.h
Context.h
Value.h
llvm::ArrayRef
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition
ArrayRef.h:40
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition
DataLayout.h:64
llvm::FunctionType
Class to represent function types.
Definition
DerivedTypes.h:165
llvm::StringRef
Represent a constant reference to a string, i.e.
Definition
StringRef.h:56
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition
Type.h:46
llvm::ubi::AnyValue
Definition
Value.h:335
llvm::ubi::Context
The global context for the interpreter.
Definition
Context.h:227
llvm::ubi::EventHandler
An interface for handling events and managing outputs during interpretation.
Definition
Context.h:166
llvm::ubi::ExecutorBase
Definition
ExecutorBase.h:86
llvm::ubi::Library::executeLibcall
std::optional< AnyValue > executeLibcall(LibFunc LF, StringRef Name, FunctionType *FuncType, ArrayRef< AnyValue > Args)
Simulates a libcall.
Definition
Library.cpp:365
llvm::ubi::Library::Library
Library(Context &Ctx, EventHandler &Handler, const DataLayout &DL, ExecutorBase &Executor)
Definition
Library.cpp:27
llvm::ubi::Pointer
Definition
Value.h:224
llvm::Intrinsic::ID
unsigned ID
Definition
GenericSSAContext.h:28
llvm::ubi
Definition
Context.h:24
llvm::ubi::MemAllocKind
MemAllocKind
Definition
Context.h:32
Generated on
for LLVM by
1.14.0