Skip to content

Commit

Permalink
Merge pull request #2746 from bjorn3/emit_small_mem_custom_memflags
Browse files Browse the repository at this point in the history
Allow passing arbitrary MemFlags to emit_small_mem{cpy,move}
  • Loading branch information
cfallin authored Apr 28, 2021
2 parents 7ec073c + 1639f2c commit ff2529c
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions cranelift/frontend/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ impl<'a> FunctionBuilder<'a> {
dest_align: u8,
src_align: u8,
non_overlapping: bool,
mut flags: MemFlags,
) {
// Currently the result of guess work, not actual profiling.
const THRESHOLD: u64 = 4;
Expand Down Expand Up @@ -676,7 +677,6 @@ impl<'a> FunctionBuilder<'a> {
return;
}

let mut flags = MemFlags::new();
flags.set_aligned();

// Load all of the memory first. This is necessary in case `dest` overlaps.
Expand Down Expand Up @@ -732,6 +732,7 @@ impl<'a> FunctionBuilder<'a> {
ch: u8,
size: u64,
buffer_align: u8,
mut flags: MemFlags,
) {
// Currently the result of guess work, not actual profiling.
const THRESHOLD: u64 = 4;
Expand Down Expand Up @@ -763,7 +764,6 @@ impl<'a> FunctionBuilder<'a> {
let size = self.ins().iconst(config.pointer_type(), size as i64);
self.call_memset(config, buffer, ch, size);
} else {
let mut flags = MemFlags::new();
flags.set_aligned();

let ch = u64::from(ch);
Expand Down Expand Up @@ -851,7 +851,9 @@ mod tests {
use alloc::string::ToString;
use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::ir::types::*;
use cranelift_codegen::ir::{AbiParam, ExternalName, Function, InstBuilder, Signature};
use cranelift_codegen::ir::{
AbiParam, ExternalName, Function, InstBuilder, MemFlags, Signature,
};
use cranelift_codegen::isa::CallConv;
use cranelift_codegen::settings;
use cranelift_codegen::verifier::verify_function;
Expand Down Expand Up @@ -1063,7 +1065,16 @@ block0:
let src = builder.use_var(x);
let dest = builder.use_var(y);
let size = 8;
builder.emit_small_memory_copy(target.frontend_config(), dest, src, size, 8, 8, true);
builder.emit_small_memory_copy(
target.frontend_config(),
dest,
src,
size,
8,
8,
true,
MemFlags::new(),
);
builder.ins().return_(&[dest]);

builder.seal_all_blocks();
Expand Down Expand Up @@ -1121,7 +1132,16 @@ block0:
let src = builder.use_var(x);
let dest = builder.use_var(y);
let size = 8192;
builder.emit_small_memory_copy(target.frontend_config(), dest, src, size, 8, 8, true);
builder.emit_small_memory_copy(
target.frontend_config(),
dest,
src,
size,
8,
8,
true,
MemFlags::new(),
);
builder.ins().return_(&[dest]);

builder.seal_all_blocks();
Expand Down Expand Up @@ -1179,7 +1199,7 @@ block0:

let dest = builder.use_var(y);
let size = 8;
builder.emit_small_memset(target.frontend_config(), dest, 1, size, 8);
builder.emit_small_memset(target.frontend_config(), dest, 1, size, 8, MemFlags::new());
builder.ins().return_(&[dest]);

builder.seal_all_blocks();
Expand Down Expand Up @@ -1232,7 +1252,7 @@ block0:

let dest = builder.use_var(y);
let size = 8192;
builder.emit_small_memset(target.frontend_config(), dest, 1, size, 8);
builder.emit_small_memset(target.frontend_config(), dest, 1, size, 8, MemFlags::new());
builder.ins().return_(&[dest]);

builder.seal_all_blocks();
Expand Down

0 comments on commit ff2529c

Please sign in to comment.