Skip to content

Commit 4cf4286

Browse files
committed
Inline get_simple_function
1 parent 2acd77e commit 4cf4286

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

src/intrinsic/mod.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,6 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
9595
Some(cx.context.get_builtin_function(gcc_name))
9696
}
9797

98-
// TODO(antoyo): We can probably remove these and use the fallback intrinsic implementation.
99-
fn get_simple_function<'gcc, 'tcx>(
100-
cx: &CodegenCx<'gcc, 'tcx>,
101-
name: Symbol,
102-
) -> Option<Function<'gcc>> {
103-
let (ty, func_name) = match name {
104-
sym::minimumf32 => (cx.float_type, "fminimumf"),
105-
sym::minimumf64 => (cx.double_type, "fminimum"),
106-
sym::maximumf32 => (cx.float_type, "fmaximumf"),
107-
sym::maximumf64 => (cx.double_type, "fmaximum"),
108-
_ => return None,
109-
};
110-
Some(cx.context.new_function(
111-
None,
112-
FunctionType::Extern,
113-
ty,
114-
&[cx.context.new_parameter(None, ty, "a"), cx.context.new_parameter(None, ty, "b")],
115-
func_name,
116-
false,
117-
))
118-
}
119-
12098
fn get_simple_function_f128<'gcc, 'tcx>(
12199
cx: &CodegenCx<'gcc, 'tcx>,
122100
name: Symbol,
@@ -215,7 +193,6 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
215193
let fn_args = instance.args;
216194

217195
let simple = get_simple_intrinsic(self, name);
218-
let simple_func = get_simple_function(self, name);
219196

220197
let value = match name {
221198
_ if simple.is_some() => {
@@ -226,8 +203,26 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
226203
&args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
227204
)
228205
}
229-
_ if simple_func.is_some() => {
230-
let func = simple_func.expect("simple function");
206+
// TODO(antoyo): We can probably remove these and use the fallback intrinsic implementation.
207+
sym::minimumf32 | sym::minimumf64 | sym::maximumf32 | sym::maximumf64 => {
208+
let (ty, func_name) = match name {
209+
sym::minimumf32 => (cx.float_type, "fminimumf"),
210+
sym::maximumf32 => (cx.float_type, "fmaximumf"),
211+
sym::minimumf64 => (cx.double_type, "fminimum"),
212+
sym::maximumf64 => (cx.double_type, "fmaximum"),
213+
_ => unreachable!(),
214+
};
215+
let func = cx.context.new_function(
216+
None,
217+
FunctionType::Extern,
218+
ty,
219+
&[
220+
cx.context.new_parameter(None, ty, "a"),
221+
cx.context.new_parameter(None, ty, "b"),
222+
],
223+
func_name,
224+
false,
225+
);
231226
self.cx.context.new_call(
232227
self.location,
233228
func,

0 commit comments

Comments
 (0)