forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathamd_comgr.h.in
More file actions
2851 lines (2714 loc) · 98.5 KB
/
Copy pathamd_comgr.h.in
File metadata and controls
2851 lines (2714 loc) · 98.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//===- amd_comgr.h.in - User-facing APIs ----------------------------------===//
//
// Part of Comgr, under the Apache License v2.0 with LLVM Exceptions. See
// amd/comgr/LICENSE.TXT in this repository for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file defines the user-facing Comgr APIs, including compilation,
/// metadata, and disassembly, symbol lookup, and symbolization APIs.
///
/// It is copied into amd_comgr.h by CMake during the Comgr build.
///
//===----------------------------------------------------------------------===//
#ifndef AMD_COMGR_H_
#define AMD_COMGR_H_
#include <stddef.h> /* size_t */
#include <stdint.h>
#ifndef __cplusplus
#include <stdbool.h> /* bool */
#endif /* __cplusplus */
/* Placeholder for calling convention and import/export macros */
#ifndef AMD_COMGR_CALL
#define AMD_COMGR_CALL
#endif
// Add deprecation support for Comgr on Linux
// This can be removed in favor of generic [[deprecated]] in C23, which should
// also allow us to more easily include support on Windows
#ifndef AMD_COMGR_DEPRECATED
#ifdef AMD_COMGR_BUILD
#define AMD_COMGR_DEPRECATED(msg) // empty
#endif
#endif
#ifndef AMD_COMGR_DEPRECATED
#if defined __GNUC__ && (__GNUC__ > 5 || defined __clang__)
#define AMD_COMGR_DEPRECATED(msg) __attribute__((deprecated(msg)))
#else // Windows systems, and GCC older than 6.0
#define AMD_COMGR_DEPRECATED(msg) // empty
#endif
#endif
#ifndef AMD_COMGR_EXPORT_DECORATOR
#ifdef __GNUC__
#define AMD_COMGR_EXPORT_DECORATOR __attribute__ ((visibility ("default")))
#else
#define AMD_COMGR_EXPORT_DECORATOR __declspec(dllexport)
#endif
#endif
#ifndef AMD_COMGR_IMPORT_DECORATOR
#ifdef __GNUC__
#define AMD_COMGR_IMPORT_DECORATOR
#else
#define AMD_COMGR_IMPORT_DECORATOR __declspec(dllimport)
#endif
#endif
#define AMD_COMGR_API_EXPORT AMD_COMGR_EXPORT_DECORATOR AMD_COMGR_CALL
#define AMD_COMGR_API_IMPORT AMD_COMGR_IMPORT_DECORATOR AMD_COMGR_CALL
#ifndef AMD_COMGR_API
#ifdef AMD_COMGR_EXPORT
#define AMD_COMGR_API AMD_COMGR_API_EXPORT
#else
#define AMD_COMGR_API AMD_COMGR_API_IMPORT
#endif
#endif
#define AMD_COMGR_INTERFACE_VERSION_MAJOR @amd_comgr_VERSION_MAJOR@
#define AMD_COMGR_INTERFACE_VERSION_MINOR @amd_comgr_VERSION_MINOR@
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** \defgroup codeobjectmanager Code Object Manager
* @{
*
* @brief The code object manager is a callable library that provides
* operations for creating and inspecting code objects.
*
* The library provides handles to various objects. Concurrent execution of
* operations is supported provided all objects accessed by each concurrent
* operation are disjoint. For example, the @p amd_comgr_data_set_t handles
* passed to operations must be disjoint, together with all the @p
* amd_comgr_data_t handles that have been added to it. The exception is that
* the default device library data object handles can be non-disjoint as they
* are immutable.
*
* The library supports generating and inspecting code objects that
* contain machine code for a certain set of instruction set
* arhitectures (isa). The set of isa supported and information about
* the properties of the isa can be queried.
*
* The library supports performing an action that can take data
* objects of one kind, and generate new data objects of another kind.
*
* Data objects are referenced using handles using @p
* amd_comgr_data_t. The kinds of data objects are given
* by @p amd_comgr_data_kind_t.
*
* To perform an action, two @p amd_comgr_data_set_t
* objects are created. One is used to hold all the data objects
* needed by an action, and other is updated by the action with all
* the result data objects. In addition, an @p
* amd_comgr_action_info_t is created to hold
* information that controls the action. These are then passed to @p
* amd_comgr_do_action to perform an action specified by
* @p amd_comgr_action_kind_t.
*
* Data objects are reference counted and are destroyed when the
* reference count reaches 0. When a data object is created, its
* reference count is 1, it has 0 bytes of data, it has an empty name,
* and it has no metadata.
*
* Mutating a data object is only permitted before it is used as part of
* the input to an action. A data object which is the result of an action
* must not be mutated.
*
* Some data objects can have associated metadata. There are
* operations for querying this metadata.
*
* The default device library that satisfies the requirements of the
* compiler action can be obtained.
*
* The library inspects some environment variables to aid in debugging. These
* include:
* - @p AMD_COMGR_SAVE_TEMPS: If this is set, and is not "0", the library does
* not delete temporary files generated while executing compilation actions.
* These files do not appear in the current working directory, but are
* instead left in a platform-specific temporary directory (/tmp on Linux and
* C:\Temp or the path found in the TEMP environment variable on Windows).
* - @p AMD_COMGR_SAVE_LLVM_TEMPS: If this is set, and is not "0", Comgr
* forwards "--save-temps=obj" to Clang Driver invocations
* - @p AMD_COMGR_REDIRECT_LOGS: If this is not set, or is set to "0", logs are
* returned to the caller as normal. If this is set to "stdout"/"-" or
* "stderr", logs are additionally copied to the standard output or error
* stream, respectively. If this is set to any other value, it is interpreted
* as a filename which logs are appended to. In all cases logs are still
* returned to the caller; this variable copies them, it does not move them.
* Logs may be redirected irrespective of whether logging is enabled.
* - @p AMD_COMGR_EMIT_VERBOSE_LOGS: If this is set, and is not "0", logs will
* include additional Comgr-specific informational messages. Equivalent to
* AMD_COMGR_LOG_LEVEL=debug, unless AMD_COMGR_LOG_LEVEL is set, which takes
* precedence.
* - @p AMD_COMGR_LOG_LEVEL: Sets the severity threshold of the Comgr logger.
* Values from least to most verbose: "none", "error", "warning", "info",
* "debug" (case-insensitive). A level enables that severity and all more
* severe ones. Takes precedence over AMD_COMGR_EMIT_VERBOSE_LOGS; if unset,
* defaults to "debug" when AMD_COMGR_EMIT_VERBOSE_LOGS is enabled, else
* "error".
*/
/** \defgroup symbol_versions_group Symbol Versions
*
* The names used for the shared library versioned symbols.
*
* Every function is annotated with one of the version macros defined in this
* section. Each macro specifies a corresponding symbol version string. After
* dynamically loading the shared library with \p dlopen, the address of each
* function can be obtained using \p dlvsym with the name of the function and
* its corresponding symbol version string. An error will be reported by \p
* dlvsym if the installed library does not support the version for the
* function specified in this version of the interface.
*
* @{
*/
/**
* The function was introduced in version 1.8 of the interface and has the
* symbol version string of ``"@amd_comgr_NAME@_1.8"``.
*/
#define AMD_COMGR_VERSION_1_8
/**
* The function was introduced or changed in version 2.0 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.0"``.
*/
#define AMD_COMGR_VERSION_2_0
/**
* The function was introduced or changed in version 2.2 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.2"``.
*/
#define AMD_COMGR_VERSION_2_2
/**
* The function was introduced or changed in version 2.3 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.3"``.
*/
#define AMD_COMGR_VERSION_2_3
/**
* The function was introduced or changed in version 2.4 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.4"``.
*/
#define AMD_COMGR_VERSION_2_4
/**
* The function was introduced or changed in version 2.5 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.5"``.
*/
#define AMD_COMGR_VERSION_2_5
/**
* The function was introduced or changed in version 2.6 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.6"``.
*/
#define AMD_COMGR_VERSION_2_6
/**
* The function was introduced or changed in version 2.7 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.7"``.
*/
#define AMD_COMGR_VERSION_2_7
/**
* The function was introduced or changed in version 2.8 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.8"``.
*/
#define AMD_COMGR_VERSION_2_8
/**
* The function was introduced or changed in version 2.9 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_2.9"``.
*/
#define AMD_COMGR_VERSION_2_9
/**
* The function was introduced or changed in version 3.0 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_3.0"``.
*/
#define AMD_COMGR_VERSION_3_0
/**
* The function was introduced or changed in version 3.1 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_3.1"``.
*/
#define AMD_COMGR_VERSION_3_1
/**
* The function was introduced or changed in version 3.2 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_3.2"``.
*/
#define AMD_COMGR_VERSION_3_2
/**
* The function was introduced or changed in version 3.3 of the interface
* and has the symbol version string of ``"@amd_comgr_NAME@_3.3"``.
*/
#define AMD_COMGR_VERSION_3_3
/** @} */
/**
* @brief Status codes.
*/
typedef enum amd_comgr_status_s {
/**
* The function has been executed successfully.
*/
AMD_COMGR_STATUS_SUCCESS = 0x0,
/**
* A generic error has occurred.
*/
AMD_COMGR_STATUS_ERROR = 0x1,
/**
* One of the actual arguments does not meet a precondition stated
* in the documentation of the corresponding formal argument. This
* includes both invalid Action types, and invalid arguments to
* valid Action types.
*/
AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT = 0x2,
/**
* Failed to allocate the necessary resources.
*/
AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES = 0x3,
} amd_comgr_status_t;
/**
* @brief The source languages supported by the compiler.
*/
typedef enum amd_comgr_language_s {
/**
* No high level language.
*/
AMD_COMGR_LANGUAGE_NONE = 0x0,
/**
* OpenCL 1.2.
*/
AMD_COMGR_LANGUAGE_OPENCL_1_2 = 0x1,
/**
* OpenCL 2.0.
*/
AMD_COMGR_LANGUAGE_OPENCL_2_0 = 0x2,
/**
* HIP.
*/
AMD_COMGR_LANGUAGE_HIP = 0x3,
/**
* LLVM IR, either textual (.ll) or bitcode (.bc) format.
*/
AMD_COMGR_LANGUAGE_LLVM_IR = 0x4,
/**
* Marker for last valid language.
*/
AMD_COMGR_LANGUAGE_LAST = AMD_COMGR_LANGUAGE_LLVM_IR
} amd_comgr_language_t;
/**
* @brief Query additional information about a status code.
*
* @param[in] status Status code.
*
* @param[out] status_string A NUL-terminated string that describes
* the error status.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* status is an invalid status code, or @p status_string is NULL.
*/
amd_comgr_status_t AMD_COMGR_API amd_comgr_status_string(
amd_comgr_status_t status,
const char ** status_string) AMD_COMGR_VERSION_1_8;
/**
* @brief Get the version of the code object manager interface
* supported.
*
* An interface is backwards compatible with an implementation with an
* equal major version, and a greater than or equal minor version.
*
* @param[out] major Major version number.
*
* @param[out] minor Minor version number.
*/
void AMD_COMGR_API amd_comgr_get_version(
size_t *major,
size_t *minor) AMD_COMGR_VERSION_1_8;
/**
* @brief The kinds of data supported.
*/
typedef enum amd_comgr_data_kind_s {
/**
* No data is available.
*/
AMD_COMGR_DATA_KIND_UNDEF = 0x0,
/**
* The data is a textual main source.
*/
AMD_COMGR_DATA_KIND_SOURCE = 0x1,
/**
* The data is a textual source that is included in the main source
* or other include source.
*/
AMD_COMGR_DATA_KIND_INCLUDE = 0x2,
/**
* The data is a precompiled-header source that is included in the main
* source or other include source.
*/
AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER = 0x3,
/**
* The data is a diagnostic output.
*/
AMD_COMGR_DATA_KIND_DIAGNOSTIC = 0x4,
/**
* The data is a textual log output.
*/
AMD_COMGR_DATA_KIND_LOG = 0x5,
/**
* The data is compiler LLVM IR bit code for a specific isa.
*/
AMD_COMGR_DATA_KIND_BC = 0x6,
/**
* The data is a relocatable machine code object for a specific isa.
*/
AMD_COMGR_DATA_KIND_RELOCATABLE = 0x7,
/**
* The data is an executable machine code object for a specific
* isa. An executable is the kind of code object that can be loaded
* and executed.
*/
AMD_COMGR_DATA_KIND_EXECUTABLE = 0x8,
/**
* The data is a block of bytes.
*/
AMD_COMGR_DATA_KIND_BYTES = 0x9,
/**
* The data is a fat binary (clang-offload-bundler output).
*/
AMD_COMGR_DATA_KIND_FATBIN = 0x10,
/**
* The data is an archive.
*/
AMD_COMGR_DATA_KIND_AR = 0x11,
/**
* The data is a bitcode bundle.
*/
AMD_COMGR_DATA_KIND_BC_BUNDLE = 0x12,
/**
* The data is an archive bundle.
*/
AMD_COMGR_DATA_KIND_AR_BUNDLE = 0x13,
/**
* The data is an object file bundle.
*/
AMD_COMGR_DATA_KIND_OBJ_BUNDLE = 0x14,
/**
* The data is SPIR-V IR
*/
AMD_COMGR_DATA_KIND_SPIRV = 0x15,
/**
* Marker for last valid data kind.
*/
AMD_COMGR_DATA_KIND_LAST = AMD_COMGR_DATA_KIND_SPIRV
} amd_comgr_data_kind_t;
/**
* @brief A handle to a data object.
*
* Data objects are used to hold the data which is either an input or
* output of a code object manager action.
*/
typedef struct amd_comgr_data_s {
uint64_t handle;
} amd_comgr_data_t;
/**
* @brief A handle to an action data object.
*
* An action data object holds a set of data objects. These can be
* used as inputs to an action, or produced as the result of an
* action.
*/
typedef struct amd_comgr_data_set_s {
uint64_t handle;
} amd_comgr_data_set_t;
/**
* @brief A handle to an action information object.
*
* An action information object holds all the necessary information,
* excluding the input data objects, required to perform an action.
*/
typedef struct amd_comgr_action_info_s {
uint64_t handle;
} amd_comgr_action_info_t;
/**
* @brief A handle to a metadata node.
*
* A metadata node handle is used to traverse the metadata associated
* with a data node.
*/
typedef struct amd_comgr_metadata_node_s {
uint64_t handle;
} amd_comgr_metadata_node_t;
/**
* @brief A handle to a machine code object symbol.
*
* A symbol handle is used to obtain the properties of symbols of a machine code
* object. A symbol handle is invalidated when the data object containing the
* symbol is destroyed.
*/
typedef struct amd_comgr_symbol_s {
uint64_t handle;
} amd_comgr_symbol_t;
/**
* @brief A handle to a disassembly information object.
*
* A disassembly information object holds all the necessary information,
* excluding the input data, required to perform disassembly.
*/
typedef struct amd_comgr_disassembly_info_s {
uint64_t handle;
} amd_comgr_disassembly_info_t;
/**
* @brief A handle to a symbolizer information object.
*
* A symbolizer information object holds all the necessary information
* required to perform symbolization.
*/
typedef struct amd_comgr_symbolizer_info_s {
uint64_t handle;
} amd_comgr_symbolizer_info_t;
/**
* @brief Return the number of isa names supported by this version of
* the code object manager library.
*
* The isa name specifies the instruction set architecture that should
* be used in the actions that involve machine code generation or
* inspection.
*
* @param[out] count The number of isa names supported.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* count is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update action info object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_isa_count(
size_t *count) AMD_COMGR_VERSION_2_0;
/**
* @brief Return the Nth isa name supported by this version of the
* code object manager library.
*
* @param[in] index The index of the isa name to be returned. The
* first isa name is index 0.
*
* @param[out] isa_name A null terminated string that is the isa name
* being requested.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* index is greater than the number of isa name supported by this
* version of the code object manager library. @p isa_name is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update action info object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_isa_name(
size_t index,
const char **isa_name) AMD_COMGR_VERSION_2_0;
/**
* @brief Get a handle to the metadata of an isa name.
*
* The structure of the returned metadata is isa name specific and versioned
* with details specified in
* https://llvm.org/docs/AMDGPUUsage.html#code-object-metadata.
* It can include information about the
* limits for resources such as registers and memory addressing.
*
* @param[in] isa_name The isa name to query.
*
* @param[out] metadata A handle to the metadata of the isa name. If
* the isa name has no metadata then the returned handle has a kind of
* @p AMD_COMGR_METADATA_KIND_NULL. The handle must be destroyed
* using @c amd_comgr_destroy_metadata.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* name is NULL or is not an isa name supported by this version of the
* code object manager library. @p metadata is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_isa_metadata(
const char *isa_name,
amd_comgr_metadata_node_t *metadata) AMD_COMGR_VERSION_2_0;
/**
* @brief Create a data object that can hold data of a specified kind.
*
* @param[in] kind The kind of data the object is intended to hold.
*
* @param[out] data A handle to the data object created. Its reference
* count is set to 1.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* kind is an invalid data kind, or @p
* AMD_COMGR_DATA_KIND_UNDEF. @p data is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to create the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_create_data(
amd_comgr_data_kind_t kind,
amd_comgr_data_t *data) AMD_COMGR_VERSION_1_8;
/**
* @brief Indicate that no longer using a data object handle.
*
* The reference count of the associated data object is
* decremented. If it reaches 0 it is destroyed.
*
* @note Although this may lead to the destruction of a data object, it is not
* considered a mutation for the purposes of the restrictions described in @ref
* codeobjectmanager.
*
* @param[in] data The data object to release.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, or has kind @p
* AMD_COMGR_DATA_KIND_UNDEF.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_release_data(
amd_comgr_data_t data) AMD_COMGR_VERSION_1_8;
/**
* @brief Get the kind of the data object.
*
* @param[in] data The data object to query.
*
* @param[out] kind The kind of data the object.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object. @p kind is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to create the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_data_kind(
amd_comgr_data_t data,
amd_comgr_data_kind_t *kind) AMD_COMGR_VERSION_1_8;
/**
* @brief Set the data content of a data object to the specified
* bytes.
*
* Any previous value of the data object is overwritten. Any metadata
* associated with the data object is also replaced which invalidates
* all metadata handles to the old metadata.
*
* @warning This function mutates the data object; see @ref codeobjectmanager
* for restrictions.
*
* @param[in] data The data object to update.
*
* @param[in] size The number of bytes in the data specified by @p bytes.
*
* @param[in] bytes The bytes to set the data object to. The bytes are
* copied into the data object and can be freed after the call.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, or has kind @p
* AMD_COMGR_DATA_KIND_UNDEF.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_set_data(
amd_comgr_data_t data,
size_t size,
const char* bytes) AMD_COMGR_VERSION_1_8;
/**
* @brief For the given open posix file descriptor, map a slice of the
* file into the data object. The slice is specified by @p offset and @p size.
* Internally this API calls amd_comgr_set_data and resets data object's
* current state.
*
* @warning This function mutates the data object; see @ref codeobjectmanager
* for restrictions.
*
* @param[in, out] data The data object to update.
*
* @param[in] file_descriptor The native file descriptor for an open file.
* The @p file_descriptor must not be passed into a system I/O function
* by any other thread while this function is executing. The offset in
* the file descriptor may be updated based on the requested size and
* underlying platform. The @p file_descriptor may be closed immediately
* after this function returns.
*
* @param[in] offset position relative to the start of the file
* specifying the beginning of the slice in @p file_descriptor.
*
* @param[in] size Size in bytes of the slice.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The operation is successful.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is an invalid or
* the map operation failed.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_set_data_from_file_slice(
amd_comgr_data_t data,
int file_descriptor,
uint64_t offset,
uint64_t size) AMD_COMGR_VERSION_2_3;
/**
* @brief Set the name associated with a data object.
*
* When compiling, the full name of an include directive is used to
* reference the contents of the include data object with the same
* name. The name may also be used for other data objects in log and
* diagnostic output.
*
* @warning This function mutates the data object; see @ref codeobjectmanager
* for restrictions.
*
* @param[in] data The data object to update.
*
* @param[in] name A null terminated string that specifies the name to
* use for the data object. If NULL then the name is set to the empty
* string.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, or has kind @p
* AMD_COMGR_DATA_KIND_UNDEF.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_set_data_name(
amd_comgr_data_t data,
const char* name) AMD_COMGR_VERSION_1_8;
/**
* @brief Get the data contents, and/or the size of the data
* associated with a data object.
*
* @param[in] data The data object to query.
*
* @param[in, out] size On entry, the size of @p bytes. On return, if @p bytes
* is NULL, set to the size of the data object contents.
*
* @param[out] bytes If not NULL, then the first @p size bytes of the
* data object contents is copied. If NULL, no data is copied, and
* only @p size is updated (useful in order to find the size of buffer
* required to copy the data).
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, or has kind @p
* AMD_COMGR_DATA_KIND_UNDEF. @p size is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_data(
amd_comgr_data_t data,
size_t *size,
char *bytes) AMD_COMGR_VERSION_1_8;
/**
* @brief Get the data object name and/or name length.
*
* @param[in] data The data object to query.
*
* @param[in, out] size On entry, the size of @p name. On return, the size of
* the data object name including the terminating null character.
*
* @param[out] name If not NULL, then the first @p size characters of the
* data object name are copied. If @p name is NULL, only @p size is updated
* (useful in order to find the size of buffer required to copy the name).
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, or has kind @p
* AMD_COMGR_DATA_KIND_UNDEF. @p size is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_data_name(
amd_comgr_data_t data,
size_t *size,
char *name) AMD_COMGR_VERSION_1_8;
/**
* @brief Get the data object isa name and/or isa name length.
*
* @param[in] data The data object to query.
*
* @param[in, out] size On entry, the size of @p isa_name. On return, if @p
* isa_name is NULL, set to the size of the isa name including the terminating
* null character.
*
* @param[out] isa_name If not NULL, then the first @p size characters
* of the isa name are copied. If NULL, no isa name is copied, and
* only @p size is updated (useful in order to find the size of buffer
* required to copy the isa name).
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, has kind @p
* AMD_COMGR_DATA_KIND_UNDEF, or is not an isa specific
* kind. @p size is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_data_isa_name(
amd_comgr_data_t data,
size_t *size,
char *isa_name) AMD_COMGR_VERSION_2_0;
/**
* @brief Create a symbolizer info object.
*
* @param[in] code_object A data object denoting a code object for which
* symbolization should be performed. The kind of this object must be
* ::AMD_COMGR_DATA_KIND_RELOCATABLE, ::AMD_COMGR_DATA_KIND_EXECUTABLE,
* or ::AMD_COMGR_DATA_KIND_BYTES.
*
* @param[in] print_symbol_callback Function called by a successfull
* symbolize query. @p symbol is a null-terminated string containing the
* symbolization of the address and @p user_data is an arbitary user data.
* The callback does not own @p symbol, and it cannot be referenced once
* the callback returns.
*
* @param[out] symbolizer_info A handle to the symbolizer info object created.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
* successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if @p code_object is
* invalid or @p print_symbol_callback is null.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to create @p symbolizer_info as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_create_symbolizer_info(
amd_comgr_data_t code_object,
void (*print_symbol_callback)(
const char *symbol,
void *user_data),
amd_comgr_symbolizer_info_t *symbolizer_info) AMD_COMGR_VERSION_2_4;
/**
* @brief Destroy symbolizer info object.
*
* @param[in] symbolizer_info A handle to symbolizer info object to destroy.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS on successful execution.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if @p
* symbolizer_info is invalid.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_destroy_symbolizer_info(
amd_comgr_symbolizer_info_t symbolizer_info) AMD_COMGR_VERSION_2_4;
/**
* @brief Symbolize an address.
*
* The @p address is symbolized using the symbol definitions of the
* @p code_object specified when the @p symbolizer_info was created.
* The @p print_symbol_callback callback function specified when the
* @p symbolizer_info was created is called passing the
* symbolization result as @p symbol and @p user_data value.
*
* If symbolization is not possible ::AMD_COMGR_STATUS_SUCCESS is returned and
* the string passed to the @p symbol argument of the @p print_symbol_callback
* specified when the @p symbolizer_info was created contains the text
* "<invalid>" or "??". This is consistent with `llvm-symbolizer` utility.
*
* @param[in] symbolizer_info A handle to symbolizer info object which should be
* used to symbolize the @p address.
*
* @param[in] address An unrelocated ELF address to which symbolization
* query should be performed.
*
* @param[in] is_code if true, the symbolizer symbolize the address as code
* and the symbolization result contains filename, function name, line number
* and column number, else the symbolizer symbolize the address as data and
* the symbolizaion result contains symbol name, symbol's starting address
* and symbol size.
*
* @param[in] user_data Arbitrary user-data passed to @p print_symbol_callback
* callback as described for @p symbolizer_info argument.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* symbolizer_info is an invalid data object.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_symbolize(
amd_comgr_symbolizer_info_t symbolizer_info,
uint64_t address,
bool is_code,
void *user_data) AMD_COMGR_VERSION_2_4;
/**
* @brief Get a handle to the metadata of a data object.
*
* @param[in] data The data object to query.
*
* @param[out] metadata A handle to the metadata of the data
* object. If the data object has no metadata then the returned handle
* has a kind of @p AMD_COMGR_METADATA_KIND_NULL. The
* handle must be destroyed using @c amd_comgr_destroy_metadata.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has
* been executed successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
* data is an invalid data object, or has kind @p
* AMD_COMGR_DATA_KIND_UNDEF. @p metadata is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
* Unable to update the data object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_get_data_metadata(
amd_comgr_data_t data,
amd_comgr_metadata_node_t *metadata) AMD_COMGR_VERSION_1_8;
/**
* @brief Destroy a metadata handle.
*
* @param[in] metadata A metadata handle to destroy.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
* successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p metadata is an invalid
* metadata handle.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update metadata
* handle as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_destroy_metadata(amd_comgr_metadata_node_t metadata) AMD_COMGR_VERSION_1_8;
/**
* @brief Create a data set object.
*
* @param[out] data_set A handle to the data set created. Initially it
* contains no data objects.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
* successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is NULL.
*
* @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to create the data
* set object as out of resources.
*/
amd_comgr_status_t AMD_COMGR_API
amd_comgr_create_data_set(
amd_comgr_data_set_t *data_set) AMD_COMGR_VERSION_1_8;
/**
* @brief Destroy a data set object.
*
* The reference counts of any associated data objects are decremented. Any
* handles to the data set object become invalid.
*
* @param[in] data_set A handle to the data set object to destroy.
*
* @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
* successfully.
*
* @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is an invalid