1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Functions for linking and calling trigonometric functions in JIT-compiled code.
//!
//! This module provides functionality to:
//! - Link external trigonometric functions (sin, cos) into JIT-compiled code
//! - Generate Cranelift IR instructions to call trigonometric functions within compiled functions
//!
//! All trigonometric functions operate on 64-bit floating point numbers (f64) and expect
//! arguments in radians.
use FunctionBuilder;
use F64;
use ;
use ;
/// Links the sine function to make it available for JIT compilation.
///
/// This function declares the external sin function to the Cranelift module,
/// making it available for use in JIT-compiled code. It creates a function
/// signature matching the standard sin function: f64 -> f64.
///
/// # Arguments
/// * `module` - The Cranelift module to declare the function in
///
/// # Returns
/// * `Ok(FuncId)` - The function ID that can be used to call sin
/// * `Err(String)` - Error message if declaration fails
/// Generates Cranelift IR instructions to call the sine function.
///
/// This helper function adds instructions to call the previously linked sin
/// function within a function being built with Cranelift.
///
/// # Arguments
/// * `builder` - The Cranelift function builder being used to construct the function
/// * `module` - The Cranelift module containing the function declaration
/// * `func_id` - The function ID returned by link_sin()
/// * `arg` - The Cranelift IR value to pass as the argument to sin (in radians)
///
/// # Returns
/// The Cranelift IR value containing the result of calling sin
/// Links the cosine function to make it available for JIT compilation.
///
/// This function declares the external cos function to the Cranelift module,
/// making it available for use in JIT-compiled code. It creates a function
/// signature matching the standard cos function: f64 -> f64.
///
/// # Arguments
/// * `module` - The Cranelift module to declare the function in
///
/// # Returns
/// * `Ok(FuncId)` - The function ID that can be used to call cos
/// * `Err(String)` - Error message if declaration fails
/// Generates Cranelift IR instructions to call the cosine function.
///
/// This helper function adds instructions to call the previously linked cos
/// function within a function being built with Cranelift.
///
/// # Arguments
/// * `builder` - The Cranelift function builder being used to construct the function
/// * `module` - The Cranelift module containing the function declaration
/// * `func_id` - The function ID returned by link_cos()
/// * `arg` - The Cranelift IR value to pass as the argument to cos (in radians)
///
/// # Returns
/// The Cranelift IR value containing the result of calling cos