Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl AllocatedAbstractInstructionSet {
comment,
}),
Either::Right(org_op) => match org_op {
ControlFlowOp::Jump { to, type_ } => {
ControlFlowOp::Jump { to, ty: type_ } => {
let target_offset = label_offsets.get(&to).unwrap().offs;
let ops = if matches!(type_, JumpType::Call) {
compile_call(
Expand Down Expand Up @@ -414,7 +414,7 @@ impl AllocatedAbstractInstructionSet {
Either::Left(_) => 1,

// Worst case for jump is 2 opcodes, and 3 for calls
Either::Right(Jump { ref type_, .. }) => match type_ {
Either::Right(Jump { ty: ref type_, .. }) => match type_ {
JumpType::Unconditional => 2,
JumpType::NotZero(_) => 2,
JumpType::Call => 3,
Expand Down Expand Up @@ -554,13 +554,13 @@ impl AllocatedAbstractInstructionSet {
for jump in jumps {
let offs = labelled_blocks.get(&jump.to).unwrap().offs;
let rel_offset = offs.abs_diff(jump.offset);
let Either::Right(ControlFlowOp::Jump { ref type_, .. }) = self.ops[jump.op_idx].opcode
let Either::Right(ControlFlowOp::Jump { ref ty, .. }) = self.ops[jump.op_idx].opcode
else {
unreachable!("Jump info should only be collected for jumps");
};
// Relative self jumps need a NOOP inserted before it so that we can jump to the NOOP.
let is_self_jump = rel_offset == 0;
match type_ {
match ty {
JumpType::Unconditional => {
// Unconditional jumps have 18-bit immidate offset
if is_self_jump || rel_offset > consts::EIGHTEEN_BITS {
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/asm_generation/fuel/fuel_asm_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl AsmBuilder for FuelAsmBuilder<'_, '_> {
self.before_entries.push(Op {
opcode: Either::Right(crate::asm_lang::ControlFlowOp::Jump {
to: *decode_fn_label,
type_: JumpType::Call,
ty: JumpType::Call,
}),
comment: format!("decode configurable {name}"),
owning_span: None,
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/asm_generation/fuel/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl FuelAsmBuilder<'_, '_> {
self.cur_bytecode.push(Op {
opcode: Either::Right(OrganizationalOp::Jump {
to: fn_label,
type_: JumpType::Call,
ty: JumpType::Call,
}),
comment: format!("[call: {fn_name}]: call function"),
owning_span: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl AbstractInstructionSet {
// - "JMP LABEL" if reg is not zero
if let Either::Right(ControlFlowOp::Jump {
to,
type_: JumpType::NotZero(reg),
ty: JumpType::NotZero(reg),
}) = &mut op.opcode
{
if let Some(con) = known_values.resolve(reg).and_then(|r| r.value()) {
Expand All @@ -198,7 +198,7 @@ impl AbstractInstructionSet {
} else {
op.opcode = Either::Right(ControlFlowOp::Jump {
to: *to,
type_: JumpType::Unconditional,
ty: JumpType::Unconditional,
});
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ impl AbstractInstructionSet {
ResetKnown::Defs
}
}
ControlFlowOp::Jump { type_, .. } => match type_ {
ControlFlowOp::Jump { ty: type_, .. } => match type_ {
JumpType::Call => ResetKnown::All,
_ => ResetKnown::Defs,
},
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/asm_generation/fuel/optimizations/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl AbstractInstructionSet {
(
Either::Right(OrganizationalOp::Jump {
to: dst_label,
type_: JumpType::Unconditional | JumpType::NotZero(_),
ty: JumpType::Unconditional | JumpType::NotZero(_),
..
}),
Either::Right(OrganizationalOp::Label(label)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ impl AbstractInstructionSet {
let mut op_def = op.def_registers();
op_def.append(&mut op.def_const_registers());

if let Either::Right(ControlFlowOp::Jump { type_, .. }) = &op.opcode {
if !matches!(type_, JumpType::Call) {
if let Either::Right(ControlFlowOp::Jump { ty, .. }) = &op.opcode {
if !matches!(ty, JumpType::Call) {
// Block boundary. Start afresh.
cur_live.clone_from(liveness.get(ix).expect("Incorrect liveness info"));
// Add use(op) to cur_live.
Expand Down
Loading