about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2023-08-02 12:45:52 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2023-08-06 15:47:40 -0700
commit502af03445f045dade14f14e754803f02c2c5e24 (patch)
treefbeb208e1c6d7df46431f1412404e8b48dfd5349 /compiler/rustc_codegen_gcc
parent85fbb571497d13cfb828de9b0d3e78656b9203c1 (diff)
downloadrust-502af03445f045dade14f14e754803f02c2c5e24.tar.gz
rust-502af03445f045dade14f14e754803f02c2c5e24.zip
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly
Diffstat (limited to 'compiler/rustc_codegen_gcc')
-rw-r--r--compiler/rustc_codegen_gcc/src/intrinsic/mod.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
index 68edde13829..eca2abf2775 100644
--- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
+++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
@@ -302,6 +302,20 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
                     }
                 }
 
+                sym::compare_bytes => {
+                    let a = args[0].immediate();
+                    let b = args[1].immediate();
+                    let n = args[2].immediate();
+
+                    let void_ptr_type = self.context.new_type::<*const ()>();
+                    let a_ptr = self.bitcast(a, void_ptr_type);
+                    let b_ptr = self.bitcast(b, void_ptr_type);
+
+                    let builtin = self.context.get_builtin_function("memcmp");
+                    let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]);
+                    self.sext(cmp, self.type_ix(32))
+                }
+
                 sym::black_box => {
                     args[0].val.store(self, result);