@@ -72,44 +72,8 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
72
72
sym:: fabsf64 => "fabs" ,
73
73
sym:: minnumf32 => "fminf" ,
74
74
sym:: minnumf64 => "fmin" ,
75
- sym:: minimumf32 => "fminimumf" ,
76
- sym:: minimumf64 => "fminimum" ,
77
- sym:: minimumf128 => {
78
- // GCC doesn't have the intrinsic we want so we use the compiler-builtins one
79
- // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html
80
- let f128_type = cx. type_f128 ( ) ;
81
- return Some ( cx. context . new_function (
82
- None ,
83
- FunctionType :: Extern ,
84
- f128_type,
85
- & [
86
- cx. context . new_parameter ( None , f128_type, "a" ) ,
87
- cx. context . new_parameter ( None , f128_type, "b" ) ,
88
- ] ,
89
- "fminimumf128" ,
90
- false ,
91
- ) ) ;
92
- }
93
75
sym:: maxnumf32 => "fmaxf" ,
94
76
sym:: maxnumf64 => "fmax" ,
95
- sym:: maximumf32 => "fmaximumf" ,
96
- sym:: maximumf64 => "fmaximum" ,
97
- sym:: maximumf128 => {
98
- // GCC doesn't have the intrinsic we want so we use the compiler-builtins one
99
- // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html
100
- let f128_type = cx. type_f128 ( ) ;
101
- return Some ( cx. context . new_function (
102
- None ,
103
- FunctionType :: Extern ,
104
- f128_type,
105
- & [
106
- cx. context . new_parameter ( None , f128_type, "a" ) ,
107
- cx. context . new_parameter ( None , f128_type, "b" ) ,
108
- ] ,
109
- "fmaximumf128" ,
110
- false ,
111
- ) ) ;
112
- }
113
77
sym:: copysignf32 => "copysignf" ,
114
78
sym:: copysignf64 => "copysign" ,
115
79
sym:: copysignf128 => "copysignl" ,
@@ -130,6 +94,72 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
130
94
Some ( cx. context . get_builtin_function ( gcc_name) )
131
95
}
132
96
97
+ // TODO(antoyo): We can probably remove these and use the fallback intrinsic implementation.
98
+ fn get_simple_function < ' gcc , ' tcx > (
99
+ cx : & CodegenCx < ' gcc , ' tcx > ,
100
+ name : Symbol ,
101
+ ) -> Option < Function < ' gcc > > {
102
+ let ( return_type, parameters, func_name) = match name {
103
+ sym:: minimumf32 => {
104
+ let parameters = [
105
+ cx. context . new_parameter ( None , cx. float_type , "a" ) ,
106
+ cx. context . new_parameter ( None , cx. float_type , "b" ) ,
107
+ ] ;
108
+ ( cx. float_type , parameters, "fminimumf" )
109
+ }
110
+ sym:: minimumf64 => {
111
+ let parameters = [
112
+ cx. context . new_parameter ( None , cx. double_type , "a" ) ,
113
+ cx. context . new_parameter ( None , cx. double_type , "b" ) ,
114
+ ] ;
115
+ ( cx. double_type , parameters, "fminimum" )
116
+ }
117
+ sym:: minimumf128 => {
118
+ let f128_type = cx. type_f128 ( ) ;
119
+ // GCC doesn't have the intrinsic we want so we use the compiler-builtins one
120
+ // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html
121
+ let parameters = [
122
+ cx. context . new_parameter ( None , f128_type, "a" ) ,
123
+ cx. context . new_parameter ( None , f128_type, "b" ) ,
124
+ ] ;
125
+ ( f128_type, parameters, "fminimumf128" )
126
+ }
127
+ sym:: maximumf32 => {
128
+ let parameters = [
129
+ cx. context . new_parameter ( None , cx. float_type , "a" ) ,
130
+ cx. context . new_parameter ( None , cx. float_type , "b" ) ,
131
+ ] ;
132
+ ( cx. float_type , parameters, "fmaximumf" )
133
+ }
134
+ sym:: maximumf64 => {
135
+ let parameters = [
136
+ cx. context . new_parameter ( None , cx. double_type , "a" ) ,
137
+ cx. context . new_parameter ( None , cx. double_type , "b" ) ,
138
+ ] ;
139
+ ( cx. double_type , parameters, "fmaximum" )
140
+ }
141
+ sym:: maximumf128 => {
142
+ let f128_type = cx. type_f128 ( ) ;
143
+ // GCC doesn't have the intrinsic we want so we use the compiler-builtins one
144
+ // https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html
145
+ let parameters = [
146
+ cx. context . new_parameter ( None , f128_type, "a" ) ,
147
+ cx. context . new_parameter ( None , f128_type, "b" ) ,
148
+ ] ;
149
+ ( f128_type, parameters, "fmaximumf128" )
150
+ }
151
+ _ => return None ,
152
+ } ;
153
+ Some ( cx. context . new_function (
154
+ None ,
155
+ FunctionType :: Extern ,
156
+ return_type,
157
+ & parameters,
158
+ func_name,
159
+ false ,
160
+ ) )
161
+ }
162
+
133
163
impl < ' a , ' gcc , ' tcx > IntrinsicCallBuilderMethods < ' tcx > for Builder < ' a , ' gcc , ' tcx > {
134
164
fn codegen_intrinsic_call (
135
165
& mut self ,
@@ -158,14 +188,23 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
158
188
let result = PlaceRef :: new_sized ( llresult, fn_abi. ret . layout ) ;
159
189
160
190
let simple = get_simple_intrinsic ( self , name) ;
191
+ let simple_func = get_simple_function ( self , name) ;
161
192
162
193
// FIXME(tempdragon): Re-enable `clippy::suspicious_else_formatting` if the following issue is solved:
163
194
// https://github.com/rust-lang/rust-clippy/issues/12497
164
195
// and leave `else if use_integer_compare` to be placed "as is".
165
196
#[ allow( clippy:: suspicious_else_formatting) ]
166
197
let value = match name {
167
198
_ if simple. is_some ( ) => {
168
- let func = simple. expect ( "simple function" ) ;
199
+ let func = simple. expect ( "simple intrinsic function" ) ;
200
+ self . cx . context . new_call (
201
+ self . location ,
202
+ func,
203
+ & args. iter ( ) . map ( |arg| arg. immediate ( ) ) . collect :: < Vec < _ > > ( ) ,
204
+ )
205
+ }
206
+ _ if simple_func. is_some ( ) => {
207
+ let func = simple_func. expect ( "simple function" ) ;
169
208
self . cx . context . new_call (
170
209
self . location ,
171
210
func,
0 commit comments