about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2020-10-05 20:13:36 +0000
committerkadmin <julianknodt@gmail.com>2021-03-09 16:54:13 +0000
commit72c734d001a157e0fb38e1feebf6748189d3e1b9 (patch)
tree66a1aab39b55d7f43e81a90993a70350c7f95937
parent0fdc07e197e3d0265452e266d038b089b69da6cb (diff)
downloadrust-72c734d001a157e0fb38e1feebf6748189d3e1b9.tar.gz
rust-72c734d001a157e0fb38e1feebf6748189d3e1b9.zip
Update fmt and use of memcpy
I'm still not totally sure if this is the right way to implement the memcpy, but that portion
compiles correctly now. Now to fix the compile errors everywhere else :).
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/statement.rs23
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs2
2 files changed, 15 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs
index 2c90054b6c7..b507cb0a823 100644
--- a/compiler/rustc_codegen_ssa/src/mir/statement.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs
@@ -120,15 +120,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                 ref dst,
                 ref size,
             }) => {
-              bx.memcpy(
-                dst,
-                todo!(),
-                src,
-                todo!(),
-                size,
-                todo!(),
-              );
-              bx
+                let dst_val = self.codegen_place(&mut bx, dst.as_ref());
+                let src_val = self.codegen_place(&mut bx, src.as_ref());
+                let size_val = self.codegen_operand(&mut bx, size);
+                let size = size_val.immediate_or_packed_pair(&mut bx);
+                bx.memcpy(
+                    dst_val.llval,
+                    dst_val.align,
+                    src_val.llval,
+                    src_val.align,
+                    size,
+                    // TODO probably want to have this change based on alignment above?
+                    crate::MemFlags::empty(),
+                );
+                bx
             }
             mir::StatementKind::FakeRead(..)
             | mir::StatementKind::Retag { .. }
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index 90111d4080c..2db69c27fe8 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -1668,7 +1668,7 @@ impl Debug for Statement<'_> {
                 ref src,
                 ref dst,
                 ref size,
-            }) => write!(fmt, "src {:?} -> dst {:?}, {:?} bytes", src, dst, size),
+            }) => write!(fmt, "copy_nonoverlapping(src={:?}, dst={:?},bytes={:?})", src, dst, size),
             Nop => write!(fmt, "nop"),
         }
     }