Add a new compare_bytes intrinsic instead of calling memcmp directly

This commit is contained in:
Scott McMurray 2023-08-02 12:45:52 -07:00
parent 85fbb57149
commit 502af03445
17 changed files with 267 additions and 22 deletions

View file

@ -329,6 +329,15 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
}
}
sym::compare_bytes => {
let cmp = self.call_intrinsic(
"memcmp",
&[args[0].immediate(), args[1].immediate(), args[2].immediate()],
);
// Some targets have `memcmp` returning `i16`, but the intrinsic is always `i32`.
self.sext(cmp, self.type_ix(32))
}
sym::black_box => {
args[0].val.store(self, result);
let result_val_span = [result.llval];