Skip to content

Commit 9c8ae2f

Browse files
committed
Add a new compare_bytes intrinsic instead of calling memcmp directly
1 parent 7ebcd4d commit 9c8ae2f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: src/intrinsic/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
302302
}
303303
}
304304

305+
sym::compare_bytes => {
306+
let a = args[0].immediate();
307+
let b = args[1].immediate();
308+
let n = args[2].immediate();
309+
310+
let void_ptr_type = self.context.new_type::<*const ()>();
311+
let a_ptr = self.bitcast(a, void_ptr_type);
312+
let b_ptr = self.bitcast(b, void_ptr_type);
313+
314+
let builtin = self.context.get_builtin_function("memcmp");
315+
let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]);
316+
self.sext(cmp, self.type_ix(32))
317+
}
318+
305319
sym::black_box => {
306320
args[0].val.store(self, result);
307321

0 commit comments

Comments
 (0)