Mass rename Ebb and relatives to Block (#1365)

* Manually rename BasicBlock to BlockPredecessor

BasicBlock is a pair of (Ebb, Inst) that is used to represent the
basic block subcomponent of an Ebb that is a predecessor to an Ebb.

Eventually we will be able to remove this struct, but for now it
makes sense to give it a non-conflicting name so that we can start
to transition Ebb to represent a basic block.

I have not updated any comments that refer to BasicBlock, as
eventually we will remove BlockPredecessor and replace with Block,
which is a basic block, so the comments will become correct.

* Manually rename SSABuilder block types to avoid conflict

SSABuilder has its own Block and BlockData types. These along with
associated identifier will cause conflicts in a later commit, so
they are renamed to be more verbose here.

* Automatically rename 'Ebb' to 'Block' in *.rs

* Automatically rename 'EBB' to 'block' in *.rs

* Automatically rename 'ebb' to 'block' in *.rs

* Automatically rename 'extended basic block' to 'basic block' in *.rs

* Automatically rename 'an basic block' to 'a basic block' in *.rs

* Manually update comment for `Block`

`Block`'s wikipedia article required an update.

* Automatically rename 'an `Block`' to 'a `Block`' in *.rs

* Automatically rename 'extended_basic_block' to 'basic_block' in *.rs

* Automatically rename 'ebb' to 'block' in *.clif

* Manually rename clif constant that contains 'ebb' as substring to avoid conflict

* Automatically rename filecheck uses of 'EBB' to 'BB'

'regex: EBB' -> 'regex: BB'
'$EBB' -> '$BB'

* Automatically rename 'EBB' 'Ebb' to 'block' in *.clif

* Automatically rename 'an block' to 'a block' in *.clif

* Fix broken testcase when function name length increases

Test function names are limited to 16 characters. This causes
the new longer name to be truncated and fail a filecheck test. An
outdated comment was also fixed.
This commit is contained in:
Ryan Hunt
2020-02-07 10:46:47 -06:00
committed by GitHub
parent a136d1cb00
commit 832666c45e
370 changed files with 8090 additions and 7988 deletions

View File

@@ -6,8 +6,8 @@
use crate::entity::SecondaryMap;
use crate::ir::entities::AnyEntity;
use crate::ir::{
DataFlowGraph, DisplayFunctionAnnotations, Ebb, Function, Inst, SigRef, Type, Value, ValueDef,
ValueLoc,
Block, DataFlowGraph, DisplayFunctionAnnotations, Function, Inst, SigRef, Type, Value,
ValueDef, ValueLoc,
};
use crate::isa::{RegInfo, TargetIsa};
use crate::packed_option::ReservedValue;
@@ -19,13 +19,13 @@ use core::fmt::{self, Write};
/// A `FuncWriter` used to decorate functions during printing.
pub trait FuncWriter {
/// Write the extended basic block header for the current function.
fn write_ebb_header(
/// Write the basic block header for the current function.
fn write_block_header(
&mut self,
w: &mut dyn Write,
func: &Function,
isa: Option<&dyn TargetIsa>,
ebb: Ebb,
block: Block,
indent: usize,
) -> fmt::Result;
@@ -145,15 +145,15 @@ impl FuncWriter for PlainWriter {
write_instruction(w, func, aliases, isa, inst, indent)
}
fn write_ebb_header(
fn write_block_header(
&mut self,
w: &mut dyn Write,
func: &Function,
isa: Option<&dyn TargetIsa>,
ebb: Ebb,
block: Block,
indent: usize,
) -> fmt::Result {
write_ebb_header(w, func, isa, ebb, indent)
write_block_header(w, func, isa, block, indent)
}
}
@@ -196,11 +196,11 @@ pub fn decorate_function<FW: FuncWriter>(
writeln!(w, " {{")?;
let aliases = alias_map(func);
let mut any = func_w.write_preamble(w, func, regs)?;
for ebb in &func.layout {
for block in &func.layout {
if any {
writeln!(w)?;
}
decorate_ebb(func_w, w, func, &aliases, annotations, ebb)?;
decorate_block(func_w, w, func, &aliases, annotations, block)?;
any = true;
}
writeln!(w, "}}")
@@ -235,24 +235,24 @@ fn write_arg(
/// Write out the basic block header, outdented:
///
/// ebb1:
/// ebb1(v1: i32):
/// ebb10(v4: f64, v5: b1):
/// block1:
/// block1(v1: i32):
/// block10(v4: f64, v5: b1):
///
pub fn write_ebb_header(
pub fn write_block_header(
w: &mut dyn Write,
func: &Function,
isa: Option<&dyn TargetIsa>,
ebb: Ebb,
block: Block,
indent: usize,
) -> fmt::Result {
// The `indent` is the instruction indentation. EBB headers are 4 spaces out from that.
write!(w, "{1:0$}{2}", indent - 4, "", ebb)?;
// The `indent` is the instruction indentation. block headers are 4 spaces out from that.
write!(w, "{1:0$}{2}", indent - 4, "", block)?;
let regs = isa.map(TargetIsa::register_info);
let regs = regs.as_ref();
let mut args = func.dfg.ebb_params(ebb).iter().cloned();
let mut args = func.dfg.block_params(block).iter().cloned();
match args.next() {
None => return writeln!(w, ":"),
Some(arg) => {
@@ -309,13 +309,13 @@ fn write_value_range_markers(
Ok(())
}
fn decorate_ebb<FW: FuncWriter>(
fn decorate_block<FW: FuncWriter>(
func_w: &mut FW,
w: &mut dyn Write,
func: &Function,
aliases: &SecondaryMap<Value, Vec<Value>>,
annotations: &DisplayFunctionAnnotations,
ebb: Ebb,
block: Block,
) -> fmt::Result {
// Indent all instructions if any encodings are present.
let indent = if func.encodings.is_empty() && func.srclocs.is_empty() {
@@ -325,8 +325,8 @@ fn decorate_ebb<FW: FuncWriter>(
};
let isa = annotations.isa;
func_w.write_ebb_header(w, func, isa, ebb, indent)?;
for a in func.dfg.ebb_params(ebb).iter().cloned() {
func_w.write_block_header(w, func, isa, block, indent)?;
for a in func.dfg.block_params(block).iter().cloned() {
write_value_aliases(w, aliases, a, indent)?;
}
@@ -334,7 +334,7 @@ fn decorate_ebb<FW: FuncWriter>(
if !func.offsets.is_empty() {
let encinfo = isa.encoding_info();
let regs = &isa.register_info();
for (offset, inst, size) in func.inst_offsets(ebb, &encinfo) {
for (offset, inst, size) in func.inst_offsets(block, &encinfo) {
func_w.write_instruction(w, func, aliases, Some(isa), inst, indent)?;
if size > 0 {
if let Some(val_ranges) = annotations.value_ranges {
@@ -346,7 +346,7 @@ fn decorate_ebb<FW: FuncWriter>(
}
}
for inst in func.layout.ebb_insts(ebb) {
for inst in func.layout.block_insts(block) {
func_w.write_instruction(w, func, aliases, isa, inst, indent)?;
}
@@ -374,11 +374,11 @@ fn type_suffix(func: &Function, inst: Inst) -> Option<Type> {
// operand, we don't need the type suffix.
if constraints.use_typevar_operand() {
let ctrl_var = inst_data.typevar_operand(&func.dfg.value_lists).unwrap();
let def_ebb = match func.dfg.value_def(ctrl_var) {
ValueDef::Result(instr, _) => func.layout.inst_ebb(instr),
ValueDef::Param(ebb, _) => Some(ebb),
let def_block = match func.dfg.value_def(ctrl_var) {
ValueDef::Result(instr, _) => func.layout.inst_block(instr),
ValueDef::Param(block, _) => Some(block),
};
if def_ebb.is_some() && def_ebb == func.layout.inst_ebb(inst) {
if def_block.is_some() && def_block == func.layout.inst_block(inst) {
return None;
}
}
@@ -533,7 +533,7 @@ pub fn write_operands(
..
} => {
write!(w, " {}", destination)?;
write_ebb_args(w, args.as_slice(pool))
write_block_args(w, args.as_slice(pool))
}
Branch {
destination,
@@ -542,7 +542,7 @@ pub fn write_operands(
} => {
let args = args.as_slice(pool);
write!(w, " {}, {}", args[0], destination)?;
write_ebb_args(w, &args[1..])
write_block_args(w, &args[1..])
}
BranchInt {
cond,
@@ -552,7 +552,7 @@ pub fn write_operands(
} => {
let args = args.as_slice(pool);
write!(w, " {} {}, {}", cond, args[0], destination)?;
write_ebb_args(w, &args[1..])
write_block_args(w, &args[1..])
}
BranchFloat {
cond,
@@ -562,7 +562,7 @@ pub fn write_operands(
} => {
let args = args.as_slice(pool);
write!(w, " {} {}, {}", cond, args[0], destination)?;
write_ebb_args(w, &args[1..])
write_block_args(w, &args[1..])
}
BranchIcmp {
cond,
@@ -572,7 +572,7 @@ pub fn write_operands(
} => {
let args = args.as_slice(pool);
write!(w, " {} {}, {}, {}", cond, args[0], args[1], destination)?;
write_ebb_args(w, &args[2..])
write_block_args(w, &args[2..])
}
BranchTable {
arg,
@@ -714,8 +714,8 @@ pub fn write_operands(
}
}
/// Write EBB args using optional parantheses.
fn write_ebb_args(w: &mut dyn Write, args: &[Value]) -> fmt::Result {
/// Write block args using optional parantheses.
fn write_block_args(w: &mut dyn Write, args: &[Value]) -> fmt::Result {
if args.is_empty() {
Ok(())
} else {
@@ -775,33 +775,33 @@ mod tests {
"function %foo() fast {\n ss0 = explicit_slot 4\n}\n"
);
let ebb = f.dfg.make_ebb();
f.layout.append_ebb(ebb);
let block = f.dfg.make_block();
f.layout.append_block(block);
assert_eq!(
f.to_string(),
"function %foo() fast {\n ss0 = explicit_slot 4\n\nebb0:\n}\n"
"function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0:\n}\n"
);
f.dfg.append_ebb_param(ebb, types::I8);
f.dfg.append_block_param(block, types::I8);
assert_eq!(
f.to_string(),
"function %foo() fast {\n ss0 = explicit_slot 4\n\nebb0(v0: i8):\n}\n"
"function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0(v0: i8):\n}\n"
);
f.dfg.append_ebb_param(ebb, types::F32.by(4).unwrap());
f.dfg.append_block_param(block, types::F32.by(4).unwrap());
assert_eq!(
f.to_string(),
"function %foo() fast {\n ss0 = explicit_slot 4\n\nebb0(v0: i8, v1: f32x4):\n}\n"
"function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0(v0: i8, v1: f32x4):\n}\n"
);
{
let mut cursor = FuncCursor::new(&mut f);
cursor.set_position(CursorPosition::After(ebb));
cursor.set_position(CursorPosition::After(block));
cursor.ins().return_(&[])
};
assert_eq!(
f.to_string(),
"function %foo() fast {\n ss0 = explicit_slot 4\n\nebb0(v0: i8, v1: f32x4):\n return\n}\n"
"function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0(v0: i8, v1: f32x4):\n return\n}\n"
);
}
@@ -811,18 +811,18 @@ mod tests {
let mut func = Function::new();
{
let ebb0 = func.dfg.make_ebb();
let block0 = func.dfg.make_block();
let mut pos = FuncCursor::new(&mut func);
pos.insert_ebb(ebb0);
pos.insert_block(block0);
// make some detached values for change_to_alias
let v0 = pos.func.dfg.append_ebb_param(ebb0, types::I32);
let v1 = pos.func.dfg.append_ebb_param(ebb0, types::I32);
let v2 = pos.func.dfg.append_ebb_param(ebb0, types::I32);
pos.func.dfg.detach_ebb_params(ebb0);
let v0 = pos.func.dfg.append_block_param(block0, types::I32);
let v1 = pos.func.dfg.append_block_param(block0, types::I32);
let v2 = pos.func.dfg.append_block_param(block0, types::I32);
pos.func.dfg.detach_block_params(block0);
// alias to a param--will be printed at beginning of ebb defining param
let v3 = pos.func.dfg.append_ebb_param(ebb0, types::I32);
// alias to a param--will be printed at beginning of block defining param
let v3 = pos.func.dfg.append_block_param(block0, types::I32);
pos.func.dfg.change_to_alias(v0, v3);
// alias to an alias--should print attached to alias, not ultimate target
@@ -837,7 +837,7 @@ mod tests {
}
assert_eq!(
func.to_string(),
"function u0:0() fast {\nebb0(v3: i32):\n v0 -> v3\n v2 -> v0\n v4 = iconst.i32 42\n v5 = iadd v0, v0\n v1 -> v5\n v6 = iconst.i32 23\n v7 = iadd v1, v1\n}\n"
"function u0:0() fast {\nblock0(v3: i32):\n v0 -> v3\n v2 -> v0\n v4 = iconst.i32 42\n v5 = iadd v0, v0\n v1 -> v5\n v6 = iconst.i32 23\n v7 = iadd v1, v1\n}\n"
);
}
}