CIRCT 22.0.0git
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1//===- Common.h - Common declarations for the ArcRuntime ------------------===//
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 common structs for the ArcRuntime.
10//
11// This file belongs to both the public and internal API of the ArcRuntime.
12// Changes to the internal API must be reflected in the lowering passes of the
13// MLIR model.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef CIRCT_DIALECT_ARC_RUNTIME_COMMON_H
18#define CIRCT_DIALECT_ARC_RUNTIME_COMMON_H
19
20#include <stdint.h>
21
22/// Version of the combined public and internal API.
23#define ARC_RUNTIME_API_VERSION UINT64_C(0)
24
25/// Magic number used to assert the presence of an `ArcState` struct.
26#define ARC_RUNTIME_MAGIC UINT32_C(0xAC1BB1CA)
27
28#pragma pack(push, 1)
29
30// Note: The ArcState struct uses a flexible array member to contain the
31// variable-length hardware model state. This adheres to the C99 standard.
32// It is not standard C++ but widely supported by C++ compilers, even though
33// they might emit a warning.
34#if defined(__cplusplus) && defined(__clang__)
35#pragma clang diagnostic push
36#pragma clang diagnostic ignored "-Wc99-extensions"
37#endif
38
39/// Combined runtime and model state for a hardware model instance.
40struct ArcState {
41 /// Runtime implementation specific data. Usually points to a custom struct.
42 void *impl;
43 /// Padding for alignment and reserved for future use.
44 uint32_t reserved;
45 /// Runtime magic number. Must be set to `ARC_RUNTIME_MAGIC`.
46 uint32_t magic;
47 // The model's state.
48 uint8_t modelState[];
49};
50
51#if defined(__cplusplus) && defined(__clang__)
52#pragma clang diagnostic pop
53#endif
54
55/// Static information for a compiled hardware model, generated by the
56/// MLIR lowering.
58 /// Runtime API version used when compiling the model.
59 uint64_t apiVersion;
60 /// Number of bytes required for the model's state.
61 uint64_t numStateBytes;
62 /// Name of the compiled model.
63 const char *modelName;
64};
65
66#pragma pack(pop)
67
68#endif // CIRCT_DIALECT_ARC_RUNTIME_COMMON_H
Static information for a compiled hardware model, generated by the MLIR lowering.
Definition Common.h:57
uint64_t apiVersion
Runtime API version used when compiling the model.
Definition Common.h:59
uint64_t numStateBytes
Number of bytes required for the model's state.
Definition Common.h:61
const char * modelName
Name of the compiled model.
Definition Common.h:63
Combined runtime and model state for a hardware model instance.
Definition Common.h:40
uint32_t reserved
Padding for alignment and reserved for future use.
Definition Common.h:44
void * impl
Runtime implementation specific data. Usually points to a custom struct.
Definition Common.h:42
uint8_t modelState[]
Definition Common.h:48
uint32_t magic
Runtime magic number. Must be set to ARC_RUNTIME_MAGIC.
Definition Common.h:46