llvm_sys/
remarks.rs

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
//! Remark diagnostics library.
use prelude::LLVMBool;

#[repr(C)]
pub enum LLVMRemarkType {
    LLVMRemarkTypeUnknown,
    LLVMRemarkTypePassed,
    LLVMRemarkTypeMissed,
    LLVMRemarkTypeAnalysis,
    LLVMRemarkTypeAnalysisFPCommute,
    LLVMRemarkTypeAnalysisAliasing,
    LLVMRemarkTypeFailure,
}

pub enum LLVMRemarkOpaqueString {}

/// String containing a buffer and a length. The buffer is not guaranteed to be zero-terminated.
pub type LLVMRemarkStringRef = *mut LLVMRemarkOpaqueString;

extern "C" {
    /// Returns the buffer holding the string.
    pub fn LLVMRemarkStringGetData(String: LLVMRemarkStringRef) -> *const ::libc::c_char;

    /// Returns the size of the string.
    pub fn LLVMRemarkStringGetLen(String: LLVMRemarkStringRef) -> u32;
}

pub enum LLVMRemarkOpaqueDebugLoc {}

/// DebugLoc containing File, Line and Column.
pub type LLVMRemarkDebugLocRef = *mut LLVMRemarkOpaqueDebugLoc;

extern "C" {
    /// Return the path to the source file for a debug location.
    pub fn LLVMRemarkDebugLocGetSourceFilePath(DL: LLVMRemarkDebugLocRef) -> LLVMRemarkStringRef;

    /// Return the line in the source file for a debug location.
    pub fn LLVMRemarkDebugLocGetSourceLine(DL: LLVMRemarkDebugLocRef) -> u32;

    /// Return the column in the source file for a debug location.
    pub fn LLVMRemarkDebugLocGetSourceColumn(DL: LLVMRemarkDebugLocRef) -> u32;
}

pub enum LLVMRemarkOpaqueArg {}

/// Element of the "Args" list. The key might give more information about what
/// the semantics of the value are, e.g. "Callee" will tell you that the value
/// is a symbol that names a function.
pub type LLVMRemarkArgRef = *mut LLVMRemarkOpaqueArg;

extern "C" {
    /// Returns the key of an argument. The key defines what the value is, and the
    /// same key can appear multiple times in the list of arguments.
    pub fn LLVMRemarkArgGetKey(Arg: LLVMRemarkArgRef) -> LLVMRemarkStringRef;

    /// Returns the value of an argument. This is a string that can contain newlines.
    pub fn LLVMRemarkArgGetValue(Arg: LLVMRemarkArgRef) -> LLVMRemarkStringRef;

    /// Returns the debug location that is attached to the value of this argument.
    pub fn LLVMRemarkArgGetDebugLoc(Arg: LLVMRemarkArgRef) -> LLVMRemarkDebugLocRef;
}

pub enum LLVMRemarkOpaqueEntry {}
/// A remark emitted by the compiler.
pub type LLVMRemarkEntryRef = *mut LLVMRemarkOpaqueEntry;

extern "C" {
    /// Free the resources used by the remark entry.
    pub fn LLVMRemarkEntryDispose(Remark: LLVMRemarkEntryRef);

    /// The type of the remark. For example, it can allow users to only keep the
    /// missed optimizations from the compiler.
    pub fn LLVMRemarkEntryGetType(Remark: LLVMRemarkEntryRef) -> LLVMRemarkType;

    /// Get the name of the pass that emitted this remark.
    pub fn LLVMRemarkEntryGetPassName(Remark: LLVMRemarkEntryRef) -> LLVMRemarkStringRef;

    /// Get an identifier of the remark.
    pub fn LLVMRemarkEntryGetRemarkName(Remark: LLVMRemarkEntryRef) -> LLVMRemarkStringRef;

    /// Get the name of the function being processed when the remark was emitted.
    pub fn LLVMRemarkEntryGetFunctionName(Remark: LLVMRemarkEntryRef) -> LLVMRemarkStringRef;

    /// Returns the debug location that is attached to this remark.
    pub fn LLVMRemarkEntryGetDebugLoc(Remark: LLVMRemarkEntryRef) -> LLVMRemarkDebugLocRef;

    /// Return the hotness of the remark.
    pub fn LLVMRemarkEntryGetHotness(Remark: LLVMRemarkEntryRef) -> u64;

    /// The number of arguments the remark holds.
    pub fn LLVMRemarkEntryGetNumArgs(Remark: LLVMRemarkEntryRef) -> u32;

    /// Get a new iterator to iterate over a remark's argument.
    pub fn LLVMRemarkEntryGetFirstArg(Remark: LLVMRemarkEntryRef) -> LLVMRemarkArgRef;

    /// Get the next argument in Remark from the position of It.
    pub fn LLVMRemarkEntryGetNextArg(
        It: LLVMRemarkArgRef,
        Remark: LLVMRemarkEntryRef,
    ) -> LLVMRemarkArgRef;
}

pub enum LLVMRemarkOpaqueParser {}
pub type LLVMRemarkParserRef = *mut LLVMRemarkOpaqueParser;

extern "C" {
    /// Creates a remark parser that can be used to parse the buffer located in
    /// Buf of size Size bytes.
    pub fn LLVMRemarkParserCreateYAML(Buf: *const ::libc::c_void, Size: u64)
        -> LLVMRemarkParserRef;

    pub fn LLVMRemarkParserCreateBitstream(
        Buf: *const ::libc::c_void,
        Size: u64,
    ) -> LLVMRemarkParserRef;

    /// Returns the next remark in the file.
    pub fn LLVMRemarkParserGetNext(Parser: LLVMRemarkParserRef) -> LLVMRemarkEntryRef;

    /// Returns `1` if the parser encountered an error while parsing the buffer.
    pub fn LLVMRemarkParserHasError(Parser: LLVMRemarkParserRef) -> LLVMBool;

    /// Returns a null-terminated string containing an error message.
    pub fn LLVMRemarkParserGetErrorMessage(Parser: LLVMRemarkParserRef) -> *const ::libc::c_char;

    pub fn LLVMRemarkParserDispose(Parser: LLVMRemarkParserRef);
}

pub const REMARKS_API_VERSION: u32 = 1;

extern "C" {
    /// Returns the version of the remarks library.
    pub fn LLVMRemarkVersion() -> u32;
}