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
5extern crate libc;
6
7#[repr(C)]
8pub struct CIrValue {
9    _private: [u8; 0], // Ensures the struct cannot be instantiated
10}
11
12#[repr(C)]
13pub struct CIrBits {
14    _private: [u8; 0], // Ensures the struct cannot be instantiated
15}
16
17#[repr(C)]
18pub struct CIrPackage {
19    _private: [u8; 0], // Ensures the struct cannot be instantiated
20}
21
22#[repr(C)]
23pub struct CIrFunction {
24    _private: [u8; 0], // Ensures the struct cannot be instantiated
25}
26
27#[repr(C)]
28pub struct CIrFunctionJit {
29    _private: [u8; 0], // Ensures the struct cannot be instantiated
30}
31
32#[repr(C)]
33pub struct CTraceMessage {
34    pub message: *mut std::os::raw::c_char,
35    pub verbosity: i64,
36}
37
38#[repr(C)]
39pub struct CIrType {
40    _private: [u8; 0], // Ensures the struct cannot be instantiated
41}
42
43#[repr(C)]
44pub struct CIrFunctionType {
45    _private: [u8; 0], // Ensures the struct cannot be instantiated
46}
47
48// "VAST" is the "Verilog AST" API which
49#[repr(C)]
50pub struct CVastFile {
51    _private: [u8; 0], // Ensures the struct cannot be instantiated
52}
53
54#[repr(C)]
55pub struct CVastModule {
56    _private: [u8; 0], // Ensures the struct cannot be instantiated
57}
58
59#[repr(C)]
60pub struct CVastDataType {
61    _private: [u8; 0], // Ensures the struct cannot be instantiated
62}
63
64#[repr(C)]
65pub struct CVastExpression {
66    _private: [u8; 0], // Ensures the struct cannot be instantiated
67}
68
69#[repr(C)]
70pub struct CVastLiteral {
71    _private: [u8; 0], // Ensures the struct cannot be instantiated
72}
73
74#[repr(C)]
75pub struct CVastLogicRef {
76    _private: [u8; 0], // Ensures the struct cannot be instantiated
77}
78
79#[repr(C)]
80pub struct CVastInstantiation {
81    _private: [u8; 0], // Ensures the struct cannot be instantiated
82}
83
84#[repr(C)]
85pub struct CVastContinuousAssignment {
86    _private: [u8; 0], // Ensures the struct cannot be instantiated
87}
88
89#[repr(C)]
90pub struct CVastSlice {
91    _private: [u8; 0], // Ensures the struct cannot be instantiated
92}
93
94#[repr(C)]
95pub struct CVastIndex {
96    _private: [u8; 0], // Ensures the struct cannot be instantiated
97}
98
99#[repr(C)]
100pub struct CVastIndexableExpression {
101    _private: [u8; 0], // Ensures the struct cannot be instantiated
102}
103
104#[repr(C)]
105pub struct CVastAlwaysBase {
106    _private: [u8; 0], // Ensures the struct cannot be instantiated
107}
108
109#[repr(C)]
110pub struct CVastStatementBlock {
111    _private: [u8; 0], // Ensures the struct cannot be instantiated
112}
113
114#[repr(C)]
115pub struct CVastStatement {
116    _private: [u8; 0], // Ensures the struct cannot be instantiated
117}
118
119// -- DSLX
120
121#[repr(C)]
122pub struct CDslxImportData {
123    _private: [u8; 0], // Ensures the struct cannot be instantiated
124}
125
126#[repr(C)]
127pub struct CDslxTypecheckedModule {
128    _private: [u8; 0], // Ensures the struct cannot be instantiated
129}
130
131#[repr(C)]
132pub struct CDslxModule {
133    _private: [u8; 0], // Ensures the struct cannot be instantiated
134}
135
136#[repr(C)]
137pub struct CDslxTypeInfo {
138    _private: [u8; 0], // Ensures the struct cannot be instantiated
139}
140
141#[repr(C)]
142pub struct CDslxStructDef {
143    _private: [u8; 0], // Ensures the struct cannot be instantiated
144}
145
146#[repr(C)]
147pub struct CDslxEnumDef {
148    _private: [u8; 0], // Ensures the struct cannot be instantiated
149}
150
151#[repr(C)]
152pub struct CDslxTypeAlias {
153    _private: [u8; 0], // Ensures the struct cannot be instantiated
154}
155
156#[repr(C)]
157pub struct CDslxType {
158    _private: [u8; 0], // Ensures the struct cannot be instantiated
159}
160
161#[repr(C)]
162pub struct CDslxTypeDim {
163    _private: [u8; 0], // Ensures the struct cannot be instantiated
164}
165
166#[repr(C)]
167pub struct CDslxExpr {
168    _private: [u8; 0], // Ensures the struct cannot be instantiated
169}
170
171#[repr(C)]
172pub struct CDslxInterpValue {
173    _private: [u8; 0], // Ensures the struct cannot be instantiated
174}
175
176#[repr(C)]
177pub struct CDslxEnumMember {
178    _private: [u8; 0], // Ensures the struct cannot be instantiated
179}
180
181#[repr(C)]
182pub struct CDslxStructMember {
183    _private: [u8; 0], // Ensures the struct cannot be instantiated
184}
185
186#[repr(C)]
187pub struct CDslxTypeAnnotation {
188    _private: [u8; 0], // Ensures the struct cannot be instantiated
189}
190
191#[repr(C)]
192pub struct CDslxTypeRefTypeAnnotation {
193    _private: [u8; 0], // Ensures the struct cannot be instantiated
194}
195
196#[repr(C)]
197pub struct CDslxTypeRef {
198    _private: [u8; 0], // Ensures the struct cannot be instantiated
199}
200
201#[repr(C)]
202pub struct CDslxImport {
203    _private: [u8; 0], // Ensures the struct cannot be instantiated
204}
205
206#[repr(C)]
207pub struct CDslxColonRef {
208    _private: [u8; 0], // Ensures the struct cannot be instantiated
209}
210
211#[repr(C)]
212pub struct CDslxTypeDefinition {
213    _private: [u8; 0], // Ensures the struct cannot be instantiated
214}
215
216#[repr(C)]
217pub struct CDslxConstantDef {
218    _private: [u8; 0], // Ensures the struct cannot be instantiated
219}
220
221#[repr(C)]
222pub struct CDslxModuleMember {
223    _private: [u8; 0], // Ensures the struct cannot be instantiated
224}
225
226#[repr(C)]
227pub struct CDslxFunction {
228    _private: [u8; 0], // Ensures the struct cannot be instantiated
229}
230
231#[repr(C)]
232pub struct CDslxQuickcheck {
233    _private: [u8; 0], // Ensures the struct cannot be instantiated
234}
235
236#[repr(C)]
237pub struct CScheduleAndCodegenResult {
238    _private: [u8; 0], // Ensures the struct cannot be instantiated
239}
240
241#[repr(C)]
242pub struct CIrBuilderBase {
243    _private: [u8; 0], // Ensures the struct cannot be instantiated
244}
245
246#[repr(C)]
247pub struct CIrBValue {
248    _private: [u8; 0], // Ensures the struct cannot be instantiated
249}
250
251#[repr(C)]
252pub struct CIrFunctionBuilder {
253    _private: [u8; 0], // Ensures the struct cannot be instantiated
254}
255
256pub type XlsFormatPreference = i32;
257
258pub type VastFileType = i32;
259
260pub type VastOperatorKind = i32;
261
262pub type DslxTypeDefinitionKind = i32;
263
264pub type DslxModuleMemberKind = i32;
265
266extern "C" {
267    pub fn xls_convert_dslx_to_ir(
268        dslx: *const std::os::raw::c_char,
269        path: *const std::os::raw::c_char,
270        module_name: *const std::os::raw::c_char,
271        dslx_stdlib_path: *const std::os::raw::c_char,
272        additional_search_paths: *const *const std::os::raw::c_char,
273        additional_search_paths_count: libc::size_t,
274        error_out: *mut *mut std::os::raw::c_char,
275        ir_out: *mut *mut std::os::raw::c_char,
276    ) -> bool;
277
278    pub fn xls_convert_dslx_to_ir_with_warnings(
279        dslx: *const std::os::raw::c_char,
280        path: *const std::os::raw::c_char,
281        module_name: *const std::os::raw::c_char,
282        dslx_stdlib_path: *const std::os::raw::c_char,
283        additional_search_paths: *const *const std::os::raw::c_char,
284        additional_search_paths_count: libc::size_t,
285        enable_warnings: *const *const std::os::raw::c_char,
286        enable_warnings_count: libc::size_t,
287        disable_warnings: *const *const std::os::raw::c_char,
288        disable_warnings_count: libc::size_t,
289        warnings_as_errors: bool,
290        warnings_out: *mut *mut *mut std::os::raw::c_char,
291        warnings_out_count: *mut libc::size_t,
292        error_out: *mut *mut std::os::raw::c_char,
293        ir_out: *mut *mut std::os::raw::c_char,
294    ) -> bool;
295
296    pub fn xls_parse_typed_value(
297        text: *const std::os::raw::c_char,
298        error_out: *mut *mut std::os::raw::c_char,
299        value_out: *mut *mut CIrValue,
300    ) -> bool;
301    pub fn xls_value_free(value: *mut CIrValue);
302
303    pub fn xls_value_clone(value: *const CIrValue) -> *mut CIrValue;
304
305    // Extracts a bits value from a (boxed) value or gives an error.
306    pub fn xls_value_get_bits(
307        value: *const CIrValue,
308        error_out: *mut *mut std::os::raw::c_char,
309        bits_out: *mut *mut CIrBits,
310    ) -> bool;
311
312    // Turns a span of IR values into a tuple value.
313    pub fn xls_value_make_tuple(
314        value_count: libc::size_t,
315        values: *const *const CIrValue,
316    ) -> *mut CIrValue;
317
318    // Create a token value
319    pub fn xls_value_make_token() -> *mut CIrValue;
320
321    /// Returns an error:
322    /// * if the elements do not all have the same type, or
323    /// * if the array is empty (because then we cannot determine the element
324    ///   type)
325    pub fn xls_value_make_array(
326        element_count: libc::size_t,
327        elements: *const *const CIrValue,
328        error_out: *mut *mut std::os::raw::c_char,
329        result_out: *mut *mut CIrValue,
330    ) -> bool;
331
332    // Extracts an element from a tuple/array value or gives an error (e.g. if this
333    // value is not a tuple/array or the index is out of bounds).
334    pub fn xls_value_get_element(
335        tuple: *const CIrValue,
336        index: libc::size_t,
337        error_out: *mut *mut std::os::raw::c_char,
338        element_out: *mut *mut CIrValue,
339    ) -> bool;
340
341    pub fn xls_value_get_element_count(
342        value: *const CIrValue,
343        error_out: *mut *mut std::os::raw::c_char,
344        count_out: *mut i64,
345    ) -> bool;
346
347    // Creates a bits value (via an unsigned integer) that is boxed in an IrValue.
348    pub fn xls_value_make_ubits(
349        bit_count: i64,
350        value: u64,
351        error_out: *mut *mut std::os::raw::c_char,
352        result_out: *mut *mut CIrValue,
353    ) -> bool;
354
355    // Creates a bits value (via a signed integer) that is boxed in an IrValue.
356    pub fn xls_value_make_sbits(
357        bit_count: i64,
358        value: i64,
359        error_out: *mut *mut std::os::raw::c_char,
360        result_out: *mut *mut CIrValue,
361    ) -> bool;
362
363    // Boxes an IR bits object into an IR value.
364    pub fn xls_value_from_bits(bits: *const CIrBits) -> *mut CIrValue;
365
366    pub fn xls_bits_make_ubits(
367        bit_count: i64,
368        value: u64,
369        error_out: *mut *mut std::os::raw::c_char,
370        bits_out: *mut *mut CIrBits,
371    ) -> bool;
372
373    pub fn xls_bits_make_sbits(
374        bit_count: i64,
375        value: i64,
376        error_out: *mut *mut std::os::raw::c_char,
377        bits_out: *mut *mut CIrBits,
378    ) -> bool;
379
380    pub fn xls_bits_free(bits: *mut CIrBits);
381    pub fn xls_bits_get_bit_count(bits: *const CIrBits) -> i64;
382    pub fn xls_bits_get_bit(bits: *const CIrBits, index: i64) -> bool;
383    pub fn xls_bits_eq(bits: *const CIrBits, other: *const CIrBits) -> bool;
384    pub fn xls_bits_to_debug_string(bits: *const CIrBits) -> *mut std::os::raw::c_char;
385    pub fn xls_bits_add(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
386    pub fn xls_bits_umul(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
387    pub fn xls_bits_smul(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
388    pub fn xls_bits_negate(bits: *const CIrBits) -> *mut CIrBits;
389    pub fn xls_bits_abs(bits: *const CIrBits) -> *mut CIrBits;
390    pub fn xls_bits_not(bits: *const CIrBits) -> *mut CIrBits;
391    pub fn xls_bits_and(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
392    pub fn xls_bits_or(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
393    pub fn xls_bits_xor(lhs: *const CIrBits, rhs: *const CIrBits) -> *mut CIrBits;
394
395    pub fn xls_bits_shift_left_logical(bits: *const CIrBits, shift_amount: i64) -> *mut CIrBits;
396    pub fn xls_bits_shift_right_logical(bits: *const CIrBits, shift_amount: i64) -> *mut CIrBits;
397    pub fn xls_bits_shift_right_arithmetic(bits: *const CIrBits, shift_amount: i64)
398        -> *mut CIrBits;
399
400    // struct xls_bits* xls_bits_width_slice(const struct xls_bits* bits, int64_t
401    // start, int64_t width);
402
403    pub fn xls_bits_width_slice(bits: *const CIrBits, start: i64, width: i64) -> *mut CIrBits;
404
405    pub fn xls_package_free(package: *mut CIrPackage);
406    pub fn xls_c_str_free(c_str: *mut std::os::raw::c_char);
407    pub fn xls_c_strs_free(c_strs: *mut *mut std::os::raw::c_char, count: libc::size_t);
408    pub fn xls_value_to_string(
409        value: *const CIrValue,
410        str_out: *mut *mut std::os::raw::c_char,
411    ) -> bool;
412    pub fn xls_format_preference_from_string(
413        s: *const std::os::raw::c_char,
414        error_out: *mut *mut std::os::raw::c_char,
415        result_out: *mut XlsFormatPreference,
416    ) -> bool;
417
418    pub fn xls_value_to_string_format_preference(
419        value: *const CIrValue,
420        fmt: XlsFormatPreference,
421        error_out: *mut *mut std::os::raw::c_char,
422        str_out: *mut *mut std::os::raw::c_char,
423    ) -> bool;
424    pub fn xls_bits_to_string(
425        bits: *const CIrBits,
426        fmt: XlsFormatPreference,
427        include_bit_count: bool,
428        error_out: *mut *mut std::os::raw::c_char,
429        str_out: *mut *mut std::os::raw::c_char,
430    ) -> bool;
431
432    pub fn xls_value_eq(value: *const CIrValue, value: *const CIrValue) -> bool;
433    pub fn xls_parse_ir_package(
434        ir: *const std::os::raw::c_char,
435        filename: *const std::os::raw::c_char,
436        error_out: *mut *mut std::os::raw::c_char,
437        xls_package_out: *mut *mut CIrPackage,
438    ) -> bool;
439    pub fn xls_type_to_string(
440        t: *const CIrType,
441        error_out: *mut *mut std::os::raw::c_char,
442        result_out: *mut *mut std::os::raw::c_char,
443    ) -> bool;
444    pub fn xls_type_get_flat_bit_count(t: *const CIrType) -> i64;
445    pub fn xls_package_get_type_for_value(
446        package: *const CIrPackage,
447        value: *const CIrValue,
448        error_out: *mut *mut std::os::raw::c_char,
449        result_out: *mut *mut CIrType,
450    ) -> bool;
451    pub fn xls_package_get_function(
452        package: *const CIrPackage,
453        function_name: *const std::os::raw::c_char,
454        error_out: *mut *mut std::os::raw::c_char,
455        result_out: *mut *mut CIrFunction,
456    ) -> bool;
457    pub fn xls_function_get_type(
458        function: *const CIrFunction,
459        error_out: *mut *mut std::os::raw::c_char,
460        xls_fn_type_out: *mut *mut CIrFunctionType,
461    ) -> bool;
462    pub fn xls_function_type_to_string(
463        t: *const CIrFunctionType,
464        error_out: *mut *mut std::os::raw::c_char,
465        string_out: *mut *mut std::os::raw::c_char,
466    ) -> bool;
467    pub fn xls_function_get_name(
468        function: *const CIrFunction,
469        error_out: *mut *mut std::os::raw::c_char,
470        name_out: *mut *mut std::os::raw::c_char,
471    ) -> bool;
472    pub fn xls_interpret_function(
473        function: *const CIrFunction,
474        argc: libc::size_t,
475        args: *const *const CIrValue,
476        error_out: *mut *mut std::os::raw::c_char,
477        result_out: *mut *mut CIrValue,
478    ) -> bool;
479    pub fn xls_optimize_ir(
480        ir: *const std::os::raw::c_char,
481        top: *const std::os::raw::c_char,
482        error_out: *mut *mut std::os::raw::c_char,
483        ir_out: *mut *mut std::os::raw::c_char,
484    ) -> bool;
485    pub fn xls_mangle_dslx_name(
486        module_name: *const std::os::raw::c_char,
487        function_name: *const std::os::raw::c_char,
488        error_out: *mut *mut std::os::raw::c_char,
489        mangled_out: *mut *mut std::os::raw::c_char,
490    ) -> bool;
491    pub fn xls_package_to_string(
492        p: *const CIrPackage,
493        string_out: *mut *mut std::os::raw::c_char,
494    ) -> bool;
495    pub fn xls_package_set_top_by_name(
496        p: *mut CIrPackage,
497        name: *const std::os::raw::c_char,
498        error_out: *mut *mut std::os::raw::c_char,
499    ) -> bool;
500
501    pub fn xls_make_function_jit(
502        function: *const CIrFunction,
503        error_out: *mut *mut std::os::raw::c_char,
504        result_out: *mut *mut CIrFunctionJit,
505    ) -> bool;
506    pub fn xls_function_jit_free(jit: *mut CIrFunctionJit);
507    pub fn xls_function_jit_run(
508        jit: *const CIrFunctionJit,
509        argc: libc::size_t,
510        args: *const *const CIrValue,
511        error_out: *mut *mut std::os::raw::c_char,
512        trace_messages_out: *mut *mut CTraceMessage,
513        trace_messages_count_out: *mut libc::size_t,
514        assert_messages_out: *mut *mut *mut std::os::raw::c_char,
515        assert_messages_count_out: *mut libc::size_t,
516        result_out: *mut *mut CIrValue,
517    ) -> bool;
518    pub fn xls_trace_messages_free(trace_messages: *mut CTraceMessage, count: libc::size_t);
519
520    // -- VAST APIs
521
522    pub fn xls_vast_make_verilog_file(file_type: VastFileType) -> *mut CVastFile;
523    pub fn xls_vast_verilog_file_free(f: *mut CVastFile);
524    pub fn xls_vast_verilog_file_add_module(
525        f: *mut CVastFile,
526        name: *const std::os::raw::c_char,
527    ) -> *mut CVastModule;
528
529    // - Node creation
530    pub fn xls_vast_verilog_file_make_scalar_type(f: *mut CVastFile) -> *mut CVastDataType;
531    pub fn xls_vast_verilog_file_make_bit_vector_type(
532        f: *mut CVastFile,
533        bit_count: i64,
534        is_signed: bool,
535    ) -> *mut CVastDataType;
536    pub fn xls_vast_verilog_file_make_extern_package_type(
537        f: *mut CVastFile,
538        package_name: *const std::os::raw::c_char,
539        type_name: *const std::os::raw::c_char,
540    ) -> *mut CVastDataType;
541    pub fn xls_vast_verilog_file_make_packed_array_type(
542        f: *mut CVastFile,
543        element_type: *mut CVastDataType,
544        dims: *const i64,
545        dim_count: libc::size_t,
546    ) -> *mut CVastDataType;
547
548    pub fn xls_vast_verilog_file_make_continuous_assignment(
549        f: *mut CVastFile,
550        lhs: *mut CVastExpression,
551        rhs: *mut CVastExpression,
552    ) -> *mut CVastContinuousAssignment;
553
554    pub fn xls_vast_verilog_file_make_concat(
555        f: *mut CVastFile,
556        expressions: *mut *mut CVastExpression,
557        expression_count: libc::size_t,
558    ) -> *mut CVastExpression;
559
560    pub fn xls_vast_verilog_file_make_slice_i64(
561        f: *mut CVastFile,
562        subject: *mut CVastIndexableExpression,
563        hi: i64,
564        lo: i64,
565    ) -> *mut CVastSlice;
566
567    pub fn xls_vast_verilog_file_make_index(
568        f: *mut CVastFile,
569        subject: *mut CVastIndexableExpression,
570        index: *mut CVastExpression,
571    ) -> *mut CVastIndex;
572    pub fn xls_vast_verilog_file_make_index_i64(
573        f: *mut CVastFile,
574        subject: *mut CVastIndexableExpression,
575        index: i64,
576    ) -> *mut CVastIndex;
577
578    pub fn xls_vast_verilog_file_make_unary(
579        f: *mut CVastFile,
580        arg: *mut CVastExpression,
581        op: VastOperatorKind,
582    ) -> *mut CVastExpression;
583
584    pub fn xls_vast_verilog_file_make_binary(
585        f: *mut CVastFile,
586        lhs: *mut CVastExpression,
587        rhs: *mut CVastExpression,
588        op: VastOperatorKind,
589    ) -> *mut CVastExpression;
590
591    pub fn xls_vast_verilog_file_make_ternary(
592        f: *mut CVastFile,
593        cond: *mut CVastExpression,
594        then_expr: *mut CVastExpression,
595        else_expr: *mut CVastExpression,
596    ) -> *mut CVastExpression;
597
598    pub fn xls_vast_verilog_file_make_instantiation(
599        f: *mut CVastFile,
600        module_name: *const std::os::raw::c_char,
601        instance_name: *const std::os::raw::c_char,
602        parameter_port_names: *const *const std::os::raw::c_char,
603        parameter_expressions: *const *const CVastExpression,
604        parameter_count: libc::size_t,
605        connection_port_names: *const *const std::os::raw::c_char,
606        connection_expressions: *const *const CVastExpression,
607        connection_count: libc::size_t,
608    ) -> *mut CVastInstantiation;
609    pub fn xls_vast_verilog_file_make_literal(
610        f: *mut CVastFile,
611        bits: *const CIrBits,
612        format_preference: XlsFormatPreference,
613        emit_bit_count: bool,
614        error_out: *mut *mut std::os::raw::c_char,
615        literal_out: *mut *mut CVastLiteral,
616    ) -> bool;
617
618    // - Module additions
619    pub fn xls_vast_verilog_module_add_input(
620        m: *mut CVastModule,
621        name: *const std::os::raw::c_char,
622        type_: *mut CVastDataType,
623    ) -> *mut CVastLogicRef;
624    pub fn xls_vast_verilog_module_add_output(
625        m: *mut CVastModule,
626        name: *const std::os::raw::c_char,
627        type_: *mut CVastDataType,
628    ) -> *mut CVastLogicRef;
629    pub fn xls_vast_verilog_module_add_wire(
630        m: *mut CVastModule,
631        name: *const std::os::raw::c_char,
632        type_: *mut CVastDataType,
633    ) -> *mut CVastLogicRef;
634    pub fn xls_vast_verilog_module_add_member_instantiation(
635        m: *mut CVastModule,
636        inst: *mut CVastInstantiation,
637    );
638    pub fn xls_vast_verilog_module_add_member_continuous_assignment(
639        m: *mut CVastModule,
640        ca: *mut CVastContinuousAssignment,
641    );
642
643    // - Expression conversions
644    pub fn xls_vast_logic_ref_as_indexable_expression(
645        v: *mut CVastLogicRef,
646    ) -> *mut CVastIndexableExpression;
647    pub fn xls_vast_index_as_indexable_expression(
648        v: *mut CVastIndex,
649    ) -> *mut CVastIndexableExpression;
650
651    pub fn xls_vast_literal_as_expression(v: *mut CVastLiteral) -> *mut CVastExpression;
652    pub fn xls_vast_logic_ref_as_expression(v: *mut CVastLogicRef) -> *mut CVastExpression;
653    pub fn xls_vast_slice_as_expression(v: *mut CVastSlice) -> *mut CVastExpression;
654    pub fn xls_vast_index_as_expression(v: *mut CVastIndex) -> *mut CVastExpression;
655
656    pub fn xls_vast_verilog_file_add_include(f: *mut CVastFile, path: *const std::os::raw::c_char);
657    pub fn xls_vast_verilog_file_emit(f: *const CVastFile) -> *mut std::os::raw::c_char;
658
659    // -- DSLX
660
661    pub fn xls_dslx_import_data_create(
662        dslx_stdlib_path: *const std::os::raw::c_char,
663        additional_search_paths: *const *const std::os::raw::c_char,
664        additional_search_paths_count: libc::size_t,
665    ) -> *mut CDslxImportData;
666    pub fn xls_dslx_import_data_free(data: *mut CDslxImportData);
667
668    pub fn xls_dslx_parse_and_typecheck(
669        text: *const std::os::raw::c_char,
670        path: *const std::os::raw::c_char,
671        module_name: *const std::os::raw::c_char,
672        import_data: *const CDslxImportData,
673        error_out: *mut *mut std::os::raw::c_char,
674        typechecked_module_out: *mut *mut CDslxTypecheckedModule,
675    ) -> bool;
676
677    // bool xls_schedule_and_codegen_package(
678    // struct xls_package* p, const char* scheduling_options_flags_proto,
679    // const char* codegen_flags_proto, bool with_delay_model, char** error_out,
680    // struct xls_schedule_and_codegen_result** result_out);
681    pub fn xls_schedule_and_codegen_package(
682        p: *mut CIrPackage,
683        scheduling_options_flags_proto: *const std::os::raw::c_char,
684        codegen_flags_proto: *const std::os::raw::c_char,
685        with_delay_model: bool,
686        error_out: *mut *mut std::os::raw::c_char,
687        result_out: *mut *mut CScheduleAndCodegenResult,
688    ) -> bool;
689
690    pub fn xls_schedule_and_codegen_result_get_verilog_text(
691        result: *mut CScheduleAndCodegenResult,
692    ) -> *mut std::os::raw::c_char;
693
694    pub fn xls_schedule_and_codegen_result_free(result: *mut CScheduleAndCodegenResult);
695
696    pub fn xls_dslx_typechecked_module_free(module: *mut CDslxTypecheckedModule);
697
698    pub fn xls_dslx_typechecked_module_get_module(
699        module: *mut CDslxTypecheckedModule,
700    ) -> *mut CDslxModule;
701
702    pub fn xls_dslx_typechecked_module_get_type_info(
703        module: *mut CDslxTypecheckedModule,
704    ) -> *mut CDslxTypeInfo;
705
706    pub fn xls_dslx_module_get_name(module: *const CDslxModule) -> *mut std::os::raw::c_char;
707
708    pub fn xls_dslx_module_get_type_definition_count(module: *const CDslxModule) -> i64;
709
710    pub fn xls_dslx_module_get_member_count(module: *const CDslxModule) -> i64;
711
712    pub fn xls_dslx_module_get_member(module: *const CDslxModule, i: i64)
713        -> *mut CDslxModuleMember;
714
715    pub fn xls_dslx_module_get_type_definition_kind(
716        module: *const CDslxModule,
717        i: i64,
718    ) -> DslxTypeDefinitionKind;
719
720    pub fn xls_dslx_module_get_type_definition_as_struct_def(
721        module: *const CDslxModule,
722        i: i64,
723    ) -> *mut CDslxStructDef;
724    pub fn xls_dslx_module_get_type_definition_as_enum_def(
725        module: *const CDslxModule,
726        i: i64,
727    ) -> *mut CDslxEnumDef;
728    pub fn xls_dslx_module_get_type_definition_as_type_alias(
729        module: *const CDslxModule,
730        i: i64,
731    ) -> *mut CDslxTypeAlias;
732
733    // -- xls_dslx_module_member
734    pub fn xls_dslx_module_member_get_kind(
735        member: *const CDslxModuleMember,
736    ) -> DslxModuleMemberKind;
737    pub fn xls_dslx_module_member_get_constant_def(
738        member: *const CDslxModuleMember,
739    ) -> *mut CDslxConstantDef;
740    pub fn xls_dslx_module_member_get_type_alias(
741        member: *const CDslxModuleMember,
742    ) -> *mut CDslxTypeAlias;
743    pub fn xls_dslx_module_member_get_struct_def(
744        member: *const CDslxModuleMember,
745    ) -> *mut CDslxStructDef;
746    pub fn xls_dslx_module_member_get_enum_def(
747        member: *const CDslxModuleMember,
748    ) -> *mut CDslxEnumDef;
749
750    pub fn xls_dslx_colon_ref_get_attr(
751        colon_ref: *const CDslxColonRef,
752    ) -> *mut std::os::raw::c_char;
753
754    pub fn xls_dslx_type_info_get_type_struct_def(
755        type_info: *mut CDslxTypeInfo,
756        node: *mut CDslxStructDef,
757    ) -> *mut CDslxType;
758    pub fn xls_dslx_type_info_get_type_enum_def(
759        type_info: *mut CDslxTypeInfo,
760        node: *mut CDslxEnumDef,
761    ) -> *mut CDslxType;
762    pub fn xls_dslx_type_info_get_type_struct_member(
763        type_info: *mut CDslxTypeInfo,
764        member: *mut CDslxStructMember,
765    ) -> *mut CDslxType;
766    pub fn xls_dslx_type_info_get_type_type_alias(
767        type_info: *mut CDslxTypeInfo,
768        node: *mut CDslxTypeAlias,
769    ) -> *mut CDslxType;
770    pub fn xls_dslx_type_info_get_type_constant_def(
771        type_info: *mut CDslxTypeInfo,
772        node: *mut CDslxConstantDef,
773    ) -> *mut CDslxType;
774
775    /// Gets the concrete type for a TypeAnnotation AST node.
776    pub fn xls_dslx_type_info_get_type_type_annotation(
777        type_info: *mut CDslxTypeInfo,
778        type_annotation: *mut CDslxTypeAnnotation,
779    ) -> *mut CDslxType;
780
781    // -- ConstantDef
782
783    pub fn xls_dslx_constant_def_get_name(
784        constant_def: *const CDslxConstantDef,
785    ) -> *mut std::os::raw::c_char;
786
787    pub fn xls_dslx_constant_def_get_value(constant_def: *const CDslxConstantDef)
788        -> *mut CDslxExpr;
789
790    // -- TypeAlias
791
792    pub fn xls_dslx_type_alias_get_identifier(
793        type_alias: *const CDslxTypeAlias,
794    ) -> *mut std::os::raw::c_char;
795
796    pub fn xls_dslx_type_alias_get_type_annotation(
797        type_alias: *const CDslxTypeAlias,
798    ) -> *mut CDslxTypeAnnotation;
799
800    // -- TypeAnnotation
801
802    pub fn xls_dslx_type_annotation_get_type_ref_type_annotation(
803        type_annotation: *const CDslxTypeAnnotation,
804    ) -> *mut CDslxTypeRefTypeAnnotation;
805
806    // -- TypeRef
807
808    pub fn xls_dslx_type_ref_get_type_definition(
809        type_ref: *const CDslxTypeRef,
810    ) -> *mut CDslxTypeDefinition;
811
812    // -- Import
813
814    pub fn xls_dslx_import_get_subject_count(import: *const CDslxImport) -> i64;
815    pub fn xls_dslx_import_get_subject(
816        import: *const CDslxImport,
817        i: i64,
818    ) -> *mut std::os::raw::c_char;
819
820    // -- ColonRef
821
822    pub fn xls_dslx_colon_ref_resolve_import_subject(
823        colon_ref: *const CDslxColonRef,
824    ) -> *mut CDslxImport;
825
826    // -- TypeDefinition
827
828    pub fn xls_dslx_type_definition_get_colon_ref(
829        type_definition: *const CDslxTypeDefinition,
830    ) -> *mut CDslxColonRef;
831    pub fn xls_dslx_type_definition_get_type_alias(
832        type_definition: *const CDslxTypeDefinition,
833    ) -> *mut CDslxTypeAlias;
834
835    // -- TypeRefTypeAnnotation
836
837    pub fn xls_dslx_type_ref_type_annotation_get_type_ref(
838        type_ref_type_annotation: *const CDslxTypeRefTypeAnnotation,
839    ) -> *mut CDslxTypeRef;
840
841    // -- StructDef
842
843    pub fn xls_dslx_struct_def_get_identifier(
844        struct_def: *const CDslxStructDef,
845    ) -> *mut std::os::raw::c_char;
846
847    pub fn xls_dslx_struct_def_is_parametric(struct_def: *const CDslxStructDef) -> bool;
848
849    pub fn xls_dslx_struct_def_get_member_count(struct_def: *const CDslxStructDef) -> i64;
850
851    pub fn xls_dslx_struct_def_get_member(
852        struct_def: *const CDslxStructDef,
853        i: i64,
854    ) -> *mut CDslxStructMember;
855
856    pub fn xls_dslx_struct_member_get_name(
857        member: *const CDslxStructMember,
858    ) -> *mut std::os::raw::c_char;
859
860    pub fn xls_dslx_struct_member_get_type(
861        member: *const CDslxStructMember,
862    ) -> *mut CDslxTypeAnnotation;
863
864    // -- EnumDef
865
866    pub fn xls_dslx_enum_def_get_identifier(
867        enum_def: *const CDslxEnumDef,
868    ) -> *mut std::os::raw::c_char;
869
870    pub fn xls_dslx_enum_def_get_member_count(enum_def: *const CDslxEnumDef) -> i64;
871
872    pub fn xls_dslx_enum_def_get_member(
873        enum_def: *const CDslxEnumDef,
874        i: i64,
875    ) -> *mut CDslxEnumMember;
876
877    pub fn xls_dslx_enum_def_get_underlying(
878        enum_def: *const CDslxEnumDef,
879    ) -> *mut CDslxTypeAnnotation;
880
881    pub fn xls_dslx_enum_member_get_name(
882        member: *const CDslxEnumMember,
883    ) -> *mut std::os::raw::c_char;
884
885    pub fn xls_dslx_enum_member_get_value(member: *const CDslxEnumMember) -> *mut CDslxExpr;
886
887    // --
888
889    pub fn xls_dslx_interp_value_free(value: *mut CDslxInterpValue);
890
891    pub fn xls_dslx_interp_value_convert_to_ir(
892        value: *mut CDslxInterpValue,
893        error_out: *mut *mut std::os::raw::c_char,
894        result_out: *mut *mut CIrValue,
895    ) -> bool;
896
897    pub fn xls_dslx_type_to_string(
898        type_: *const CDslxType,
899        error_out: *mut *mut std::os::raw::c_char,
900        result_out: *mut *mut std::os::raw::c_char,
901    ) -> bool;
902
903    pub fn xls_dslx_type_info_get_const_expr(
904        type_info: *mut CDslxTypeInfo,
905        expr: *mut CDslxExpr,
906        error_out: *mut *mut std::os::raw::c_char,
907        result_out: *mut *mut CDslxInterpValue,
908    ) -> bool;
909
910    pub fn xls_dslx_type_get_total_bit_count(
911        type_: *const CDslxType,
912        error_out: *mut *mut std::os::raw::c_char,
913        result_out: *mut i64,
914    ) -> bool;
915
916    pub fn xls_dslx_type_is_signed_bits(
917        type_: *const CDslxType,
918        error_out: *mut *mut std::os::raw::c_char,
919        result_out: *mut bool,
920    ) -> bool;
921
922    pub fn xls_dslx_type_is_bits_like(
923        type_: *const CDslxType,
924        is_signed: *mut *mut CDslxTypeDim,
925        size: *mut *mut CDslxTypeDim,
926    ) -> bool;
927
928    pub fn xls_dslx_type_is_enum(type_: *const CDslxType) -> bool;
929    pub fn xls_dslx_type_is_struct(type_: *const CDslxType) -> bool;
930    pub fn xls_dslx_type_is_array(type_: *const CDslxType) -> bool;
931
932    pub fn xls_dslx_type_dim_is_parametric(dim: *const CDslxTypeDim) -> bool;
933    pub fn xls_dslx_type_dim_get_as_bool(
934        dim: *const CDslxTypeDim,
935        error_out: *mut *mut std::os::raw::c_char,
936        result_out: *mut bool,
937    ) -> bool;
938    pub fn xls_dslx_type_dim_get_as_int64(
939        dim: *const CDslxTypeDim,
940        error_out: *mut *mut std::os::raw::c_char,
941        result_out: *mut i64,
942    ) -> bool;
943    pub fn xls_dslx_type_dim_free(dim: *mut CDslxTypeDim);
944
945    pub fn xls_dslx_type_get_enum_def(ty: *const CDslxType) -> *mut CDslxEnumDef;
946
947    pub fn xls_dslx_type_get_struct_def(ty: *const CDslxType) -> *mut CDslxStructDef;
948
949    pub fn xls_dslx_type_array_get_element_type(ty: *const CDslxType) -> *mut CDslxType;
950    pub fn xls_dslx_type_array_get_size(ty: *const CDslxType) -> *mut CDslxTypeDim;
951
952    // -- IR builder APIs
953
954    pub fn xls_package_create(name: *const std::os::raw::c_char) -> *mut CIrPackage;
955    pub fn xls_package_get_bits_type(package: *mut CIrPackage, bit_count: i64) -> *mut CIrType;
956
957    pub fn xls_package_get_tuple_type(
958        package: *mut CIrPackage,
959        members: *mut *mut CIrType,
960        member_count: i64,
961    ) -> *mut CIrType;
962
963    pub fn xls_package_get_array_type(
964        package: *mut CIrPackage,
965        element_type: *mut CIrType,
966        size: i64,
967    ) -> *mut CIrType;
968
969    pub fn xls_package_get_token_type(package: *mut CIrPackage) -> *mut CIrType;
970
971    pub fn xls_function_builder_create(
972        name: *const std::os::raw::c_char,
973        package: *mut CIrPackage,
974        should_verify: bool,
975    ) -> *mut CIrFunctionBuilder;
976    pub fn xls_function_builder_as_builder_base(
977        builder: *mut CIrFunctionBuilder,
978    ) -> *mut CIrBuilderBase;
979    pub fn xls_function_builder_free(builder: *mut CIrFunctionBuilder);
980    pub fn xls_bvalue_free(bvalue: *mut CIrBValue);
981    pub fn xls_function_builder_add_parameter(
982        builder: *mut CIrFunctionBuilder,
983        name: *const std::os::raw::c_char,
984        type_: *mut CIrType,
985    ) -> *mut CIrBValue;
986    pub fn xls_function_builder_build(
987        builder: *mut CIrFunctionBuilder,
988        error_out: *mut *mut std::os::raw::c_char,
989        function_out: *mut *mut CIrFunction,
990    ) -> bool;
991    pub fn xls_function_builder_build_with_return_value(
992        builder: *mut CIrFunctionBuilder,
993        return_value: *mut CIrBValue,
994        error_out: *mut *mut std::os::raw::c_char,
995        function_out: *mut *mut CIrFunction,
996    ) -> bool;
997    pub fn xls_builder_base_add_and(
998        builder: *mut CIrBuilderBase,
999        lhs: *mut CIrBValue,
1000        rhs: *mut CIrBValue,
1001        name: *const std::os::raw::c_char,
1002    ) -> *mut CIrBValue;
1003    pub fn xls_builder_base_add_nand(
1004        builder: *mut CIrBuilderBase,
1005        lhs: *mut CIrBValue,
1006        rhs: *mut CIrBValue,
1007        name: *const std::os::raw::c_char,
1008    ) -> *mut CIrBValue;
1009    pub fn xls_builder_base_add_or(
1010        builder: *mut CIrBuilderBase,
1011        lhs: *mut CIrBValue,
1012        rhs: *mut CIrBValue,
1013        name: *const std::os::raw::c_char,
1014    ) -> *mut CIrBValue;
1015    pub fn xls_builder_base_add_xor(
1016        builder: *mut CIrBuilderBase,
1017        lhs: *mut CIrBValue,
1018        rhs: *mut CIrBValue,
1019        name: *const std::os::raw::c_char,
1020    ) -> *mut CIrBValue;
1021    pub fn xls_builder_base_add_not(
1022        builder: *mut CIrBuilderBase,
1023        value: *mut CIrBValue,
1024        name: *const std::os::raw::c_char,
1025    ) -> *mut CIrBValue;
1026    pub fn xls_builder_base_add_negate(
1027        builder: *mut CIrBuilderBase,
1028        value: *mut CIrBValue,
1029        name: *const std::os::raw::c_char,
1030    ) -> *mut CIrBValue;
1031    pub fn xls_builder_base_add_reverse(
1032        builder: *mut CIrBuilderBase,
1033        value: *mut CIrBValue,
1034        name: *const std::os::raw::c_char,
1035    ) -> *mut CIrBValue;
1036    pub fn xls_builder_base_add_or_reduce(
1037        builder: *mut CIrBuilderBase,
1038        value: *mut CIrBValue,
1039        name: *const std::os::raw::c_char,
1040    ) -> *mut CIrBValue;
1041    pub fn xls_builder_base_add_and_reduce(
1042        builder: *mut CIrBuilderBase,
1043        value: *mut CIrBValue,
1044        name: *const std::os::raw::c_char,
1045    ) -> *mut CIrBValue;
1046    pub fn xls_builder_base_add_xor_reduce(
1047        builder: *mut CIrBuilderBase,
1048        value: *mut CIrBValue,
1049        name: *const std::os::raw::c_char,
1050    ) -> *mut CIrBValue;
1051    pub fn xls_builder_base_add_literal(
1052        builder: *mut CIrBuilderBase,
1053        value: *mut CIrValue,
1054        name: *const std::os::raw::c_char,
1055    ) -> *mut CIrBValue;
1056    pub fn xls_builder_base_add_tuple(
1057        builder: *mut CIrBuilderBase,
1058        operands: *mut *mut CIrBValue,
1059        operand_count: i64,
1060        name: *const std::os::raw::c_char,
1061    ) -> *mut CIrBValue;
1062    pub fn xls_builder_base_add_tuple_index(
1063        builder: *mut CIrBuilderBase,
1064        tuple: *mut CIrBValue,
1065        index: i64,
1066        name: *const std::os::raw::c_char,
1067    ) -> *mut CIrBValue;
1068    pub fn xls_builder_base_add_array(
1069        builder: *mut CIrBuilderBase,
1070        element_type: *mut CIrType,
1071        elements: *const *mut CIrBValue,
1072        element_count: i64,
1073        name: *const std::os::raw::c_char,
1074    ) -> *mut CIrBValue;
1075    pub fn xls_builder_base_add_array_index(
1076        builder: *mut CIrBuilderBase,
1077        array: *mut CIrBValue,
1078        indices: *const *mut CIrBValue,
1079        index_count: i64,
1080        assumed_in_bounds: bool,
1081        name: *const std::os::raw::c_char,
1082    ) -> *mut CIrBValue;
1083    pub fn xls_builder_base_add_dynamic_bit_slice(
1084        builder: *mut CIrBuilderBase,
1085        value: *mut CIrBValue,
1086        start: *mut CIrBValue,
1087        width: i64,
1088        name: *const std::os::raw::c_char,
1089    ) -> *mut CIrBValue;
1090    pub fn xls_builder_base_add_bit_slice(
1091        builder: *mut CIrBuilderBase,
1092        value: *mut CIrBValue,
1093        start: i64,
1094        width: i64,
1095        name: *const std::os::raw::c_char,
1096    ) -> *mut CIrBValue;
1097    pub fn xls_builder_base_add_bit_slice_update(
1098        builder: *mut CIrBuilderBase,
1099        value: *mut CIrBValue,
1100        start: *mut CIrBValue,
1101        update: *mut CIrBValue,
1102        name: *const std::os::raw::c_char,
1103    ) -> *mut CIrBValue;
1104    pub fn xls_builder_base_add_concat(
1105        builder: *mut CIrBuilderBase,
1106        values: *const *mut CIrBValue,
1107        value_count: i64,
1108        name: *const std::os::raw::c_char,
1109    ) -> *mut CIrBValue;
1110    pub fn xls_builder_base_add_add(
1111        builder: *mut CIrBuilderBase,
1112        lhs: *mut CIrBValue,
1113        rhs: *mut CIrBValue,
1114        name: *const std::os::raw::c_char,
1115    ) -> *mut CIrBValue;
1116    pub fn xls_builder_base_add_sub(
1117        builder: *mut CIrBuilderBase,
1118        lhs: *mut CIrBValue,
1119        rhs: *mut CIrBValue,
1120        name: *const std::os::raw::c_char,
1121    ) -> *mut CIrBValue;
1122    pub fn xls_builder_base_add_umul(
1123        builder: *mut CIrBuilderBase,
1124        lhs: *mut CIrBValue,
1125        rhs: *mut CIrBValue,
1126        name: *const std::os::raw::c_char,
1127    ) -> *mut CIrBValue;
1128    pub fn xls_builder_base_add_smul(
1129        builder: *mut CIrBuilderBase,
1130        lhs: *mut CIrBValue,
1131        rhs: *mut CIrBValue,
1132        name: *const std::os::raw::c_char,
1133    ) -> *mut CIrBValue;
1134    pub fn xls_builder_base_add_udiv(
1135        builder: *mut CIrBuilderBase,
1136        lhs: *mut CIrBValue,
1137        rhs: *mut CIrBValue,
1138        name: *const std::os::raw::c_char,
1139    ) -> *mut CIrBValue;
1140    pub fn xls_builder_base_add_sdiv(
1141        builder: *mut CIrBuilderBase,
1142        lhs: *mut CIrBValue,
1143        rhs: *mut CIrBValue,
1144        name: *const std::os::raw::c_char,
1145    ) -> *mut CIrBValue;
1146    pub fn xls_builder_base_add_umod(
1147        builder: *mut CIrBuilderBase,
1148        lhs: *mut CIrBValue,
1149        rhs: *mut CIrBValue,
1150        name: *const std::os::raw::c_char,
1151    ) -> *mut CIrBValue;
1152    pub fn xls_builder_base_add_smod(
1153        builder: *mut CIrBuilderBase,
1154        lhs: *mut CIrBValue,
1155        rhs: *mut CIrBValue,
1156        name: *const std::os::raw::c_char,
1157    ) -> *mut CIrBValue;
1158    pub fn xls_builder_base_add_eq(
1159        builder: *mut CIrBuilderBase,
1160        lhs: *mut CIrBValue,
1161        rhs: *mut CIrBValue,
1162        name: *const std::os::raw::c_char,
1163    ) -> *mut CIrBValue;
1164    pub fn xls_builder_base_add_ne(
1165        builder: *mut CIrBuilderBase,
1166        lhs: *mut CIrBValue,
1167        rhs: *mut CIrBValue,
1168        name: *const std::os::raw::c_char,
1169    ) -> *mut CIrBValue;
1170
1171    // -- comparisons
1172    pub fn xls_builder_base_add_ule(
1173        builder: *mut CIrBuilderBase,
1174        lhs: *mut CIrBValue,
1175        rhs: *mut CIrBValue,
1176        name: *const std::os::raw::c_char,
1177    ) -> *mut CIrBValue;
1178    pub fn xls_builder_base_add_ult(
1179        builder: *mut CIrBuilderBase,
1180        lhs: *mut CIrBValue,
1181        rhs: *mut CIrBValue,
1182        name: *const std::os::raw::c_char,
1183    ) -> *mut CIrBValue;
1184    pub fn xls_builder_base_add_uge(
1185        builder: *mut CIrBuilderBase,
1186        lhs: *mut CIrBValue,
1187        rhs: *mut CIrBValue,
1188        name: *const std::os::raw::c_char,
1189    ) -> *mut CIrBValue;
1190    pub fn xls_builder_base_add_ugt(
1191        builder: *mut CIrBuilderBase,
1192        lhs: *mut CIrBValue,
1193        rhs: *mut CIrBValue,
1194        name: *const std::os::raw::c_char,
1195    ) -> *mut CIrBValue;
1196    pub fn xls_builder_base_add_sle(
1197        builder: *mut CIrBuilderBase,
1198        lhs: *mut CIrBValue,
1199        rhs: *mut CIrBValue,
1200        name: *const std::os::raw::c_char,
1201    ) -> *mut CIrBValue;
1202    pub fn xls_builder_base_add_slt(
1203        builder: *mut CIrBuilderBase,
1204        lhs: *mut CIrBValue,
1205        rhs: *mut CIrBValue,
1206        name: *const std::os::raw::c_char,
1207    ) -> *mut CIrBValue;
1208    pub fn xls_builder_base_add_sgt(
1209        builder: *mut CIrBuilderBase,
1210        lhs: *mut CIrBValue,
1211        rhs: *mut CIrBValue,
1212        name: *const std::os::raw::c_char,
1213    ) -> *mut CIrBValue;
1214    pub fn xls_builder_base_add_sge(
1215        builder: *mut CIrBuilderBase,
1216        lhs: *mut CIrBValue,
1217        rhs: *mut CIrBValue,
1218        name: *const std::os::raw::c_char,
1219    ) -> *mut CIrBValue;
1220
1221    pub fn xls_builder_base_add_shra(
1222        builder: *mut CIrBuilderBase,
1223        a: *mut CIrBValue,
1224        b: *mut CIrBValue,
1225        name: *const std::os::raw::c_char,
1226    ) -> *mut CIrBValue;
1227    pub fn xls_builder_base_add_shrl(
1228        builder: *mut CIrBuilderBase,
1229        a: *mut CIrBValue,
1230        b: *mut CIrBValue,
1231        name: *const std::os::raw::c_char,
1232    ) -> *mut CIrBValue;
1233    pub fn xls_builder_base_add_shll(
1234        builder: *mut CIrBuilderBase,
1235        a: *mut CIrBValue,
1236        b: *mut CIrBValue,
1237        name: *const std::os::raw::c_char,
1238    ) -> *mut CIrBValue;
1239    pub fn xls_builder_base_add_nor(
1240        builder: *mut CIrBuilderBase,
1241        a: *mut CIrBValue,
1242        b: *mut CIrBValue,
1243        name: *const std::os::raw::c_char,
1244    ) -> *mut CIrBValue;
1245    pub fn xls_builder_base_add_clz(
1246        builder: *mut CIrBuilderBase,
1247        a: *mut CIrBValue,
1248        name: *const std::os::raw::c_char,
1249    ) -> *mut CIrBValue;
1250    pub fn xls_builder_base_add_ctz(
1251        builder: *mut CIrBuilderBase,
1252        a: *mut CIrBValue,
1253        name: *const std::os::raw::c_char,
1254    ) -> *mut CIrBValue;
1255    pub fn xls_builder_base_add_encode(
1256        builder: *mut CIrBuilderBase,
1257        a: *mut CIrBValue,
1258        name: *const std::os::raw::c_char,
1259    ) -> *mut CIrBValue;
1260
1261    pub fn xls_builder_base_add_decode(
1262        builder: *mut CIrBuilderBase,
1263        a: *mut CIrBValue,
1264        width: *mut i64,
1265        name: *const std::os::raw::c_char,
1266    ) -> *mut CIrBValue;
1267    pub fn xls_builder_base_add_select(
1268        builder: *mut CIrBuilderBase,
1269        selector: *mut CIrBValue,
1270        cases: *const *mut CIrBValue,
1271        case_count: i64,
1272        default_value: *mut CIrBValue,
1273        name: *const std::os::raw::c_char,
1274    ) -> *mut CIrBValue;
1275    pub fn xls_builder_base_add_array_concat(
1276        builder: *mut CIrBuilderBase,
1277        arrays: *const *mut CIrBValue,
1278        array_count: i64,
1279        name: *const std::os::raw::c_char,
1280    ) -> *mut CIrBValue;
1281    pub fn xls_builder_base_add_array_slice(
1282        builder: *mut CIrBuilderBase,
1283        array: *mut CIrBValue,
1284        start: *mut CIrBValue,
1285        width: i64,
1286        name: *const std::os::raw::c_char,
1287    ) -> *mut CIrBValue;
1288    pub fn xls_builder_base_add_array_update(
1289        builder: *mut CIrBuilderBase,
1290        array: *mut CIrBValue,
1291        update_value: *mut CIrBValue,
1292        indices: *const *mut CIrBValue,
1293        index_count: i64,
1294        assumed_in_bounds: bool,
1295        name: *const std::os::raw::c_char,
1296    ) -> *mut CIrBValue;
1297    pub fn xls_builder_base_add_identity(
1298        builder: *mut CIrBuilderBase,
1299        value: *mut CIrBValue,
1300        name: *const std::os::raw::c_char,
1301    ) -> *mut CIrBValue;
1302
1303    pub fn xls_builder_base_add_sign_extend(
1304        builder: *mut CIrBuilderBase,
1305        value: *mut CIrBValue,
1306        new_bit_count: i64,
1307        name: *const std::os::raw::c_char,
1308    ) -> *mut CIrBValue;
1309    pub fn xls_builder_base_add_zero_extend(
1310        builder: *mut CIrBuilderBase,
1311        value: *mut CIrBValue,
1312        new_bit_count: i64,
1313        name: *const std::os::raw::c_char,
1314    ) -> *mut CIrBValue;
1315
1316    pub fn xls_builder_base_add_one_hot(
1317        builder: *mut CIrBuilderBase,
1318        input: *mut CIrBValue,
1319        lsb_is_priority: bool,
1320        name: *const std::os::raw::c_char,
1321    ) -> *mut CIrBValue;
1322
1323    pub fn xls_builder_base_add_one_hot_select(
1324        builder: *mut CIrBuilderBase,
1325        selector: *mut CIrBValue,
1326        cases: *const *mut CIrBValue,
1327        case_count: i64,
1328        name: *const std::os::raw::c_char,
1329    ) -> *mut CIrBValue;
1330
1331    pub fn xls_builder_base_add_priority_select(
1332        builder: *mut CIrBuilderBase,
1333        selector: *mut CIrBValue,
1334        cases: *const *mut CIrBValue,
1335        case_count: i64,
1336        default_value: *mut CIrBValue,
1337        name: *const std::os::raw::c_char,
1338    ) -> *mut CIrBValue;
1339
1340    pub fn xls_builder_base_get_last_value(
1341        builder: *mut CIrBuilderBase,
1342        error_out: *mut *mut std::os::raw::c_char,
1343        value_out: *mut *mut CIrBValue,
1344    ) -> bool;
1345
1346    pub fn xls_builder_base_get_type(
1347        builder: *mut CIrBuilderBase,
1348        value: *mut CIrBValue,
1349    ) -> *mut CIrType;
1350
1351    // New functions for sequential logic
1352    pub fn xls_vast_verilog_module_add_always_ff(
1353        m: *mut CVastModule,
1354        sensitivity_list_elements: *mut *mut CVastExpression,
1355        sensitivity_list_count: usize,
1356        out_always_ff: *mut *mut CVastAlwaysBase,
1357        error_out: *mut *mut ::std::os::raw::c_char,
1358    ) -> bool;
1359    pub fn xls_vast_verilog_module_add_always_at(
1360        m: *mut CVastModule,
1361        sensitivity_list_elements: *mut *mut CVastExpression,
1362        sensitivity_list_count: usize,
1363        out_always_at: *mut *mut CVastAlwaysBase,
1364        error_out: *mut *mut ::std::os::raw::c_char,
1365    ) -> bool;
1366    pub fn xls_vast_verilog_module_add_reg(
1367        m: *mut CVastModule,
1368        name: *const ::std::os::raw::c_char,
1369        type_: *mut CVastDataType,
1370        out_reg_ref: *mut *mut CVastLogicRef,
1371        error_out: *mut *mut ::std::os::raw::c_char,
1372    ) -> bool;
1373    pub fn xls_vast_verilog_file_make_pos_edge(
1374        f: *mut CVastFile,
1375        signal_expr: *mut CVastExpression,
1376    ) -> *mut CVastExpression;
1377    pub fn xls_vast_verilog_file_make_nonblocking_assignment(
1378        f: *mut CVastFile,
1379        lhs: *mut CVastExpression,
1380        rhs: *mut CVastExpression,
1381    ) -> *mut CVastStatement;
1382    pub fn xls_vast_always_base_get_statement_block(
1383        always_base: *mut CVastAlwaysBase,
1384    ) -> *mut CVastStatementBlock;
1385    pub fn xls_vast_statement_block_add_nonblocking_assignment(
1386        block: *mut CVastStatementBlock,
1387        lhs: *mut CVastExpression,
1388        rhs: *mut CVastExpression,
1389    ) -> *mut CVastStatement;
1390
1391    pub fn xls_function_type_get_param_count(fty: *mut CIrFunctionType) -> i64;
1392
1393    pub fn xls_function_type_get_param_type(
1394        fty: *mut CIrFunctionType,
1395        index: libc::size_t,
1396        error_out: *mut *mut std::os::raw::c_char,
1397        param_type_out: *mut *mut CIrType,
1398    ) -> bool;
1399
1400    pub fn xls_function_type_get_return_type(fty: *mut CIrFunctionType) -> *mut CIrType;
1401
1402    pub fn xls_function_get_param_name(
1403        function: *mut CIrFunction,
1404        index: libc::size_t,
1405        error_out: *mut *mut std::os::raw::c_char,
1406        name_out: *mut *mut std::os::raw::c_char,
1407    ) -> bool;
1408
1409    pub fn xls_dslx_module_member_get_function(
1410        member: *const CDslxModuleMember,
1411    ) -> *mut CDslxFunction;
1412    pub fn xls_dslx_function_is_parametric(function: *const CDslxFunction) -> bool;
1413    pub fn xls_dslx_function_get_identifier(
1414        function: *const CDslxFunction,
1415    ) -> *mut std::os::raw::c_char;
1416
1417    // -- "requires implicit token?" determination for a DSLX function
1418    pub fn xls_dslx_type_info_get_requires_implicit_token(
1419        type_info: *mut CDslxTypeInfo,
1420        function: *mut CDslxFunction,
1421        error_out: *mut *mut std::os::raw::c_char,
1422        result_out: *mut bool,
1423    ) -> bool;
1424
1425    // -- Quickcheck APIs
1426    pub fn xls_dslx_module_member_get_quickcheck(
1427        member: *const CDslxModuleMember,
1428    ) -> *mut CDslxQuickcheck;
1429
1430    pub fn xls_dslx_quickcheck_get_function(qc: *const CDslxQuickcheck) -> *mut CDslxFunction;
1431
1432    /// Returns true iff the Quickcheck has the `exhaustive` test-cases
1433    /// specifier.
1434    pub fn xls_dslx_quickcheck_is_exhaustive(qc: *const CDslxQuickcheck) -> bool;
1435
1436    /// Retrieves the test-case count for the Quickcheck. Returns true and sets
1437    /// `*result_out` when the Quickcheck has a counted test-case specifier;
1438    /// returns false when the Quickcheck is marked exhaustive (in which case
1439    /// `*result_out` is not modified).
1440    pub fn xls_dslx_quickcheck_get_count(qc: *const CDslxQuickcheck, result_out: *mut i64) -> bool;
1441}
1442
1443pub const DSLX_STDLIB_PATH: &str = env!("DSLX_STDLIB_PATH");
1444
1445/// Directory containing the libxls DSO.
1446///
1447/// *** DO NOT USE THIS VARIABLE FROM WITHIN YOUR build.rs ***
1448///
1449/// You might be tempted to write the following in your build.rs:
1450///
1451/// ```ignore
1452/// // DO NOT DO THIS IN YOUR build.rs!!
1453/// let dylib_dirpath = xlsynth_sys::XLS_DSO_PATH;
1454/// // set rpath to dylib_dirpath or something.
1455/// ```
1456///
1457/// The problem is that build.rs is compiled for host, whereas if you're setting
1458/// an rpath (or something similar) you want to get the path from compiling
1459/// xlsynth_sys for *target*.  In other words, the above will break
1460/// cross-compilation.
1461///
1462/// Instead, your build.rs should get the path from an envvar which:
1463///
1464/// ```ignore
1465/// // Do this from your build.rs instead.
1466/// let dylib_path = std::env::var("DEP_XLSYNTH_DSO_PATH").unwrap();
1467/// ```
1468///
1469/// More details are available at
1470/// <https://doc.rust-lang.org/cargo/reference/build-script-examples.html#using-another-sys-crate>.
1471///
1472/// (If you use this envvar from your crate proper -- i.e. not from build.rs --
1473/// then it's perfectly fine.)
1474pub const XLS_DSO_PATH: &str = env!("XLS_DSO_PATH");