CIRCT 22.0.0git
Loading...
Searching...
No Matches
IRInterface.h
Go to the documentation of this file.
1//===- IRInterface.h - ArcRuntime internal API ----------------------------===//
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// Declares the runtime functions called from the MLIR model.
10//
11// This file defines the runtime's internal API. Changes to the internal API
12// must be reflected in the lowering passes of the MLIR model.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef CIRCT_DIALECT_ARC_RUNTIME_IRINTERFACE_H
17#define CIRCT_DIALECT_ARC_RUNTIME_IRINTERFACE_H
18
19// NOLINTBEGIN(readability-identifier-naming)
20
21#ifndef ARC_IR_EXPORT
22#ifndef ARC_RUNTIME_JIT_BIND
23
24// Marco definition for the shipped version of the library:
25// Symbols have to be visible to allow linking of the precompiled hardware
26// model against the static or dynamic runtime library.
27
28#ifdef _WIN32
29#define ARC_IR_EXPORT extern "C" __declspec(dllexport)
30#else
31#define ARC_IR_EXPORT extern "C" __attribute__((visibility("default")))
32#endif
33
34#else // #ifndef ARC_RUNTIME_JIT_BIND
35
36// Marco definition for the JIT runner version of the library:
37// Symbols are deliberately hidden in the executable's symbol table and
38// instead explicitly bound at runtime. This avoids issues due to linker GC
39// and internalization.
40
41#ifdef _WIN32
42#define ARC_IR_EXPORT extern "C"
43#else
44#define ARC_IR_EXPORT extern "C" __attribute__((visibility("hidden")))
45#endif
46
47#endif // #ifndef ARC_RUNTIME_JIT_BIND
48#endif // #ifndef ARC_IR_EXPORT
49
51
52#include <stdint.h>
53
54/// Allocate and initialize the state for a new instance of the given hardware
55/// model.
56///
57/// This function must allocate an `ArcState` struct with at least
58/// `model->numStateBytes` bytes provided for the `modelState` array.
59/// It must return the pointer to the zero initialized model state which is
60/// required to be 16-byte-aligned.
61///
62/// `args` is a zero terminated string containing implementation specific
63/// options for the new instance or `null`.
64ARC_IR_EXPORT uint8_t *
65arcRuntimeIR_allocInstance(const ArcRuntimeModelInfo *model, const char *args);
66
67/// Destroy and deallocate the state of a model instance.
68///
69/// This function is responsible for releasing all resources that previously
70/// have been allocated by `arcRuntimeIR_allocInstance`.
71ARC_IR_EXPORT void arcRuntimeIR_deleteInstance(uint8_t *modelState);
72
73/// Pre-Eval hook of the runtime library.
74///
75/// Simulation drivers must call this once before every invocation of the
76/// model's `eval` function.
77ARC_IR_EXPORT void arcRuntimeIR_onEval(uint8_t *modelState);
78
79// NOLINTEND(readability-identifier-naming)
80#endif // CIRCT_DIALECT_ARC_RUNTIME_IRINTERFACE_H
ARC_IR_EXPORT uint8_t * arcRuntimeIR_allocInstance(const ArcRuntimeModelInfo *model, const char *args)
Allocate and initialize the state for a new instance of the given hardware model.
ARC_IR_EXPORT void arcRuntimeIR_deleteInstance(uint8_t *modelState)
Destroy and deallocate the state of a model instance.
ARC_IR_EXPORT void arcRuntimeIR_onEval(uint8_t *modelState)
Pre-Eval hook of the runtime library.
#define ARC_IR_EXPORT
Definition IRInterface.h:31
Static information for a compiled hardware model, generated by the MLIR lowering.
Definition Common.h:57