Skip to main content

xlsynth_sys/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Declarations for the C API for the XLS dynamic shared object.
4
5#![cfg_attr(xlsynth_runtime_runpath, feature(link_arg_attribute))]
6
7#[cfg(xlsynth_runtime_runpath)]
8include!(concat!(env!("OUT_DIR"), "/xlsynth_runtime_link_arg.rs"));
9
10extern crate libc;
11
12#[repr(C)]
13pub struct CIrValue {
14    _private: [u8; 0], // Ensures the struct cannot be instantiated
15}
16
17#[repr(C)]
18pub struct CIrBits {
19    _private: [u8; 0], // Ensures the struct cannot be instantiated
20}
21
22#[repr(C)]
23pub struct CBitsRope {
24    _private: [u8; 0], // Ensures the struct cannot be instantiated
25}
26
27#[repr(C)]
28pub struct CIrPackage {
29    _private: [u8; 0], // Ensures the struct cannot be instantiated
30}
31
32#[repr(C)]
33pub struct CIrFunction {
34    _private: [u8; 0], // Ensures the struct cannot be instantiated
35}
36
37#[repr(C)]
38pub struct CIrFunctionBase {
39    _private: [u8; 0], // Ensures the struct cannot be instantiated
40}
41
42#[repr(C)]
43pub struct CIrFunctionJit {
44    _private: [u8; 0], // Ensures the struct cannot be instantiated
45}
46
47/// Opaque context for the libxls AOT C API.
48///
49/// The bindings are retained so `xlsynth-sys` covers libxls APIs that are not
50/// implemented natively in Rust. The high-level xlsynth AOT API uses the
51/// PIR/Cranelift compiler.
52#[repr(C)]
53pub struct CXlsAotExecContext {
54    _private: [u8; 0], // Ensures the struct cannot be instantiated
55}
56
57#[repr(C)]
58pub struct CTraceMessage {
59    pub message: *mut std::os::raw::c_char,
60    pub verbosity: i64,
61}
62
63#[repr(C)]
64pub struct CIrType {
65    _private: [u8; 0], // Ensures the struct cannot be instantiated
66}
67
68#[repr(C)]
69pub struct CIrFunctionType {
70    _private: [u8; 0], // Ensures the struct cannot be instantiated
71}
72
73// Protected C API for IR analysis.
74#[repr(C)]
75pub struct CIrAnalysis {
76    _private: [u8; 0], // Ensures the struct cannot be instantiated
77}
78
79#[repr(C)]
80pub struct CIrIntervalSet {
81    _private: [u8; 0], // Ensures the struct cannot be instantiated
82}
83
84// Selects how much work is done to compute ranges.
85pub type XlsIrAnalysisLevel = i32;
86pub const XLS_IR_ANALYSIS_LEVEL_FAST: XlsIrAnalysisLevel = 0;
87pub const XLS_IR_ANALYSIS_LEVEL_RANGE_WITH_CONTEXT: XlsIrAnalysisLevel = 1;
88
89// Options for creating an IR analysis handle.
90#[repr(C)]
91pub struct XlsIrAnalysisOptions {
92    pub level: XlsIrAnalysisLevel,
93}
94
95// -- DSLX
96
97#[repr(C)]
98pub struct CDslxImportData {
99    _private: [u8; 0], // Ensures the struct cannot be instantiated
100}
101
102#[repr(C)]
103pub struct CDslxTypecheckedModule {
104    _private: [u8; 0], // Ensures the struct cannot be instantiated
105}
106
107#[repr(C)]
108pub struct CDslxModule {
109    _private: [u8; 0], // Ensures the struct cannot be instantiated
110}
111
112#[repr(C)]
113pub struct CDslxTypeInfo {
114    _private: [u8; 0], // Ensures the struct cannot be instantiated
115}
116
117#[repr(C)]
118pub struct CDslxStructDef {
119    _private: [u8; 0], // Ensures the struct cannot be instantiated
120}
121
122#[repr(C)]
123pub struct CDslxEnumDef {
124    _private: [u8; 0], // Ensures the struct cannot be instantiated
125}
126
127#[repr(C)]
128pub struct CDslxSumDef {
129    _private: [u8; 0], // Ensures the struct cannot be instantiated
130}
131
132#[repr(C)]
133pub struct CDslxTypeAlias {
134    _private: [u8; 0], // Ensures the struct cannot be instantiated
135}
136
137#[repr(C)]
138pub struct CDslxType {
139    _private: [u8; 0], // Ensures the struct cannot be instantiated
140}
141
142#[repr(C)]
143pub struct CDslxTypeDim {
144    _private: [u8; 0], // Ensures the struct cannot be instantiated
145}
146
147#[repr(C)]
148pub struct CDslxExpr {
149    _private: [u8; 0], // Ensures the struct cannot be instantiated
150}
151
152#[repr(C)]
153pub struct CDslxInterpValue {
154    _private: [u8; 0], // Ensures the struct cannot be instantiated
155}
156
157#[repr(C)]
158pub struct CDslxParametricEnv {
159    _private: [u8; 0], // Ensures the struct cannot be instantiated
160}
161
162#[repr(C)]
163pub struct CDslxEnumMember {
164    _private: [u8; 0], // Ensures the struct cannot be instantiated
165}
166
167#[repr(C)]
168pub struct CDslxStructMember {
169    _private: [u8; 0], // Ensures the struct cannot be instantiated
170}
171
172#[repr(C)]
173pub struct CDslxTypeAnnotation {
174    _private: [u8; 0], // Ensures the struct cannot be instantiated
175}
176
177#[repr(C)]
178pub struct CDslxArrayTypeAnnotation {
179    _private: [u8; 0], // Ensures the struct cannot be instantiated
180}
181
182#[repr(C)]
183pub struct CDslxTypeRefTypeAnnotation {
184    _private: [u8; 0], // Ensures the struct cannot be instantiated
185}
186
187#[repr(C)]
188pub struct CDslxTypeRef {
189    _private: [u8; 0], // Ensures the struct cannot be instantiated
190}
191
192#[repr(C)]
193pub struct CDslxImport {
194    _private: [u8; 0], // Ensures the struct cannot be instantiated
195}
196
197#[repr(C)]
198pub struct CDslxColonRef {
199    _private: [u8; 0], // Ensures the struct cannot be instantiated
200}
201
202#[repr(C)]
203pub struct CDslxTypeDefinition {
204    _private: [u8; 0], // Ensures the struct cannot be instantiated
205}
206
207#[repr(C)]
208pub struct CDslxConstantDef {
209    _private: [u8; 0], // Ensures the struct cannot be instantiated
210}
211
212#[repr(C)]
213pub struct CDslxModuleMember {
214    _private: [u8; 0], // Ensures the struct cannot be instantiated
215}
216
217#[repr(C)]
218pub struct CDslxFunction {
219    _private: [u8; 0], // Ensures the struct cannot be instantiated
220}
221
222#[repr(C)]
223pub struct CDslxParam {
224    _private: [u8; 0], // Ensures the struct cannot be instantiated
225}
226
227#[repr(C)]
228pub struct CDslxAttribute {
229    _private: [u8; 0], // Ensures the struct cannot be instantiated
230}
231
232#[repr(C)]
233pub struct CDslxParametricBinding {
234    _private: [u8; 0], // Ensures the struct cannot be instantiated
235}
236
237#[repr(C)]
238pub struct CDslxCallGraph {
239    _private: [u8; 0], // Ensures the struct cannot be instantiated
240}
241
242#[repr(C)]
243pub struct CDslxQuickcheck {
244    _private: [u8; 0], // Ensures the struct cannot be instantiated
245}
246
247#[repr(C)]
248pub struct CDslxInvocationCalleeDataArray {
249    _private: [u8; 0],
250}
251
252#[repr(C)]
253pub struct CDslxInvocationCalleeData {
254    _private: [u8; 0],
255}
256
257#[repr(C)]
258pub struct CDslxInvocationData {
259    _private: [u8; 0],
260}
261
262#[repr(C)]
263pub struct CDslxInvocation {
264    _private: [u8; 0],
265}
266
267#[repr(C)]
268pub struct CScheduleAndCodegenResult {
269    _private: [u8; 0], // Ensures the struct cannot be instantiated
270}
271
272pub type XlsFormatPreference = i32;
273pub type XlsValueKind = i32;
274
275// Calling convention used for DSLX mangling APIs.
276pub type XlsCallingConvention = i32;
277
278pub type DslxTypeDefinitionKind = i32;
279
280pub type DslxModuleMemberKind = i32;
281
282pub type DslxAttributeKind = i32;
283
284pub const XLS_DSLX_ATTRIBUTE_KIND_CFG: DslxAttributeKind = 0;
285pub const XLS_DSLX_ATTRIBUTE_KIND_DSLX_FORMAT_DISABLE: DslxAttributeKind = 1;
286pub const XLS_DSLX_ATTRIBUTE_KIND_EXTERN_VERILOG: DslxAttributeKind = 2;
287pub const XLS_DSLX_ATTRIBUTE_KIND_SV_TYPE: DslxAttributeKind = 3;
288pub const XLS_DSLX_ATTRIBUTE_KIND_TEST: DslxAttributeKind = 4;
289pub const XLS_DSLX_ATTRIBUTE_KIND_TEST_PROC: DslxAttributeKind = 5;
290pub const XLS_DSLX_ATTRIBUTE_KIND_QUICKCHECK: DslxAttributeKind = 6;
291
292pub type DslxAttributeArgumentKind = i32;
293
294pub const XLS_DSLX_ATTRIBUTE_ARGUMENT_KIND_STRING: DslxAttributeArgumentKind = 0;
295pub const XLS_DSLX_ATTRIBUTE_ARGUMENT_KIND_STRING_KEY_VALUE: DslxAttributeArgumentKind = 1;
296pub const XLS_DSLX_ATTRIBUTE_ARGUMENT_KIND_INT_KEY_VALUE: DslxAttributeArgumentKind = 2;
297pub const XLS_DSLX_ATTRIBUTE_ARGUMENT_KIND_STRING_LITERAL: DslxAttributeArgumentKind = 3;
298
299pub const XLS_CALLING_CONVENTION_TYPICAL: XlsCallingConvention = 0;
300pub const XLS_CALLING_CONVENTION_IMPLICIT_TOKEN: XlsCallingConvention = 1;
301pub const XLS_CALLING_CONVENTION_PROC_NEXT: XlsCallingConvention = 2;
302
303#[repr(C)]
304pub struct XlsDslxParametricEnvItem {
305    pub identifier: *const std::os::raw::c_char,
306    pub value: *const CDslxInterpValue,
307}
308
309#[repr(C)]
310pub struct XlsDslxFunctionSpecializationRequest {
311    pub function_name: *const std::os::raw::c_char,
312    pub specialized_name: *const std::os::raw::c_char,
313    pub env: *mut CDslxParametricEnv,
314}
315
316#[repr(C)]
317pub struct CDslxInvocationRewriteRule {
318    pub from_callee: *mut CDslxFunction,
319    pub to_callee: *mut CDslxFunction,
320    pub match_callee_env: *const CDslxParametricEnv,
321    pub to_callee_env: *const CDslxParametricEnv,
322}
323
324unsafe extern "C" {
325    pub fn xls_convert_dslx_to_ir(
326        dslx: *const std::os::raw::c_char,
327        path: *const std::os::raw::c_char,
328        module_name: *const std::os::raw::c_char,
329        dslx_stdlib_path: *const std::os::raw::c_char,
330        additional_search_paths: *const *const std::os::raw::c_char,
331        additional_search_paths_count: libc::size_t,
332        error_out: *mut *mut std::os::raw::c_char,
333        ir_out: *mut *mut std::os::raw::c_char,
334    ) -> bool;
335
336    pub fn xls_convert_dslx_to_ir_with_warnings(
337        dslx: *const std::os::raw::c_char,
338        path: *const std::os::raw::c_char,
339        module_name: *const std::os::raw::c_char,
340        dslx_stdlib_path: *const std::os::raw::c_char,
341        additional_search_paths: *const *const std::os::raw::c_char,
342        additional_search_paths_count: libc::size_t,
343        enable_warnings: *const *const std::os::raw::c_char,
344        enable_warnings_count: libc::size_t,
345        disable_warnings: *const *const std::os::raw::c_char,
346        disable_warnings_count: libc::size_t,
347        warnings_as_errors: bool,
348        force_implicit_token_calling_convention: bool,
349        warnings_out: *mut *mut *mut std::os::raw::c_char,
350        warnings_out_count: *mut libc::size_t,
351        error_out: *mut *mut std::os::raw::c_char,
352        ir_out: *mut *mut std::os::raw::c_char,
353    ) -> bool;
354
355    pub fn xls_convert_dslx_path_to_ir(
356        path: *const std::os::raw::c_char,
357        dslx_stdlib_path: *const std::os::raw::c_char,
358        additional_search_paths: *const *const std::os::raw::c_char,
359        additional_search_paths_count: libc::size_t,
360        error_out: *mut *mut std::os::raw::c_char,
361        ir_out: *mut *mut std::os::raw::c_char,
362    ) -> bool;
363
364    pub fn xls_convert_dslx_path_to_ir_with_warnings(
365        path: *const std::os::raw::c_char,
366        dslx_stdlib_path: *const std::os::raw::c_char,
367        additional_search_paths: *const *const std::os::raw::c_char,
368        additional_search_paths_count: libc::size_t,
369        enable_warnings: *const *const std::os::raw::c_char,
370        enable_warnings_count: libc::size_t,
371        disable_warnings: *const *const std::os::raw::c_char,
372        disable_warnings_count: libc::size_t,
373        warnings_as_errors: bool,
374        force_implicit_token_calling_convention: bool,
375        warnings_out: *mut *mut *mut std::os::raw::c_char,
376        warnings_out_count: *mut libc::size_t,
377        error_out: *mut *mut std::os::raw::c_char,
378        ir_out: *mut *mut std::os::raw::c_char,
379    ) -> bool;
380
381    pub fn xls_parse_typed_value(
382        text: *const std::os::raw::c_char,
383        error_out: *mut *mut std::os::raw::c_char,
384        value_out: *mut *mut CIrValue,
385    ) -> bool;
386    pub fn xls_value_free(value: *mut CIrValue);
387
388    pub fn xls_value_clone(value: *const CIrValue) -> *mut CIrValue;
389
390    // Extracts a bits value from a (boxed) value or gives an error.
391    pub fn xls_value_get_bits(
392        value: *const CIrValue,
393        error_out: *mut *mut std::os::raw::c_char,
394        bits_out: *mut *mut CIrBits,
395    ) -> bool;
396
397    // Turns a span of IR values into a tuple value.
398    pub fn xls_value_make_tuple(
399        value_count: libc::size_t,
400        values: *const *const CIrValue,
401    ) -> *mut CIrValue;
402
403    // Create a token value
404    pub fn xls_value_make_token() -> *mut CIrValue;
405
406    /// Returns an error:
407    /// * if the elements do not all have the same type, or
408    /// * if the array is empty (because then we cannot determine the element
409    ///   type)
410    pub fn xls_value_make_array(
411        element_count: libc::size_t,
412        elements: *const *const CIrValue,
413        error_out: *mut *mut std::os::raw::c_char,
414        result_out: *mut *mut CIrValue,
415    ) -> bool;
416
417    // Extracts an element from a tuple/array value or gives an error (e.g. if
418    // this value is not a tuple/array or the index is out of bounds).
419    pub fn xls_value_get_element(
420        tuple: *const CIrValue,
421        index: libc::size_t,
422        error_out: *mut *mut std::os::raw::c_char,
423        element_out: *mut *mut CIrValue,
424    ) -> bool;
425
426    pub fn xls_value_get_element_count(
427        value: *const CIrValue,
428        error_out: *mut *mut std::os::raw::c_char,
429        count_out: *mut i64,
430    ) -> bool;
431
432    // Creates a bits value (via an unsigned integer) that is boxed in an
433    // XlsIrValue.
434    pub fn xls_value_make_ubits(
435        bit_count: i64,
436        value: u64,
437        error_out: *mut *mut std::os::raw::c_char,
438        result_out: *mut *mut CIrValue,
439    ) -> bool;
440
441    // Creates a bits value (via a signed integer) that is boxed in an
442    // XlsIrValue.
443    pub fn xls_value_make_sbits(
444        bit_count: i64,
445        value: i64,
446        error_out: *mut *mut std::os::raw::c_char,
447        result_out: *mut *mut CIrValue,
448    ) -> bool;
449
450    // Boxes an IR bits object into an IR value.
451    pub fn xls_value_from_bits(bits: *const CIrBits) -> *mut CIrValue;
452
453    pub fn xls_bits_make_ubits(
454        bit_count: i64,
455        value: u64,
456        error_out: *mut *mut std::os::raw::c_char,
457        bits_out: *mut *mut CIrBits,
458    ) -> bool;
459
460    pub fn xls_bits_make_sbits(
461        bit_count: i64,
462        value: i64,
463        error_out: *mut *mut std::os::raw::c_char,
464        bits_out: *mut *mut CIrBits,
465    ) -> bool;
466
467    pub fn xls_bits_free(bits: *mut CIrBits);
468    pub fn xls_bits_get_bit_count(bits: *const CIrBits) -> i64;
469    pub fn xls_bits_get_bit(bits: *const CIrBits, index: i64) -> bool;
470    pub fn xls_bits_eq(bits: *const CIrBits, other: *const CIrBits) -> bool;
471    pub fn xls_bits_ne(a: *const CIrBits, b: *const CIrBits) -> bool;
472    pub fn xls_bits_ult(a: *const CIrBits, b: *const CIrBits) -> bool;
473    pub fn xls_bits_ule(a: *const CIrBits, b: *const CIrBits) -> bool;
474    pub fn xls_bits_ugt(a: *const CIrBits, b: *const CIrBits) -> bool;
475    pub fn xls_bits_uge(a: *const CIrBits, b: *const CIrBits) -> bool;
476    pub fn xls_bits_slt(a: *const CIrBits, b: *const CIrBits) -> bool;
477    pub fn xls_bits_sle(a: *const CIrBits, b: *const CIrBits) -> bool;
478    pub fn xls_bits_sgt(a: *const CIrBits, b: *const CIrBits) -> bool;
479    pub fn xls_bits_sge(a: *const CIrBits, b: *const CIrBits) -> bool;
480    pub fn xls_bits_to_debug_string(bits: *const CIrBits) -> *mut std::os::raw::c_char;
481    pub fn xls_bits_make_bits_from_bytes(
482        bit_count: libc::size_t,
483        bytes: *const u8,
484        byte_count: libc::size_t,
485        error_out: *mut *mut std::os::raw::c_char,
486        bits_out: *mut *mut CIrBits,
487    ) -> bool;
488    pub fn xls_mangle_dslx_name_full(
489        module_name: *const std::os::raw::c_char,
490        function_name: *const std::os::raw::c_char,
491        convention: XlsCallingConvention,
492        free_keys: *const *const std::os::raw::c_char,
493        free_keys_count: libc::size_t,
494        param_env: *const CDslxParametricEnv,
495        scope: *const std::os::raw::c_char,
496        error_out: *mut *mut std::os::raw::c_char,
497        mangled_out: *mut *mut std::os::raw::c_char,
498    ) -> bool;
499    pub fn xls_bits_add(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
500    pub fn xls_bits_sub(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
501    pub fn xls_bits_umul(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
502    pub fn xls_bits_smul(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
503    pub fn xls_bits_udiv(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
504    pub fn xls_bits_sdiv(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
505    pub fn xls_bits_umod(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
506    pub fn xls_bits_smod(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
507    pub fn xls_bits_negate(bits: *const CIrBits) -> *mut CIrBits;
508    pub fn xls_bits_abs(bits: *const CIrBits) -> *mut CIrBits;
509    pub fn xls_bits_not(bits: *const CIrBits) -> *mut CIrBits;
510    pub fn xls_bits_and(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
511    pub fn xls_bits_or(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
512    pub fn xls_bits_xor(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
513
514    pub fn xls_bits_shift_left_logical(bits: *const CIrBits, shift_amount: i64) -> *mut CIrBits;
515    pub fn xls_bits_shift_right_logical(bits: *const CIrBits, shift_amount: i64) -> *mut CIrBits;
516    pub fn xls_bits_shift_right_arithmetic(bits: *const CIrBits, shift_amount: i64)
517    -> *mut CIrBits;
518
519    // struct xls_bits* xls_bits_width_slice(const struct xls_bits* bits,
520    // int64_t start, int64_t width);
521
522    pub fn xls_bits_width_slice(bits: *const CIrBits, start: i64, width: i64) -> *mut CIrBits;
523
524    pub fn xls_bits_to_bytes(
525        bits: *const CIrBits,
526        error_out: *mut *mut std::os::raw::c_char,
527        bytes_out: *mut *mut u8,
528        byte_count_out: *mut libc::size_t,
529    ) -> bool;
530    pub fn xls_bytes_free(bytes: *mut u8);
531    pub fn xls_bits_to_uint64(
532        bits: *const CIrBits,
533        error_out: *mut *mut std::os::raw::c_char,
534        value_out: *mut u64,
535    ) -> bool;
536    pub fn xls_bits_to_int64(
537        bits: *const CIrBits,
538        error_out: *mut *mut std::os::raw::c_char,
539        value_out: *mut i64,
540    ) -> bool;
541
542    pub fn xls_create_bits_rope(bit_count: i64) -> *mut CBitsRope;
543    pub fn xls_bits_rope_append_bits(bits_rope: *mut CBitsRope, bits: *const CIrBits);
544    pub fn xls_bits_rope_get_bits(bits_rope: *mut CBitsRope) -> *mut CIrBits;
545    pub fn xls_bits_rope_free(bits_rope: *mut CBitsRope);
546
547    pub fn xls_package_free(package: *mut CIrPackage);
548    pub fn xls_c_str_free(c_str: *mut std::os::raw::c_char);
549    pub fn xls_c_strs_free(c_strs: *mut *mut std::os::raw::c_char, count: libc::size_t);
550    pub fn xls_value_to_string(
551        value: *const CIrValue,
552        str_out: *mut *mut std::os::raw::c_char,
553    ) -> bool;
554    pub fn xls_format_preference_from_string(
555        s: *const std::os::raw::c_char,
556        error_out: *mut *mut std::os::raw::c_char,
557        result_out: *mut XlsFormatPreference,
558    ) -> bool;
559
560    pub fn xls_value_to_string_format_preference(
561        value: *const CIrValue,
562        fmt: XlsFormatPreference,
563        error_out: *mut *mut std::os::raw::c_char,
564        str_out: *mut *mut std::os::raw::c_char,
565    ) -> bool;
566    pub fn xls_bits_to_string(
567        bits: *const CIrBits,
568        fmt: XlsFormatPreference,
569        include_bit_count: bool,
570        error_out: *mut *mut std::os::raw::c_char,
571        str_out: *mut *mut std::os::raw::c_char,
572    ) -> bool;
573
574    pub fn xls_value_get_kind(
575        value: *const CIrValue,
576        error_out: *mut *mut std::os::raw::c_char,
577        kind_out: *mut XlsValueKind,
578    ) -> bool;
579    pub fn xls_value_make_true() -> *mut CIrValue;
580    pub fn xls_value_make_false() -> *mut CIrValue;
581    pub fn xls_value_from_bits_owned(bits: *mut CIrBits) -> *mut CIrValue;
582    pub fn xls_value_flatten_to_bits(value: *const CIrValue) -> *mut CIrBits;
583
584    pub fn xls_value_eq(value: *const CIrValue, value: *const CIrValue) -> bool;
585    pub fn xls_parse_ir_package(
586        ir: *const std::os::raw::c_char,
587        filename: *const std::os::raw::c_char,
588        error_out: *mut *mut std::os::raw::c_char,
589        xls_package_out: *mut *mut CIrPackage,
590    ) -> bool;
591
592    // -- IR analysis APIs
593
594    pub fn xls_ir_analysis_create_from_package(
595        p: *mut CIrPackage,
596        error_out: *mut *mut std::os::raw::c_char,
597        out: *mut *mut CIrAnalysis,
598    ) -> bool;
599
600    pub fn xls_ir_analysis_create_from_package_with_options(
601        p: *mut CIrPackage,
602        options: *const XlsIrAnalysisOptions,
603        error_out: *mut *mut std::os::raw::c_char,
604        out: *mut *mut CIrAnalysis,
605    ) -> bool;
606
607    pub fn xls_ir_analysis_free(a: *mut CIrAnalysis);
608
609    pub fn xls_ir_analysis_get_known_bits_for_node_id(
610        a: *const CIrAnalysis,
611        node_id: i64,
612        error_out: *mut *mut std::os::raw::c_char,
613        known_mask_out: *mut *mut CIrBits,
614        known_value_out: *mut *mut CIrBits,
615    ) -> bool;
616
617    pub fn xls_ir_analysis_get_intervals_for_node_id(
618        a: *const CIrAnalysis,
619        node_id: i64,
620        error_out: *mut *mut std::os::raw::c_char,
621        intervals_out: *mut *mut CIrIntervalSet,
622    ) -> bool;
623
624    pub fn xls_ir_analysis_at_most_one_bit_true(
625        a: *const CIrAnalysis,
626        node_id: i64,
627        error_out: *mut *mut std::os::raw::c_char,
628        result_out: *mut bool,
629    ) -> bool;
630
631    pub fn xls_ir_analysis_at_least_one_bit_true(
632        a: *const CIrAnalysis,
633        node_id: i64,
634        error_out: *mut *mut std::os::raw::c_char,
635        result_out: *mut bool,
636    ) -> bool;
637
638    pub fn xls_ir_analysis_exactly_one_bit_true(
639        a: *const CIrAnalysis,
640        node_id: i64,
641        error_out: *mut *mut std::os::raw::c_char,
642        result_out: *mut bool,
643    ) -> bool;
644
645    pub fn xls_ir_analysis_known_not_equals(
646        a: *const CIrAnalysis,
647        lhs_node_id: i64,
648        lhs_bit_index: i64,
649        rhs_node_id: i64,
650        rhs_bit_index: i64,
651        error_out: *mut *mut std::os::raw::c_char,
652        result_out: *mut bool,
653    ) -> bool;
654
655    pub fn xls_ir_analysis_implies(
656        a: *const CIrAnalysis,
657        lhs_node_id: i64,
658        lhs_bit_index: i64,
659        rhs_node_id: i64,
660        rhs_bit_index: i64,
661        error_out: *mut *mut std::os::raw::c_char,
662        result_out: *mut bool,
663    ) -> bool;
664
665    pub fn xls_interval_set_get_interval_count(s: *const CIrIntervalSet) -> i64;
666
667    pub fn xls_interval_set_get_interval_bounds(
668        s: *const CIrIntervalSet,
669        i: i64,
670        error_out: *mut *mut std::os::raw::c_char,
671        lo_out: *mut *mut CIrBits,
672        hi_out: *mut *mut CIrBits,
673    ) -> bool;
674
675    pub fn xls_interval_set_free(s: *mut CIrIntervalSet);
676
677    pub fn xls_type_to_string(
678        t: *const CIrType,
679        error_out: *mut *mut std::os::raw::c_char,
680        result_out: *mut *mut std::os::raw::c_char,
681    ) -> bool;
682    pub fn xls_type_get_kind(
683        t: *mut CIrType,
684        error_out: *mut *mut std::os::raw::c_char,
685        kind_out: *mut XlsValueKind,
686    ) -> bool;
687    pub fn xls_type_get_flat_bit_count(t: *const CIrType) -> i64;
688    pub fn xls_type_get_leaf_count(t: *mut CIrType) -> i64;
689    pub fn xls_package_get_type_for_value(
690        package: *const CIrPackage,
691        value: *const CIrValue,
692        error_out: *mut *mut std::os::raw::c_char,
693        result_out: *mut *mut CIrType,
694    ) -> bool;
695    pub fn xls_package_get_function(
696        package: *const CIrPackage,
697        function_name: *const std::os::raw::c_char,
698        error_out: *mut *mut std::os::raw::c_char,
699        result_out: *mut *mut CIrFunction,
700    ) -> bool;
701    pub fn xls_package_get_functions(
702        package: *mut CIrPackage,
703        error_out: *mut *mut std::os::raw::c_char,
704        result_out: *mut *mut *mut CIrFunction,
705        count_out: *mut libc::size_t,
706    ) -> bool;
707    pub fn xls_function_ptr_array_free(function_pointer_array: *mut *mut CIrFunction);
708    pub fn xls_function_get_type(
709        function: *const CIrFunction,
710        error_out: *mut *mut std::os::raw::c_char,
711        xls_fn_type_out: *mut *mut CIrFunctionType,
712    ) -> bool;
713    pub fn xls_function_type_to_string(
714        t: *const CIrFunctionType,
715        error_out: *mut *mut std::os::raw::c_char,
716        string_out: *mut *mut std::os::raw::c_char,
717    ) -> bool;
718    pub fn xls_function_get_name(
719        function: *const CIrFunction,
720        error_out: *mut *mut std::os::raw::c_char,
721        name_out: *mut *mut std::os::raw::c_char,
722    ) -> bool;
723    pub fn xls_function_to_z3_smtlib(
724        function: *mut CIrFunction,
725        error_out: *mut *mut std::os::raw::c_char,
726        string_out: *mut *mut std::os::raw::c_char,
727    ) -> bool;
728    pub fn xls_interpret_function(
729        function: *const CIrFunction,
730        argc: libc::size_t,
731        args: *const *const CIrValue,
732        error_out: *mut *mut std::os::raw::c_char,
733        result_out: *mut *mut CIrValue,
734    ) -> bool;
735    pub fn xls_optimize_ir(
736        ir: *const std::os::raw::c_char,
737        top: *const std::os::raw::c_char,
738        error_out: *mut *mut std::os::raw::c_char,
739        ir_out: *mut *mut std::os::raw::c_char,
740    ) -> bool;
741    pub fn xls_mangle_dslx_name(
742        module_name: *const std::os::raw::c_char,
743        function_name: *const std::os::raw::c_char,
744        error_out: *mut *mut std::os::raw::c_char,
745        mangled_out: *mut *mut std::os::raw::c_char,
746    ) -> bool;
747    pub fn xls_init_xls(
748        usage: *const std::os::raw::c_char,
749        argc: libc::c_int,
750        argv: *mut *mut std::os::raw::c_char,
751    );
752    pub fn xls_package_to_string(
753        p: *const CIrPackage,
754        string_out: *mut *mut std::os::raw::c_char,
755    ) -> bool;
756    pub fn xls_function_to_string(
757        f: *const CIrFunction,
758        string_out: *mut *mut std::os::raw::c_char,
759    ) -> bool;
760    pub fn xls_package_get_top(p: *mut CIrPackage) -> *mut CIrFunctionBase;
761    pub fn xls_package_set_top_by_name(
762        p: *mut CIrPackage,
763        name: *const std::os::raw::c_char,
764        error_out: *mut *mut std::os::raw::c_char,
765    ) -> bool;
766
767    pub fn xls_verify_package(
768        p: *mut CIrPackage,
769        error_out: *mut *mut std::os::raw::c_char,
770    ) -> bool;
771
772    pub fn xls_make_function_jit(
773        function: *const CIrFunction,
774        error_out: *mut *mut std::os::raw::c_char,
775        result_out: *mut *mut CIrFunctionJit,
776    ) -> bool;
777    pub fn xls_aot_compile_function(
778        function: *mut CIrFunction,
779        error_out: *mut *mut std::os::raw::c_char,
780        object_code_out: *mut *mut u8,
781        object_code_count_out: *mut libc::size_t,
782        entrypoints_proto_out: *mut *mut u8,
783        entrypoints_proto_count_out: *mut libc::size_t,
784    ) -> bool;
785    pub fn xls_aot_object_code_free(object_code: *mut u8);
786    pub fn xls_aot_entrypoints_proto_free(entrypoints_proto: *mut u8);
787    pub fn xls_aot_exec_context_create(
788        entrypoints_proto: *const u8,
789        entrypoints_proto_count: libc::size_t,
790        error_out: *mut *mut std::os::raw::c_char,
791        out: *mut *mut CXlsAotExecContext,
792    ) -> bool;
793    pub fn xls_aot_exec_context_clear_events(context: *mut CXlsAotExecContext);
794    pub fn xls_aot_exec_context_free(context: *mut CXlsAotExecContext);
795    pub fn xls_aot_entrypoint_trampoline(
796        function_ptr: usize,
797        inputs: *const *const u8,
798        outputs: *const *mut u8,
799        temp_buffer: *mut libc::c_void,
800        context: *mut CXlsAotExecContext,
801        continuation_point: i64,
802        trace_messages_count_out: *mut libc::size_t,
803        assert_messages_count_out: *mut libc::size_t,
804    ) -> i64;
805    pub fn xls_aot_exec_context_get_trace_message(
806        context: *const CXlsAotExecContext,
807        index: libc::size_t,
808        error_out: *mut *mut std::os::raw::c_char,
809        trace_message_out: *mut CTraceMessage,
810    ) -> bool;
811    pub fn xls_aot_exec_context_get_assert_message(
812        context: *const CXlsAotExecContext,
813        index: libc::size_t,
814        error_out: *mut *mut std::os::raw::c_char,
815        assert_message_out: *mut *mut std::os::raw::c_char,
816    ) -> bool;
817    pub fn xls_function_jit_free(jit: *mut CIrFunctionJit);
818    pub fn xls_function_jit_run(
819        jit: *const CIrFunctionJit,
820        argc: libc::size_t,
821        args: *const *const CIrValue,
822        error_out: *mut *mut std::os::raw::c_char,
823        trace_messages_out: *mut *mut CTraceMessage,
824        trace_messages_count_out: *mut libc::size_t,
825        assert_messages_out: *mut *mut *mut std::os::raw::c_char,
826        assert_messages_count_out: *mut libc::size_t,
827        result_out: *mut *mut CIrValue,
828    ) -> bool;
829    pub fn xls_trace_messages_free(trace_messages: *mut CTraceMessage, count: libc::size_t);
830
831    // -- DSLX
832
833    pub fn xls_dslx_import_data_create(
834        dslx_stdlib_path: *const std::os::raw::c_char,
835        additional_search_paths: *const *const std::os::raw::c_char,
836        additional_search_paths_count: libc::size_t,
837    ) -> *mut CDslxImportData;
838    pub fn xls_dslx_import_data_free(data: *mut CDslxImportData);
839
840    pub fn xls_dslx_parse_and_typecheck(
841        text: *const std::os::raw::c_char,
842        path: *const std::os::raw::c_char,
843        module_name: *const std::os::raw::c_char,
844        import_data: *const CDslxImportData,
845        error_out: *mut *mut std::os::raw::c_char,
846        typechecked_module_out: *mut *mut CDslxTypecheckedModule,
847    ) -> bool;
848
849    pub fn xls_dslx_typechecked_module_clone_removing_functions(
850        tm: *mut CDslxTypecheckedModule,
851        functions: *mut *mut CDslxFunction,
852        function_count: libc::size_t,
853        install_subject: *const std::os::raw::c_char,
854        import_data: *mut CDslxImportData,
855        error_out: *mut *mut std::os::raw::c_char,
856        result_out: *mut *mut CDslxTypecheckedModule,
857    ) -> bool;
858
859    pub fn xls_dslx_typechecked_module_clone_removing_members(
860        tm: *mut CDslxTypecheckedModule,
861        members: *mut *mut CDslxModuleMember,
862        member_count: libc::size_t,
863        install_subject: *const std::os::raw::c_char,
864        import_data: *mut CDslxImportData,
865        error_out: *mut *mut std::os::raw::c_char,
866        result_out: *mut *mut CDslxTypecheckedModule,
867    ) -> bool;
868
869    pub fn xls_dslx_replace_invocations_in_module(
870        tm: *mut CDslxTypecheckedModule,
871        callers: *const *mut CDslxFunction,
872        callers_count: libc::size_t,
873        rules: *const CDslxInvocationRewriteRule,
874        rules_count: libc::size_t,
875        import_data: *mut CDslxImportData,
876        install_subject: *const std::os::raw::c_char,
877        error_out: *mut *mut std::os::raw::c_char,
878        result_out: *mut *mut CDslxTypecheckedModule,
879    ) -> bool;
880
881    pub fn xls_dslx_typechecked_module_insert_function_specializations(
882        typechecked_module: *mut CDslxTypecheckedModule,
883        requests: *const XlsDslxFunctionSpecializationRequest,
884        request_count: libc::size_t,
885        import_data: *mut CDslxImportData,
886        install_subject: *const std::os::raw::c_char,
887        error_out: *mut *mut std::os::raw::c_char,
888        result_out: *mut *mut CDslxTypecheckedModule,
889    ) -> bool;
890
891    // bool xls_schedule_and_codegen_package(
892    // struct xls_package* p, const char* scheduling_options_flags_proto,
893    // const char* codegen_flags_proto, bool with_delay_model, char** error_out,
894    // struct xls_schedule_and_codegen_result** result_out);
895    pub fn xls_schedule_and_codegen_package(
896        p: *mut CIrPackage,
897        scheduling_options_flags_proto: *const std::os::raw::c_char,
898        codegen_flags_proto: *const std::os::raw::c_char,
899        with_delay_model: bool,
900        error_out: *mut *mut std::os::raw::c_char,
901        result_out: *mut *mut CScheduleAndCodegenResult,
902    ) -> bool;
903
904    pub fn xls_schedule_and_codegen_result_get_verilog_text(
905        result: *mut CScheduleAndCodegenResult,
906    ) -> *mut std::os::raw::c_char;
907
908    pub fn xls_schedule_and_codegen_result_free(result: *mut CScheduleAndCodegenResult);
909
910    pub fn xls_dslx_typechecked_module_free(module: *mut CDslxTypecheckedModule);
911
912    pub fn xls_dslx_typechecked_module_get_module(
913        module: *mut CDslxTypecheckedModule,
914    ) -> *mut CDslxModule;
915
916    pub fn xls_dslx_typechecked_module_get_type_info(
917        module: *mut CDslxTypecheckedModule,
918    ) -> *mut CDslxTypeInfo;
919
920    pub fn xls_dslx_module_to_string(module: *mut CDslxModule) -> *mut std::os::raw::c_char;
921
922    pub fn xls_dslx_module_get_name(module: *const CDslxModule) -> *mut std::os::raw::c_char;
923
924    pub fn xls_dslx_module_get_type_definition_count(module: *const CDslxModule) -> i64;
925
926    pub fn xls_dslx_module_get_member_count(module: *const CDslxModule) -> i64;
927
928    pub fn xls_dslx_module_get_member(module: *const CDslxModule, i: i64)
929    -> *mut CDslxModuleMember;
930
931    pub fn xls_dslx_module_get_type_definition_kind(
932        module: *const CDslxModule,
933        i: i64,
934    ) -> DslxTypeDefinitionKind;
935
936    pub fn xls_dslx_module_get_type_definition_as_struct_def(
937        module: *const CDslxModule,
938        i: i64,
939    ) -> *mut CDslxStructDef;
940    pub fn xls_dslx_module_get_type_definition_as_enum_def(
941        module: *const CDslxModule,
942        i: i64,
943    ) -> *mut CDslxEnumDef;
944    pub fn xls_dslx_module_get_type_definition_as_sum_def(
945        module: *const CDslxModule,
946        i: i64,
947    ) -> *mut CDslxSumDef;
948    pub fn xls_dslx_module_get_type_definition_as_type_alias(
949        module: *const CDslxModule,
950        i: i64,
951    ) -> *mut CDslxTypeAlias;
952
953    // -- xls_dslx_module_member
954    pub fn xls_dslx_module_member_get_kind(
955        member: *const CDslxModuleMember,
956    ) -> DslxModuleMemberKind;
957    pub fn xls_dslx_module_member_get_constant_def(
958        member: *const CDslxModuleMember,
959    ) -> *mut CDslxConstantDef;
960    pub fn xls_dslx_module_member_get_type_alias(
961        member: *const CDslxModuleMember,
962    ) -> *mut CDslxTypeAlias;
963    pub fn xls_dslx_module_member_get_struct_def(
964        member: *const CDslxModuleMember,
965    ) -> *mut CDslxStructDef;
966    pub fn xls_dslx_module_member_get_enum_def(
967        member: *const CDslxModuleMember,
968    ) -> *mut CDslxEnumDef;
969    pub fn xls_dslx_module_member_get_sum_def(member: *const CDslxModuleMember)
970    -> *mut CDslxSumDef;
971    pub fn xls_dslx_module_member_get_function(
972        member: *const CDslxModuleMember,
973    ) -> *mut CDslxFunction;
974    pub fn xls_dslx_module_member_get_import(member: *const CDslxModuleMember) -> *mut CDslxImport;
975    pub fn xls_dslx_module_member_get_quickcheck(
976        member: *const CDslxModuleMember,
977    ) -> *mut CDslxQuickcheck;
978    pub fn xls_dslx_module_member_from_constant_def(
979        constant_def: *mut CDslxConstantDef,
980    ) -> *mut CDslxModuleMember;
981    pub fn xls_dslx_module_member_from_struct_def(
982        struct_def: *mut CDslxStructDef,
983    ) -> *mut CDslxModuleMember;
984    pub fn xls_dslx_module_member_from_enum_def(
985        enum_def: *mut CDslxEnumDef,
986    ) -> *mut CDslxModuleMember;
987    pub fn xls_dslx_module_member_from_sum_def(sum_def: *mut CDslxSumDef)
988    -> *mut CDslxModuleMember;
989    pub fn xls_dslx_module_member_from_type_alias(
990        type_alias: *mut CDslxTypeAlias,
991    ) -> *mut CDslxModuleMember;
992    pub fn xls_dslx_module_member_from_function(
993        function: *mut CDslxFunction,
994    ) -> *mut CDslxModuleMember;
995    pub fn xls_dslx_module_member_from_quickcheck(
996        quickcheck: *mut CDslxQuickcheck,
997    ) -> *mut CDslxModuleMember;
998
999    pub fn xls_dslx_colon_ref_get_attr(
1000        colon_ref: *const CDslxColonRef,
1001    ) -> *mut std::os::raw::c_char;
1002
1003    pub fn xls_dslx_type_info_get_type_struct_def(
1004        type_info: *mut CDslxTypeInfo,
1005        node: *mut CDslxStructDef,
1006    ) -> *mut CDslxType;
1007    pub fn xls_dslx_type_info_get_type_enum_def(
1008        type_info: *mut CDslxTypeInfo,
1009        node: *mut CDslxEnumDef,
1010    ) -> *mut CDslxType;
1011    pub fn xls_dslx_type_info_get_type_sum_def(
1012        type_info: *mut CDslxTypeInfo,
1013        node: *mut CDslxSumDef,
1014    ) -> *mut CDslxType;
1015    pub fn xls_dslx_type_info_get_type_struct_member(
1016        type_info: *mut CDslxTypeInfo,
1017        member: *mut CDslxStructMember,
1018    ) -> *mut CDslxType;
1019    pub fn xls_dslx_type_info_get_type_constant_def(
1020        type_info: *mut CDslxTypeInfo,
1021        node: *mut CDslxConstantDef,
1022    ) -> *mut CDslxType;
1023
1024    /// Gets the concrete type for a TypeAnnotation AST node.
1025    pub fn xls_dslx_type_info_get_type_type_annotation(
1026        type_info: *mut CDslxTypeInfo,
1027        type_annotation: *mut CDslxTypeAnnotation,
1028    ) -> *mut CDslxType;
1029
1030    pub fn xls_dslx_type_info_get_imported_type_info(
1031        type_info: *mut CDslxTypeInfo,
1032        module: *mut CDslxModule,
1033    ) -> *mut CDslxTypeInfo;
1034
1035    pub fn xls_dslx_type_info_get_unique_invocation_callee_data(
1036        type_info: *mut CDslxTypeInfo,
1037        function: *mut CDslxFunction,
1038    ) -> *mut CDslxInvocationCalleeDataArray;
1039    pub fn xls_dslx_type_info_get_all_invocation_callee_data(
1040        type_info: *mut CDslxTypeInfo,
1041        function: *mut CDslxFunction,
1042    ) -> *mut CDslxInvocationCalleeDataArray;
1043    pub fn xls_dslx_type_info_get_root_invocation_data(
1044        type_info: *mut CDslxTypeInfo,
1045        invocation: *mut CDslxInvocation,
1046    ) -> *mut CDslxInvocationData;
1047
1048    // -- call_graph
1049    pub fn xls_dslx_type_info_build_function_call_graph(
1050        type_info: *mut CDslxTypeInfo,
1051        error_out: *mut *mut std::os::raw::c_char,
1052        result_out: *mut *mut CDslxCallGraph,
1053    ) -> bool;
1054
1055    pub fn xls_dslx_type_info_build_function_call_graph_for_module(
1056        type_info: *mut CDslxTypeInfo,
1057        module: *mut CDslxModule,
1058        error_out: *mut *mut std::os::raw::c_char,
1059        result_out: *mut *mut CDslxCallGraph,
1060    ) -> bool;
1061
1062    pub fn xls_dslx_call_graph_free(call_graph: *mut CDslxCallGraph);
1063
1064    pub fn xls_dslx_call_graph_get_function_count(call_graph: *mut CDslxCallGraph) -> i64;
1065
1066    pub fn xls_dslx_call_graph_get_function(
1067        call_graph: *mut CDslxCallGraph,
1068        index: i64,
1069    ) -> *mut CDslxFunction;
1070
1071    pub fn xls_dslx_call_graph_get_callee_count(
1072        call_graph: *mut CDslxCallGraph,
1073        caller: *mut CDslxFunction,
1074    ) -> i64;
1075
1076    pub fn xls_dslx_call_graph_get_callee_function(
1077        call_graph: *mut CDslxCallGraph,
1078        caller: *mut CDslxFunction,
1079        callee_index: i64,
1080    ) -> *mut CDslxFunction;
1081
1082    pub fn xls_dslx_invocation_callee_data_array_free(array: *mut CDslxInvocationCalleeDataArray);
1083    pub fn xls_dslx_invocation_callee_data_array_get_count(
1084        array: *mut CDslxInvocationCalleeDataArray,
1085    ) -> i64;
1086    pub fn xls_dslx_invocation_callee_data_array_get(
1087        array: *mut CDslxInvocationCalleeDataArray,
1088        index: i64,
1089    ) -> *mut CDslxInvocationCalleeData;
1090
1091    pub fn xls_dslx_invocation_callee_data_clone(
1092        data: *mut CDslxInvocationCalleeData,
1093    ) -> *mut CDslxInvocationCalleeData;
1094    pub fn xls_dslx_invocation_callee_data_free(data: *mut CDslxInvocationCalleeData);
1095    pub fn xls_dslx_invocation_callee_data_get_callee_bindings(
1096        data: *mut CDslxInvocationCalleeData,
1097    ) -> *const CDslxParametricEnv;
1098    pub fn xls_dslx_invocation_callee_data_get_caller_bindings(
1099        data: *mut CDslxInvocationCalleeData,
1100    ) -> *const CDslxParametricEnv;
1101    pub fn xls_dslx_invocation_callee_data_get_derived_type_info(
1102        data: *mut CDslxInvocationCalleeData,
1103    ) -> *mut CDslxTypeInfo;
1104    pub fn xls_dslx_invocation_callee_data_get_invocation(
1105        data: *mut CDslxInvocationCalleeData,
1106    ) -> *mut CDslxInvocation;
1107
1108    pub fn xls_dslx_invocation_data_get_invocation(
1109        data: *mut CDslxInvocationData,
1110    ) -> *mut CDslxInvocation;
1111    pub fn xls_dslx_invocation_data_get_callee(
1112        data: *mut CDslxInvocationData,
1113    ) -> *mut CDslxFunction;
1114    pub fn xls_dslx_invocation_data_get_caller(
1115        data: *mut CDslxInvocationData,
1116    ) -> *mut CDslxFunction;
1117
1118    // -- ConstantDef
1119
1120    pub fn xls_dslx_constant_def_get_name(
1121        constant_def: *const CDslxConstantDef,
1122    ) -> *mut std::os::raw::c_char;
1123
1124    pub fn xls_dslx_constant_def_get_value(constant_def: *const CDslxConstantDef)
1125    -> *mut CDslxExpr;
1126
1127    // -- TypeAlias
1128
1129    pub fn xls_dslx_type_alias_get_identifier(
1130        type_alias: *const CDslxTypeAlias,
1131    ) -> *mut std::os::raw::c_char;
1132
1133    pub fn xls_dslx_type_alias_get_type_annotation(
1134        type_alias: *const CDslxTypeAlias,
1135    ) -> *mut CDslxTypeAnnotation;
1136
1137    // -- TypeAnnotation
1138
1139    pub fn xls_dslx_type_annotation_get_type_ref_type_annotation(
1140        type_annotation: *const CDslxTypeAnnotation,
1141    ) -> *mut CDslxTypeRefTypeAnnotation;
1142    pub fn xls_dslx_type_annotation_get_array_type_annotation(
1143        type_annotation: *const CDslxTypeAnnotation,
1144    ) -> *mut CDslxArrayTypeAnnotation;
1145
1146    // -- ArrayTypeAnnotation
1147
1148    pub fn xls_dslx_array_type_annotation_get_element_type(
1149        array_type_annotation: *const CDslxArrayTypeAnnotation,
1150    ) -> *mut CDslxTypeAnnotation;
1151
1152    // -- TypeRef
1153
1154    pub fn xls_dslx_type_ref_get_type_definition(
1155        type_ref: *const CDslxTypeRef,
1156    ) -> *mut CDslxTypeDefinition;
1157
1158    // -- Import
1159
1160    pub fn xls_dslx_import_get_subject_count(import: *const CDslxImport) -> i64;
1161    pub fn xls_dslx_import_get_subject(
1162        import: *const CDslxImport,
1163        i: i64,
1164    ) -> *mut std::os::raw::c_char;
1165
1166    // -- ColonRef
1167
1168    pub fn xls_dslx_colon_ref_resolve_import_subject(
1169        colon_ref: *const CDslxColonRef,
1170    ) -> *mut CDslxImport;
1171
1172    // -- TypeDefinition
1173
1174    pub fn xls_dslx_type_definition_get_colon_ref(
1175        type_definition: *const CDslxTypeDefinition,
1176    ) -> *mut CDslxColonRef;
1177    pub fn xls_dslx_type_definition_get_type_alias(
1178        type_definition: *const CDslxTypeDefinition,
1179    ) -> *mut CDslxTypeAlias;
1180
1181    // -- TypeRefTypeAnnotation
1182
1183    pub fn xls_dslx_type_ref_type_annotation_get_type_ref(
1184        type_ref_type_annotation: *const CDslxTypeRefTypeAnnotation,
1185    ) -> *mut CDslxTypeRef;
1186    pub fn xls_dslx_type_ref_type_annotation_get_parametric_count(
1187        type_ref_type_annotation: *const CDslxTypeRefTypeAnnotation,
1188    ) -> i64;
1189    pub fn xls_dslx_type_ref_type_annotation_get_parametric_expr(
1190        type_ref_type_annotation: *const CDslxTypeRefTypeAnnotation,
1191        index: i64,
1192    ) -> *mut CDslxExpr;
1193
1194    // -- StructDef
1195
1196    pub fn xls_dslx_struct_def_get_identifier(
1197        struct_def: *const CDslxStructDef,
1198    ) -> *mut std::os::raw::c_char;
1199
1200    pub fn xls_dslx_struct_def_is_parametric(struct_def: *const CDslxStructDef) -> bool;
1201
1202    pub fn xls_dslx_struct_def_get_parametric_binding_count(
1203        struct_def: *const CDslxStructDef,
1204    ) -> i64;
1205    pub fn xls_dslx_struct_def_get_parametric_binding(
1206        struct_def: *const CDslxStructDef,
1207        index: i64,
1208    ) -> *mut CDslxParametricBinding;
1209
1210    pub fn xls_dslx_struct_def_get_member_count(struct_def: *const CDslxStructDef) -> i64;
1211
1212    pub fn xls_dslx_struct_def_get_member(
1213        struct_def: *const CDslxStructDef,
1214        i: i64,
1215    ) -> *mut CDslxStructMember;
1216
1217    pub fn xls_dslx_struct_member_get_name(
1218        member: *const CDslxStructMember,
1219    ) -> *mut std::os::raw::c_char;
1220
1221    pub fn xls_dslx_struct_member_get_type(
1222        member: *const CDslxStructMember,
1223    ) -> *mut CDslxTypeAnnotation;
1224
1225    // -- EnumDef
1226
1227    pub fn xls_dslx_enum_def_get_identifier(
1228        enum_def: *const CDslxEnumDef,
1229    ) -> *mut std::os::raw::c_char;
1230
1231    pub fn xls_dslx_enum_def_get_member_count(enum_def: *const CDslxEnumDef) -> i64;
1232
1233    pub fn xls_dslx_enum_def_get_member(
1234        enum_def: *const CDslxEnumDef,
1235        i: i64,
1236    ) -> *mut CDslxEnumMember;
1237
1238    pub fn xls_dslx_enum_def_get_underlying(
1239        enum_def: *const CDslxEnumDef,
1240    ) -> *mut CDslxTypeAnnotation;
1241
1242    pub fn xls_dslx_enum_member_get_name(
1243        member: *const CDslxEnumMember,
1244    ) -> *mut std::os::raw::c_char;
1245
1246    pub fn xls_dslx_enum_member_get_value(member: *const CDslxEnumMember) -> *mut CDslxExpr;
1247
1248    // -- SumDef
1249
1250    pub fn xls_dslx_sum_def_get_identifier(
1251        sum_def: *const CDslxSumDef,
1252    ) -> *mut std::os::raw::c_char;
1253
1254    pub fn xls_dslx_sum_def_is_parametric(sum_def: *const CDslxSumDef) -> bool;
1255
1256    pub fn xls_dslx_sum_def_get_variant_count(sum_def: *const CDslxSumDef) -> i64;
1257
1258    pub fn xls_dslx_expr_get_owner_module(expr: *mut CDslxExpr) -> *mut CDslxModule;
1259
1260    // --
1261
1262    pub fn xls_dslx_interp_value_free(value: *mut CDslxInterpValue);
1263
1264    pub fn xls_dslx_interp_value_to_string(
1265        value: *mut CDslxInterpValue,
1266    ) -> *mut std::os::raw::c_char;
1267
1268    pub fn xls_dslx_interp_value_clone(value: *const CDslxInterpValue) -> *mut CDslxInterpValue;
1269
1270    // Parametric env construction and InterpValue helpers
1271    pub fn xls_dslx_parametric_env_create(
1272        items: *const XlsDslxParametricEnvItem,
1273        items_count: libc::size_t,
1274        error_out: *mut *mut std::os::raw::c_char,
1275        env_out: *mut *mut CDslxParametricEnv,
1276    ) -> bool;
1277    pub fn xls_dslx_parametric_env_free(env: *mut CDslxParametricEnv);
1278    pub fn xls_dslx_parametric_env_clone(env: *const CDslxParametricEnv)
1279    -> *mut CDslxParametricEnv;
1280    pub fn xls_dslx_parametric_env_equals(
1281        lhs: *const CDslxParametricEnv,
1282        rhs: *const CDslxParametricEnv,
1283    ) -> bool;
1284    pub fn xls_dslx_parametric_env_less_than(
1285        lhs: *const CDslxParametricEnv,
1286        rhs: *const CDslxParametricEnv,
1287    ) -> bool;
1288    pub fn xls_dslx_parametric_env_hash(env: *const CDslxParametricEnv) -> u64;
1289    pub fn xls_dslx_parametric_env_to_string(
1290        env: *const CDslxParametricEnv,
1291    ) -> *mut std::os::raw::c_char;
1292    pub fn xls_dslx_parametric_env_get_binding_count(env: *const CDslxParametricEnv) -> i64;
1293    pub fn xls_dslx_parametric_env_get_binding_identifier(
1294        env: *const CDslxParametricEnv,
1295        index: i64,
1296    ) -> *const std::os::raw::c_char;
1297    pub fn xls_dslx_parametric_env_get_binding_value(
1298        env: *const CDslxParametricEnv,
1299        index: i64,
1300    ) -> *mut CDslxInterpValue;
1301
1302    pub fn xls_dslx_interp_value_make_ubits(bit_count: i64, value: u64) -> *mut CDslxInterpValue;
1303    pub fn xls_dslx_interp_value_make_sbits(bit_count: i64, value: i64) -> *mut CDslxInterpValue;
1304    pub fn xls_dslx_interp_value_make_enum(
1305        def: *mut CDslxEnumDef,
1306        is_signed: bool,
1307        bits: *const CIrBits,
1308        error_out: *mut *mut std::os::raw::c_char,
1309        result_out: *mut *mut CDslxInterpValue,
1310    ) -> bool;
1311    pub fn xls_dslx_interp_value_make_tuple(
1312        element_count: libc::size_t,
1313        elements: *mut *mut CDslxInterpValue,
1314        error_out: *mut *mut std::os::raw::c_char,
1315        result_out: *mut *mut CDslxInterpValue,
1316    ) -> bool;
1317    pub fn xls_dslx_interp_value_make_array(
1318        element_count: libc::size_t,
1319        elements: *mut *mut CDslxInterpValue,
1320        error_out: *mut *mut std::os::raw::c_char,
1321        result_out: *mut *mut CDslxInterpValue,
1322    ) -> bool;
1323
1324    pub fn xls_dslx_interp_value_from_string(
1325        text: *const std::os::raw::c_char,
1326        dslx_stdlib_path: *const std::os::raw::c_char,
1327        error_out: *mut *mut std::os::raw::c_char,
1328        result_out: *mut *mut CDslxInterpValue,
1329    ) -> bool;
1330
1331    pub fn xls_dslx_interp_value_convert_to_ir(
1332        value: *const CDslxInterpValue,
1333        error_out: *mut *mut std::os::raw::c_char,
1334        result_out: *mut *mut CIrValue,
1335    ) -> bool;
1336
1337    pub fn xls_dslx_type_to_string(
1338        type_: *const CDslxType,
1339        error_out: *mut *mut std::os::raw::c_char,
1340        result_out: *mut *mut std::os::raw::c_char,
1341    ) -> bool;
1342
1343    // Stringification for DSLX AST nodes
1344    pub fn xls_dslx_function_to_string(function: *const CDslxFunction)
1345    -> *mut std::os::raw::c_char;
1346    pub fn xls_dslx_struct_def_to_string(
1347        struct_def: *const CDslxStructDef,
1348    ) -> *mut std::os::raw::c_char;
1349    pub fn xls_dslx_enum_def_to_string(enum_def: *const CDslxEnumDef) -> *mut std::os::raw::c_char;
1350    pub fn xls_dslx_sum_def_to_string(sum_def: *const CDslxSumDef) -> *mut std::os::raw::c_char;
1351    pub fn xls_dslx_type_alias_to_string(
1352        type_alias: *const CDslxTypeAlias,
1353    ) -> *mut std::os::raw::c_char;
1354    pub fn xls_dslx_constant_def_to_string(
1355        constant_def: *const CDslxConstantDef,
1356    ) -> *mut std::os::raw::c_char;
1357    pub fn xls_dslx_quickcheck_to_string(qc: *const CDslxQuickcheck) -> *mut std::os::raw::c_char;
1358    pub fn xls_dslx_expr_to_string(expr: *const CDslxExpr) -> *mut std::os::raw::c_char;
1359
1360    pub fn xls_dslx_type_info_get_const_expr(
1361        type_info: *mut CDslxTypeInfo,
1362        expr: *mut CDslxExpr,
1363        error_out: *mut *mut std::os::raw::c_char,
1364        result_out: *mut *mut CDslxInterpValue,
1365    ) -> bool;
1366
1367    pub fn xls_dslx_type_get_total_bit_count(
1368        type_: *const CDslxType,
1369        error_out: *mut *mut std::os::raw::c_char,
1370        result_out: *mut i64,
1371    ) -> bool;
1372
1373    pub fn xls_dslx_type_is_signed_bits(
1374        type_: *const CDslxType,
1375        error_out: *mut *mut std::os::raw::c_char,
1376        result_out: *mut bool,
1377    ) -> bool;
1378
1379    pub fn xls_dslx_type_is_bits_like(
1380        type_: *const CDslxType,
1381        is_signed: *mut *mut CDslxTypeDim,
1382        size: *mut *mut CDslxTypeDim,
1383    ) -> bool;
1384
1385    pub fn xls_dslx_type_is_enum(type_: *const CDslxType) -> bool;
1386    pub fn xls_dslx_type_is_struct(type_: *const CDslxType) -> bool;
1387    pub fn xls_dslx_type_is_array(type_: *const CDslxType) -> bool;
1388
1389    pub fn xls_dslx_type_dim_is_parametric(dim: *const CDslxTypeDim) -> bool;
1390    pub fn xls_dslx_type_dim_get_as_bool(
1391        dim: *const CDslxTypeDim,
1392        error_out: *mut *mut std::os::raw::c_char,
1393        result_out: *mut bool,
1394    ) -> bool;
1395    pub fn xls_dslx_type_dim_get_as_int64(
1396        dim: *const CDslxTypeDim,
1397        error_out: *mut *mut std::os::raw::c_char,
1398        result_out: *mut i64,
1399    ) -> bool;
1400    pub fn xls_dslx_type_dim_free(dim: *mut CDslxTypeDim);
1401
1402    pub fn xls_dslx_type_get_enum_def(ty: *const CDslxType) -> *mut CDslxEnumDef;
1403
1404    pub fn xls_dslx_type_get_struct_def(ty: *const CDslxType) -> *mut CDslxStructDef;
1405    pub fn xls_dslx_type_struct_get_member_count(ty: *const CDslxType) -> i64;
1406    pub fn xls_dslx_type_struct_get_member_type(ty: *const CDslxType, index: i64)
1407    -> *mut CDslxType;
1408
1409    pub fn xls_dslx_type_array_get_element_type(ty: *const CDslxType) -> *mut CDslxType;
1410    pub fn xls_dslx_type_array_get_size(ty: *const CDslxType) -> *mut CDslxTypeDim;
1411
1412    // -- IR package and type APIs
1413
1414    pub fn xls_package_create(name: *const std::os::raw::c_char) -> *mut CIrPackage;
1415    pub fn xls_package_get_bits_type(package: *mut CIrPackage, bit_count: i64) -> *mut CIrType;
1416
1417    pub fn xls_package_get_tuple_type(
1418        package: *mut CIrPackage,
1419        members: *mut *mut CIrType,
1420        member_count: i64,
1421    ) -> *mut CIrType;
1422
1423    pub fn xls_package_get_array_type(
1424        package: *mut CIrPackage,
1425        element_type: *mut CIrType,
1426        size: i64,
1427    ) -> *mut CIrType;
1428
1429    pub fn xls_package_get_token_type(package: *mut CIrPackage) -> *mut CIrType;
1430
1431    pub fn xls_function_type_get_param_count(fty: *mut CIrFunctionType) -> i64;
1432
1433    pub fn xls_function_type_get_param_type(
1434        fty: *mut CIrFunctionType,
1435        index: libc::size_t,
1436        error_out: *mut *mut std::os::raw::c_char,
1437        param_type_out: *mut *mut CIrType,
1438    ) -> bool;
1439
1440    pub fn xls_function_type_get_return_type(fty: *mut CIrFunctionType) -> *mut CIrType;
1441
1442    pub fn xls_function_get_param_name(
1443        function: *mut CIrFunction,
1444        index: libc::size_t,
1445        error_out: *mut *mut std::os::raw::c_char,
1446        name_out: *mut *mut std::os::raw::c_char,
1447    ) -> bool;
1448
1449    pub fn xls_dslx_function_is_parametric(function: *const CDslxFunction) -> bool;
1450    pub fn xls_dslx_function_is_public(function: *const CDslxFunction) -> bool;
1451    pub fn xls_dslx_function_get_identifier(
1452        function: *const CDslxFunction,
1453    ) -> *mut std::os::raw::c_char;
1454
1455    pub fn xls_dslx_function_get_param_count(function: *const CDslxFunction) -> i64;
1456    pub fn xls_dslx_function_get_parametric_binding_count(function: *const CDslxFunction) -> i64;
1457    pub fn xls_dslx_function_get_param(
1458        function: *const CDslxFunction,
1459        index: i64,
1460    ) -> *mut CDslxParam;
1461    pub fn xls_dslx_function_get_parametric_binding(
1462        function: *const CDslxFunction,
1463        index: i64,
1464    ) -> *mut CDslxParametricBinding;
1465    pub fn xls_dslx_function_get_body(function: *const CDslxFunction) -> *mut CDslxExpr;
1466    // Returns the declared return type annotation node.
1467    // May return nullptr when the function omits an explicit return
1468    // annotation and relies on inferred return type.
1469    pub fn xls_dslx_function_get_return_type(
1470        function: *const CDslxFunction,
1471    ) -> *mut CDslxTypeAnnotation;
1472    pub fn xls_dslx_function_get_attribute_count(function: *const CDslxFunction) -> i64;
1473    pub fn xls_dslx_function_get_attribute(
1474        function: *const CDslxFunction,
1475        index: i64,
1476    ) -> *mut CDslxAttribute;
1477    pub fn xls_dslx_param_get_name(param: *const CDslxParam) -> *mut std::os::raw::c_char;
1478    pub fn xls_dslx_param_get_type_annotation(param: *const CDslxParam)
1479    -> *mut CDslxTypeAnnotation;
1480    pub fn xls_dslx_attribute_get_kind(attribute: *const CDslxAttribute) -> DslxAttributeKind;
1481    pub fn xls_dslx_attribute_get_argument_count(attribute: *const CDslxAttribute) -> i64;
1482    pub fn xls_dslx_attribute_get_argument_kind(
1483        attribute: *const CDslxAttribute,
1484        index: i64,
1485    ) -> DslxAttributeArgumentKind;
1486    pub fn xls_dslx_attribute_get_string_argument(
1487        attribute: *const CDslxAttribute,
1488        index: i64,
1489    ) -> *mut std::os::raw::c_char;
1490    pub fn xls_dslx_attribute_get_string_literal_argument(
1491        attribute: *const CDslxAttribute,
1492        index: i64,
1493    ) -> *mut std::os::raw::c_char;
1494    pub fn xls_dslx_attribute_get_key_value_argument_key(
1495        attribute: *const CDslxAttribute,
1496        index: i64,
1497    ) -> *mut std::os::raw::c_char;
1498    pub fn xls_dslx_attribute_get_key_value_string_argument_value(
1499        attribute: *const CDslxAttribute,
1500        index: i64,
1501    ) -> *mut std::os::raw::c_char;
1502    pub fn xls_dslx_attribute_get_key_value_int_argument_value(
1503        attribute: *const CDslxAttribute,
1504        index: i64,
1505    ) -> i64;
1506    pub fn xls_dslx_attribute_to_string(
1507        attribute: *const CDslxAttribute,
1508    ) -> *mut std::os::raw::c_char;
1509    pub fn xls_dslx_parametric_binding_get_identifier(
1510        binding: *const CDslxParametricBinding,
1511    ) -> *mut std::os::raw::c_char;
1512    pub fn xls_dslx_parametric_binding_get_type_annotation(
1513        binding: *const CDslxParametricBinding,
1514    ) -> *mut CDslxTypeAnnotation;
1515    pub fn xls_dslx_parametric_binding_get_expr(
1516        binding: *const CDslxParametricBinding,
1517    ) -> *mut CDslxExpr;
1518    pub fn xls_dslx_parametric_binding_get_default_generic_type(
1519        binding: *const CDslxParametricBinding,
1520    ) -> *mut CDslxTypeAnnotation;
1521
1522    // -- "requires implicit token?" determination for a DSLX function
1523    pub fn xls_dslx_type_info_get_requires_implicit_token(
1524        type_info: *mut CDslxTypeInfo,
1525        function: *mut CDslxFunction,
1526        error_out: *mut *mut std::os::raw::c_char,
1527        result_out: *mut bool,
1528    ) -> bool;
1529
1530    // -- Quickcheck APIs
1531    pub fn xls_dslx_quickcheck_get_function(qc: *const CDslxQuickcheck) -> *mut CDslxFunction;
1532
1533    /// Returns true iff the Quickcheck has the `exhaustive` test-cases
1534    /// specifier.
1535    pub fn xls_dslx_quickcheck_is_exhaustive(qc: *const CDslxQuickcheck) -> bool;
1536
1537    /// Retrieves the test-case count for the Quickcheck. Returns true and sets
1538    /// `*result_out` when the Quickcheck has a counted test-case specifier;
1539    /// returns false when the Quickcheck is marked exhaustive (in which case
1540    /// `*result_out` is not modified).
1541    pub fn xls_dslx_quickcheck_get_count(qc: *const CDslxQuickcheck, result_out: *mut i64) -> bool;
1542}
1543
1544mod generated_artifact_paths {
1545    include!(concat!(env!("OUT_DIR"), "/artifact_paths.rs"));
1546}
1547
1548pub const DSLX_STDLIB_PATH: &str = generated_artifact_paths::DSLX_STDLIB_PATH;
1549
1550/// Path describing where the libxls shared library was materialized.
1551///
1552/// This value is a shared-library file path when the build uses explicit
1553/// artifact overrides, and a directory path when `xlsynth-sys` downloaded or
1554/// symlinked the DSO into its own output directory.
1555///
1556/// *** DO NOT USE THIS VARIABLE FROM WITHIN YOUR build.rs ***
1557///
1558/// You might be tempted to write the following in your build.rs:
1559///
1560/// ```ignore
1561/// // DO NOT DO THIS IN YOUR build.rs!!
1562/// let dylib_dirpath = xlsynth_sys::XLS_DSO_PATH;
1563/// // set rpath to dylib_dirpath or something.
1564/// ```
1565///
1566/// The problem is that build.rs is compiled for host, whereas if you're setting
1567/// an rpath (or something similar) you want to get the path from compiling
1568/// xlsynth_sys for *target*.  In other words, the above will break
1569/// cross-compilation.
1570///
1571/// Instead, your build.rs should get the path from an envvar which:
1572///
1573/// ```ignore
1574/// // Do this from your build.rs instead.
1575/// let dylib_path = std::env::var("DEP_XLSYNTH_DSO_PATH").unwrap();
1576/// ```
1577///
1578/// `DEP_XLSYNTH_DSO_PATH` follows the same contract as `XLS_DSO_PATH`: it is a
1579/// shared-library file path when `xlsynth-sys` uses explicit artifact
1580/// overrides, and a directory path when `xlsynth-sys` downloaded or symlinked
1581/// the DSO into its own output directory. Downstream `build.rs` code that needs
1582/// a directory for link-search or rpath setup should normalize a file path to
1583/// its parent directory before using it.
1584///
1585/// More details are available at
1586/// <https://doc.rust-lang.org/cargo/reference/build-script-examples.html#using-another-sys-crate>.
1587///
1588/// (If you use this envvar from your crate proper -- i.e. not from build.rs --
1589/// then it's perfectly fine.)
1590pub const XLS_DSO_PATH: &str = generated_artifact_paths::XLS_DSO_PATH;