Tensor Tiling Library
 
Loading...
Searching...
No Matches
TTL_macros.h
Go to the documentation of this file.
1/*
2 * TTL_macros.h
3 *
4 * Copyright (c) 2023 Mobileye
5 *
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/**
20 * @def __TTL_STR_CONCAT1
21 *
22 * Concatenate x and y, must be used within another macro.
23 */
24
25/**
26 * @def __TTL_STR_CONCAT2
27 *
28 * Concatenate x and y, can be used standalone
29 */
30
31/**
32 * @def __TTL_STRINGFY1
33 *
34 * Turn s into a "string", must be used within another macro
35 */
36
37/**
38 * @def __TTL_STRINGFY2
39 *
40 * Turn s into a "string", can be used standalone
41 */
42
43/**
44 * @def TTL_ARRAYSIZE
45 *
46 * @brief Return the number of elements in the array x
47 *
48 * @param x The array to return the size of
49 */
50
51/**
52 * @def NO_PARAMETERS
53 *
54 * Sometimes tools require a void function to be defined as
55 *
56 * Function() not Function(void) - the later is correct but this
57 * macro allows for it to be overridden.
58 */
59/**
60 * @def __TTL_TRACE_FN
61 *
62 * A function defined using __TTL_TRACE_FN will have an additional "unsigned int line" parameter
63 * added if __TTL_DEBUG > 0. This line parameter allows for the output of the line of code originating
64 * the call.
65 *
66 * For example:
67 * static inline TTL_int_sub_tensor_t __TTL_TRACE_FN(TTL_step_buffering, TTL_import_double_buffering_t *const dbi,
68 * const TTL_tile_t next_tile);
69 *
70 * Will produce
71 * static inline TTL_int_sub_tensor_t TTL_step_buffering(TTL_import_double_buffering_t *const dbi,
72 * const TTL_tile_t next_tile);
73 * when __TTL_DEBUG == 0
74 * static inline TTL_int_sub_tensor_t TTL_step_buffering(TTL_import_double_buffering_t *const dbi,
75 * const TTL_tile_t next_tile, unsinged int line);
76 * when __TTL_DEBUG > 0
77 */
78
79/**
80 * @def __TTL_TRACE_LINE
81 *
82 * Is used internally to TLL to append the __LINE__ to function calls when __TTL_DEBUG > 0
83 *
84 * TTL_step_buffering(dbi, next_tile __TTL_TRACE_LINE);
85 *
86 * The file TTL_trace_macros deals with this for calls post TTL.h
87 */
88
89/************************************************************************************************************
90 * Generic name generator
91 ***********************************************************************************************************/
92/**
93 * @def __TTL_tensor_name
94 *
95 * @brief Generate a generic "[prefix][const]_[ext, int]_[type]_[sub]_tensor[suffix]" style name from the elements
96 *
97 * @param prefix The prefixed to apply to the name
98 * @param const_2 The const name to place after the prefix - should be empty or const_
99 * @param location The location of the tensor - should be ext or int
100 * @param type The type of the tensor - should be any valid c type
101 * @param sub If the tensor is a sub tensor or not - should be empty or sub_
102 * @param suffix The suffix of to apply to the name
103 *
104 * @details
105 * __TTL_tensor_name(TTL_create, const_, ext, char, sub_, ) will give TTL_create_const_ext_char_sub_tensor
106 * __TTL_tensor_name(TTL_, ,int, void, , _t) will give TTL_int_void_tensor_t
107 *
108 * The 'double' call is some 'magic' to allow the caller itself to contain a macro.
109 *
110 * @return The generated name
111 */
112/**
113 * @def __TTL_tensor_no_type_name
114 *
115 * @brief Generate a generic "[prefix][const]_[ext, int]_[sub]_tensor[suffix]" style name from the elements
116 *
117 * @param prefix The prefixed to apply to the name
118 * @param const_2 The const name to place after the prefix - should be empty or const_
119 * @param location The location of the tensor - should be ext or int
120 * @param sub If the tensor is a sub tensor or not - should be empty or sub_
121 * @param suffix The suffix of to apply to the name
122 *
123 * @details
124 * __TTL_tensor_no_type_name(TTL_create, const_, ext, sub_, ) will give TTL_create_const_ext_sub_tensor
125 * __TTL_tensor_no_type_name(TTL_, ,int, , _t) will give TTL_int_tensor_t
126 *
127 * The 'double' call is some 'magic' to allow the caller itself to contain a macro.
128 *
129 * @return The generated name
130 */