Commit 28f4ed79 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed bugs and formatting

parent 4202cd93
Pipeline #1207 failed with stages
in 23 minutes and 56 seconds
This diff is collapsed.
......@@ -1253,11 +1253,11 @@ impl fmt::Display for Constant {
&Constant::IntEx(ref v) => {
let mut res = format!("");
// Stored in little-endian order, but we need to display it in big-endian order
for i in 1 .. v.len() + 1 {
for i in 1..v.len() + 1 {
res.push_str(format!("{:016X}", v[v.len() - i]).to_string().as_str());
}
write!(f, "0x{}", res)
},
}
&Constant::Float(v) => write!(f, "{}", v),
&Constant::Double(v) => write!(f, "{}", v),
// &Constant::IRef(v) => write!(f, "{}", v),
......@@ -1576,8 +1576,12 @@ impl MuEntityHeader {
}
/// an abbreviate (easy reading) version of the name
fn abbreviate_name(&self) -> String {
self.name.split('.').last().unwrap().to_string()
pub fn abbreviate_name(&self) -> String {
if PRINT_ABBREVIATE_NAME {
self.name.split('.').last().unwrap().to_string()
} else {
(*self.name()).clone()
}
}
pub fn clone_with_id(&self, new_id: MuID) -> MuEntityHeader {
......@@ -1597,17 +1601,9 @@ impl PartialEq for MuEntityHeader {
impl fmt::Display for MuEntityHeader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if DISPLAY_ID {
if PRINT_ABBREVIATE_NAME {
write!(f, "{} #{}", self.abbreviate_name(), self.id)
} else {
write!(f, "{} #{}", self.name(), self.id)
}
write!(f, "{} #{}", self.abbreviate_name(), self.id)
} else {
if PRINT_ABBREVIATE_NAME {
write!(f, "{}", self.abbreviate_name())
} else {
write!(f, "{}", self.name())
}
write!(f, "{}", self.abbreviate_name())
}
}
}
......
......@@ -393,7 +393,7 @@ impl MuType {
/// gets the signature of a funcref or ufuncptr type
pub fn get_sig(&self) -> Option<P<MuFuncSig>> {
match self.v {
MuType_::FuncRef(ref sig) | MuType_::UFuncPtr(ref sig)=> Some(sig.clone()),
MuType_::FuncRef(ref sig) | MuType_::UFuncPtr(ref sig) => Some(sig.clone()),
_ => None
}
}
......
......@@ -4853,7 +4853,8 @@ impl<'a> InstructionSelection {
);
if resumption.is_some() {
self.backend.emit_b(resumption.as_ref().unwrap().normal_dest.target.name());
self.backend
.emit_b(resumption.as_ref().unwrap().normal_dest.target.name());
}
}
}
......
......@@ -2064,8 +2064,12 @@ pub fn emit_ireg_value(
&Constant::FuncRef(ref func) => {
let tmp = make_temporary(f_context, pv.ty.clone(), vm);
let mem =
make_value_symbolic(vm.get_name_for_func(func.id()), true, &ADDRESS_TYPE, vm);
let mem = make_value_symbolic(
vm.get_name_for_func(func.id()),
true,
&ADDRESS_TYPE,
vm
);
emit_calculate_address(backend, &tmp, &mem, vm);
tmp
}
......
......@@ -4558,7 +4558,8 @@ impl<'a> InstructionSelection {
// jump to target block
if resumption.is_some() {
self.backend.emit_jmp(resumption.as_ref().unwrap().normal_dest.target.name());
self.backend
.emit_jmp(resumption.as_ref().unwrap().normal_dest.target.name());
}
}
......
......@@ -162,7 +162,12 @@ pub fn emit_mu_globals(suffix: &str, vm: &VM) {
let global_guard = vm.globals().read().unwrap();
for g in global_guard.values() {
write!(file, ".global {}<{}>", g.name(), g.ty.get_referent_ty().unwrap()).unwrap();
write!(
file,
".global {}<{}>",
g.name(),
g.ty.get_referent_ty().unwrap()
).unwrap();
}
}
}
......
......@@ -100,7 +100,7 @@ fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionCont
// every graph node (basic block)
for (id, block) in f_content.blocks.iter() {
let block_name = block.name();
let block_name = block.hdr.abbreviate_name();
// BBid [label = "name
write!(file, "BB{} [label = \"{}", *id, &block_name).unwrap();
let block_content = block.content.as_ref().unwrap();
......@@ -122,7 +122,7 @@ fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionCont
write!(file, "[{}]", block_content.exn_arg.as_ref().unwrap()).unwrap();
}
write!(file, ":\\l{{\\l").unwrap();
write!(file, ":\\l").unwrap();
// all the instructions
for inst in block_content.body.iter() {
......@@ -130,7 +130,7 @@ fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionCont
}
// "];
writeln!(file, "\\}}\\l\"];").unwrap();
writeln!(file, "\"];").unwrap();
}
// every edge
......
......@@ -214,7 +214,8 @@ impl Inlining {
);
// creates a new block ID
// which will be the entry block for the inlined function
let new_inlined_entry_hdr = new_inlined_block_name(inlined_fv_content.get_entry_block().name(), vm);
let new_inlined_entry_hdr =
new_inlined_block_name(inlined_fv_content.get_entry_block().name(), vm);
// change current call instruction to a branch
trace!("turning CALL instruction into a branch");
let ref ops = inst.ops;
......@@ -390,7 +391,10 @@ impl Inlining {
fn new_inlined_block_name(old_block_name: MuName, vm: &VM) -> MuEntityHeader {
let new_id = vm.next_id();
MuEntityHeader::named(new_id, Arc::new(format!("{}:inlinedblock.#{}", old_block_name, new_id)))
MuEntityHeader::named(
new_id,
Arc::new(format!("{}:inlinedblock.#{}", old_block_name, new_id))
)
}
/// copies blocks from callee to caller, with specified entry block and return block
fn copy_inline_blocks(
......
......@@ -95,12 +95,18 @@ fn emit_uir(suffix: &str, func_ver: &MuFunctionVersion, vm: &VM) {
fn emit_uir_inner(file: &mut File, func_name: MuName, func_ver: &MuFunctionVersion) {
let f_content = func_ver.content.as_ref().unwrap();
writeln!(file, ".funcdef {} <{}> VERSION {}{{", func_name, func_ver.sig, func_ver.name()).unwrap();
// self.abbreviate_name()
writeln!(
file,
".funcdef {} <{}> VERSION {}",
func_name,
func_ver.sig,
func_ver.hdr.abbreviate_name()
).unwrap();
writeln!(file, "{{").unwrap();
// every basic block
for (_, block) in f_content.blocks.iter() {
write!(file, "\t{}", block.name()).unwrap();
write!(file, "\t{}", block.hdr.abbreviate_name()).unwrap();
let block_content = block.content.as_ref().unwrap();
// (args)
write!(file, "(").unwrap();
......@@ -119,15 +125,13 @@ fn emit_uir_inner(file: &mut File, func_name: MuName, func_ver: &MuFunctionVersi
}
writeln!(file, ":").unwrap();
writeln!(file, "\t{{").unwrap();
// all the instructions
for inst in block_content.body.iter() {
writeln!(file, "\t\t{}", inst.as_inst_ref()).unwrap();
}
// "];
writeln!(file, "\n\t}}").unwrap();
writeln!(file, "").unwrap();
}
writeln!(file, "}}").unwrap();
}
......
......@@ -30,4 +30,4 @@ mod test_inline;
mod test_convop;
mod test_int128;
mod test_misc;
mod test_opt;
\ No newline at end of file
mod test_opt;
......@@ -912,7 +912,7 @@ pub fn hybrid_var_part_insts() -> VM {
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_head_sum);
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_head_n);
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_head_i);
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_head_a);
ssa! ((vm, hybrid_var_part_insts_v1) <ref_hybrid> blk_head_a);
// %cond = SLT <@int64> %i %n
ssa! ((vm, hybrid_var_part_insts_v1) <int1> blk_head_cond);
......@@ -940,7 +940,7 @@ pub fn hybrid_var_part_insts() -> VM {
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_body_sum);
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_body_n);
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_body_i);
ssa! ((vm, hybrid_var_part_insts_v1) <int64> blk_body_a);
ssa! ((vm, hybrid_var_part_insts_v1) <ref_hybrid> blk_body_a);
// %blk_body_iref_a = GETIREF <@my_hybrid> a
ssa! ((vm, hybrid_var_part_insts_v1) <iref_hybrid> blk_body_iref_a);
......
......@@ -143,4 +143,4 @@ fn infinite_loop2() -> VM {
});
vm
}
\ No newline at end of file
}
......@@ -114,7 +114,7 @@ fn test_type_constructors() {
assert_type!(*types[4], "iref<int<8>>");
assert_type!(*types[5], "weakref<int<8>>");
assert_type!(*types[6], "uptr<int<8>>");
assert_type!(*types[7], "MyStructTag1(struct)");
assert_type!(*types[7], "MyStructTag1");
{
let map = STRUCT_TAG_MAP.read().unwrap();
let t7_struct_ty = map.get(&"MyStructTag1".to_string()).unwrap();
......@@ -152,7 +152,7 @@ fn test_cyclic_struct() {
let map = STRUCT_TAG_MAP.read().unwrap();
let struct_ty = map.get(&"MyStructTag2".to_string()).unwrap();
assert_type!(struct_ty, "struct<ref<MyStructTag2(struct)> int<32>>");
assert_type!(struct_ty, "struct<ref<MyStructTag2> int<32>>");
}
#[test]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment