CIRCT 23.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#include <string.h>
22#if !defined(__cplusplus)
23#include <stdalign.h>
24#endif
25
26/// Version of the combined public and internal API.
27#define ARC_RUNTIME_API_VERSION UINT64_C(1)
28
29/// Magic number used to assert the presence of an `ArcState` struct.
30#define ARC_RUNTIME_MAGIC UINT32_C(0xAC1BB1CA)
31
32#pragma pack(push, 1)
33
34// Note: The ArcState struct uses a flexible array member to contain the
35// variable-length hardware model state. This adheres to the C99 standard.
36// It is not standard C++ but widely supported by C++ compilers, even though
37// they might emit a warning.
38#if defined(__cplusplus) && defined(__clang__)
39#pragma clang diagnostic push
40#pragma clang diagnostic ignored "-Wc99-extensions"
41#endif
42
43/// Combined runtime and model state for a hardware model instance.
44struct alignas(16) ArcState {
45 /// Runtime implementation specific data. Usually points to a custom struct.
46 void *impl;
47 /// Pointer to the active trace buffer's storage.
48 /// May be null iff the model has no trace instrumentation. Otherwise must
49 /// point to buffer of at least `traceBufferCapacity` size.
50 uint64_t *traceBuffer;
51 /// Number of valid elements in the active trace buffer.
53 /// Runtime magic number. Must be set to `ARC_RUNTIME_MAGIC`.
54 uint32_t magic;
55 /// Padding for alignment and reserved for future use.
56 uint64_t reserved;
57 // The model's state.
58 uint8_t modelState[];
59};
60
61#if defined(__cplusplus) && defined(__clang__)
62#pragma clang diagnostic pop
63#endif
64
65// Forward declaration
67
68/// Static information for a compiled hardware model, generated by the
69/// MLIR lowering.
71 /// Runtime API version used when compiling the model.
72 uint64_t apiVersion;
73 /// Number of bytes required for the model's state.
74 uint64_t numStateBytes;
75 /// Name of the compiled model.
76 const char *modelName;
77 /// Signal tracing information. NULL iff the model is not trace instrumented.
79};
80
81#pragma pack(pop)
82
83#endif // CIRCT_DIALECT_ARC_RUNTIME_COMMON_H
Static information for a compiled hardware model, generated by the MLIR lowering.
Definition Common.h:70
struct ArcModelTraceInfo * traceInfo
Signal tracing information. NULL iff the model is not trace instrumented.
Definition Common.h:78
uint64_t apiVersion
Runtime API version used when compiling the model.
Definition Common.h:72
uint64_t numStateBytes
Number of bytes required for the model's state.
Definition Common.h:74
const char * modelName
Name of the compiled model.
Definition Common.h:76
Combined runtime and model state for a hardware model instance.
Definition Common.h:44
void * impl
Runtime implementation specific data. Usually points to a custom struct.
Definition Common.h:46
uint8_t modelState[]
Definition Common.h:58
uint32_t magic
Runtime magic number. Must be set to ARC_RUNTIME_MAGIC.
Definition Common.h:54
uint64_t reserved
Padding for alignment and reserved for future use.
Definition Common.h:56
uint64_t * traceBuffer
Pointer to the active trace buffer's storage.
Definition Common.h:50
uint32_t traceBufferSize
Number of valid elements in the active trace buffer.
Definition Common.h:52