Skip to content
Closed
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
11 changes: 11 additions & 0 deletions conformance/sv-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ assigning a specparam to a value parameter is rejected, as required by 6.20.5;
an unreferenced specparam declaration remains accepted. No other expectation rows
are changed for these repairs.

The scalar floating-point implementation updates twenty reviewed expectation
rows: both state modes for `5.7.2-real-constants`, `5.7.2-real-token`,
`6.12--real`, `6.12--realtime`, `6.12--shortreal`, `6.24.1--cast_op`,
`20.5--itor`, `20.5--rtoi`, `20.5--real-bits-conv`, and
`20.5--shortreal-bits-conv` change from fail to pass. Full official runs at the
pinned revision report 472 passing cases in 2state and 474 in 4state, ten more
in each mode. No passing case regresses. The negative real-select and real-edge
cases retain their verdicts. The pinned `real_bit_select_idx` input is rejected
earlier for its undriven net, so a separate analyzer regression uses a driven
input to check that real-valued indices themselves are rejected.

The report contains each case’s state mode, verdict, selected execution mode,
tags, tool return code and path to the official log. The output directory retains
both the official log and runner diagnostics for each case and state mode.
Expand Down
40 changes: 20 additions & 20 deletions conformance/sv-tests/expected.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,14 @@ chapter-20/20.4--printtimescale.sv 2state pass
chapter-20/20.4--printtimescale.sv 4state pass
chapter-20/20.4--timeformat.sv 2state fail
chapter-20/20.4--timeformat.sv 4state fail
chapter-20/20.5--itor.sv 2state fail
chapter-20/20.5--itor.sv 4state fail
chapter-20/20.5--real-bits-conv.sv 2state fail
chapter-20/20.5--real-bits-conv.sv 4state fail
chapter-20/20.5--rtoi.sv 2state fail
chapter-20/20.5--rtoi.sv 4state fail
chapter-20/20.5--shortreal-bits-conv.sv 2state fail
chapter-20/20.5--shortreal-bits-conv.sv 4state fail
chapter-20/20.5--itor.sv 2state pass
chapter-20/20.5--itor.sv 4state pass
chapter-20/20.5--real-bits-conv.sv 2state pass
chapter-20/20.5--real-bits-conv.sv 4state pass
chapter-20/20.5--rtoi.sv 2state pass
chapter-20/20.5--rtoi.sv 4state pass
chapter-20/20.5--shortreal-bits-conv.sv 2state pass
chapter-20/20.5--shortreal-bits-conv.sv 4state pass
chapter-20/20.6--bits.sv 2state pass
chapter-20/20.6--bits.sv 4state pass
chapter-20/20.6--bits_type.sv 2state pass
Expand Down Expand Up @@ -1071,10 +1071,10 @@ chapter-5/5.7.1--integers-unsized.sv 2state pass
chapter-5/5.7.1--integers-unsized.sv 4state pass
chapter-5/5.7.2-real-constants-illegal.sv 2state pass
chapter-5/5.7.2-real-constants-illegal.sv 4state pass
chapter-5/5.7.2-real-constants.sv 2state fail
chapter-5/5.7.2-real-constants.sv 4state fail
chapter-5/5.7.2-real-token.sv 2state fail
chapter-5/5.7.2-real-token.sv 4state fail
chapter-5/5.7.2-real-constants.sv 2state pass
chapter-5/5.7.2-real-constants.sv 4state pass
chapter-5/5.7.2-real-token.sv 2state pass
chapter-5/5.7.2-real-token.sv 4state pass
chapter-5/5.8-time-literals.sv 2state fail
chapter-5/5.8-time-literals.sv 4state fail
chapter-5/5.9-string-assignment.sv 2state pass
Expand All @@ -1093,18 +1093,18 @@ chapter-6/6.10--implicit_port.sv 2state pass
chapter-6/6.10--implicit_port.sv 4state pass
chapter-6/6.10--implicit_port_connection.sv 2state pass
chapter-6/6.10--implicit_port_connection.sv 4state pass
chapter-6/6.12--real.sv 2state fail
chapter-6/6.12--real.sv 4state fail
chapter-6/6.12--real.sv 2state pass
chapter-6/6.12--real.sv 4state pass
chapter-6/6.12--real_bit_select.sv 2state pass
chapter-6/6.12--real_bit_select.sv 4state pass
chapter-6/6.12--real_bit_select_idx.sv 2state pass
chapter-6/6.12--real_bit_select_idx.sv 4state pass
chapter-6/6.12--real_edge.sv 2state pass
chapter-6/6.12--real_edge.sv 4state pass
chapter-6/6.12--realtime.sv 2state fail
chapter-6/6.12--realtime.sv 4state fail
chapter-6/6.12--shortreal.sv 2state fail
chapter-6/6.12--shortreal.sv 4state fail
chapter-6/6.12--realtime.sv 2state pass
chapter-6/6.12--realtime.sv 4state pass
chapter-6/6.12--shortreal.sv 2state pass
chapter-6/6.12--shortreal.sv 4state pass
chapter-6/6.13--void.sv 2state pass
chapter-6/6.13--void.sv 4state pass
chapter-6/6.14--chandle.sv 2state fail
Expand Down Expand Up @@ -1225,8 +1225,8 @@ chapter-6/6.23--type_op.sv 2state fail
chapter-6/6.23--type_op.sv 4state fail
chapter-6/6.23--type_op_compare.sv 2state fail
chapter-6/6.23--type_op_compare.sv 4state fail
chapter-6/6.24.1--cast_op.sv 2state fail
chapter-6/6.24.1--cast_op.sv 4state fail
chapter-6/6.24.1--cast_op.sv 2state pass
chapter-6/6.24.1--cast_op.sv 4state pass
chapter-6/6.24.2--cast_fn.sv 2state fail
chapter-6/6.24.2--cast_fn.sv 4state fail
chapter-6/6.24.2--cast_task.sv 2state fail
Expand Down
53 changes: 52 additions & 1 deletion crates/celox-backend-arm64/src/isel/extern_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ fn extern_argument(ctx: &mut ISelContext, block: &mut MBlock, arg: RegisterId) -
/// Define `dst` from the C integer `result` of an extern call.
fn define_extern_result(ctx: &mut ISelContext, block: &mut MBlock, dst: RegisterId, result: VReg) {
let value = ctx.reg_map.get(dst);
let ty = ExternValue::of_verified(&ctx.register_types[&dst]);
let ty = ExternValue::of(&ctx.register_types[&dst]).unwrap_or(ExternValue::Integer {
width: ctx.sir_width(&dst),
signed: false,
});
match ty.result_value_mask() {
u64::MAX => block.push(MInst::Mov {
dst: value,
Expand Down Expand Up @@ -116,3 +119,51 @@ fn define_extern_result(ctx: &mut ISelContext, block: &mut MBlock, dst: Register
};
ctx.set_mask(dst, mask);
}

pub(super) fn lower_float(
ctx: &mut ISelContext,
block: &mut MBlock,
dst: RegisterId,
lhs: RegisterId,
rhs: Option<RegisterId>,
code: u64,
) {
let a = ctx.reg_map.get(lhs);
let a = if ctx.four_state && matches!(code & 255, 34 | 35) {
let mask = ctx.get_mask(lhs, block);
let known = ctx.alloc_vreg(SpillDesc::transient());
block.push(MInst::BitNot {
dst: known,
src: mask,
});
let value = ctx.alloc_vreg(SpillDesc::transient());
block.push(MInst::And {
dst: value,
lhs: a,
rhs: known,
});
value
} else {
a
};

let b = if let Some(rhs) = rhs {
ctx.reg_map.get(rhs)
} else {
let v = ctx.alloc_vreg(SpillDesc::remat(0));
block.push(MInst::LoadImm { dst: v, value: 0 });
v
};
let c = ctx.alloc_vreg(SpillDesc::remat(code));
block.push(MInst::LoadImm {
dst: c,
value: code,
});
let result = ctx.alloc_vreg(SpillDesc::transient());
block.push(MInst::CallExtern {
dst: Some(result),
func: celox_sir::float::FLOAT_HELPER_ID,
args: vec![a, b, c],
});
define_extern_result(ctx, block, dst, result);
}
6 changes: 6 additions & 0 deletions crates/celox-backend-arm64/src/isel/four_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ pub(super) fn lower_unary_mask(
src_width: usize,
) -> VReg {
match op {
UnaryOp::Float { .. } => {
unreachable!("float operations are lowered before integer operations")
}
UnaryOp::ToTwoState => {
let zero = ctx.alloc_vreg(SpillDesc::remat(0));
block.push(MInst::LoadImm {
Expand Down Expand Up @@ -1677,6 +1680,9 @@ pub(super) fn lower_wide_unary_mask(
let sm_chunks = get_wide_mask_chunks(ctx, block, &src, n_src);

match op {
UnaryOp::Float { .. } => {
unreachable!("float operations are lowered before integer operations")
}
UnaryOp::ToTwoState => {
let n_dst = ISelContext::num_chunks(d_width);
let mut dst_m_chunks = Vec::with_capacity(n_dst);
Expand Down
28 changes: 28 additions & 0 deletions crates/celox-backend-arm64/src/isel/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,17 @@ pub(super) fn lower_instruction(
}

SIRInstruction::Binary(dst, lhs, op, rhs) => {
if let BinaryOp::Float { op, precision } = op {
extern_call::lower_float(
ctx,
block,
*dst,
*lhs,
Some(*rhs),
celox_sir::float::binary_code(*op, *precision),
);
return;
}
let d_width = ctx.sir_width(dst);
let lhs_width = ctx.sir_width(lhs);
let rhs_width = ctx.sir_width(rhs);
Expand Down Expand Up @@ -2070,6 +2081,9 @@ pub(super) fn lower_instruction(
let rhs_vreg = ctx.reg_map.get(*rhs);

match op {
BinaryOp::Float { .. } => {
unreachable!("float operations are lowered before integer operations")
}
BinaryOp::Add | BinaryOp::Sub | BinaryOp::Mul => {
// 64-bit arithmetic may produce upper bits; mask to output width.
let raw = if d_width < 64 {
Expand Down Expand Up @@ -2778,6 +2792,17 @@ pub(super) fn lower_instruction(
}

SIRInstruction::Unary(dst, op, src) => {
if let UnaryOp::Float { op, precision } = op {
extern_call::lower_float(
ctx,
block,
*dst,
*src,
None,
celox_sir::float::unary_code(*op, *precision),
);
return;
}
let d_width = ctx.sir_width(dst);
let src_width = ctx.sir_width(src);
debug_assert!(src_width > 64 || !ctx.wide_regs.contains_key(src));
Expand All @@ -2798,6 +2823,9 @@ pub(super) fn lower_instruction(
let src_vreg = ctx.reg_map.get(*src);

match op {
UnaryOp::Float { .. } => {
unreachable!("float operations are lowered before integer operations")
}
UnaryOp::Ident | UnaryOp::ToTwoState => {
ctx.emit_mov(block, dst_vreg, src_vreg);
}
Expand Down
3 changes: 3 additions & 0 deletions crates/celox-backend-arm64/src/isel/wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ pub(super) fn lower_wide_binary(
}

match op {
BinaryOp::Float { .. } => {
unreachable!("float operations are lowered before integer operations")
}
// Chunk-wise operations: apply to each 64-bit chunk independently
BinaryOp::And | BinaryOp::Or | BinaryOp::Xor => {
let lhs_chunks = ctx.get_wide_chunks(&lhs, block);
Expand Down
3 changes: 3 additions & 0 deletions crates/celox-backend-arm64/src/isel/wide_unary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub(super) fn lower_wide_unary(
let n_chunks = ISelContext::num_chunks(d_width.max(src_width));

match op {
UnaryOp::Float { .. } => {
unreachable!("float operations are lowered before integer operations")
}
UnaryOp::BitNot => {
let src_chunks = ctx.get_wide_chunks(&src, block);
let mut dst_chunks = Vec::with_capacity(n_chunks);
Expand Down
7 changes: 6 additions & 1 deletion crates/celox-backend-arm64/src/scalar/extern_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ pub(super) fn emit_call_extern(
celox_state_layout::STATE_HEADER_EXTERN_FUNCTIONS_ADDR_OFFSET as i64,
OpSize::S64,
);
emit_load_at(ops, SCRATCH1, SCRATCH1, i64::from(func) * 8, OpSize::S64);
let offset = if func == celox_sir::float::FLOAT_HELPER_ID {
-8
} else {
i64::from(func) * 8
};
emit_load_at(ops, SCRATCH1, SCRATCH1, offset, OpSize::S64);
dynasm!(ops ; .arch aarch64 ; blr x17);

// The result interferes with every value live across the call, so the
Expand Down
23 changes: 23 additions & 0 deletions crates/celox-backend-cranelift/src/translator/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ impl SIRTranslator {
op: &BinaryOp,
rhs: &RegisterId,
) {
if let BinaryOp::Float { op, precision } = op {
self.translate_float(
state,
*dst,
*lhs,
Some(*rhs),
celox_sir::float::binary_code(*op, *precision),
);
return;
}
let l_width = state.register_map[lhs].width();
let r_width = state.register_map[rhs].width();
let d_width = state.register_map[dst].width();
Expand Down Expand Up @@ -396,6 +406,7 @@ impl SIRTranslator {
};

let mut res_v = match op {
BinaryOp::Float { .. } => unreachable!("lowered separately"),
BinaryOp::Add => state.builder.ins().iadd(l, r),
BinaryOp::Sub => state.builder.ins().isub(l, r),
BinaryOp::Mul => state.builder.ins().imul(l, r),
Expand Down Expand Up @@ -1390,6 +1401,16 @@ impl SIRTranslator {
op: &UnaryOp,
rhs: &RegisterId,
) {
if let UnaryOp::Float { op, precision } = op {
self.translate_float(
state,
*dst,
*rhs,
None,
celox_sir::float::unary_code(*op, *precision),
);
return;
}
if matches!(
op,
UnaryOp::PopCount | UnaryOp::CountLeadingZeros | UnaryOp::CountTrailingZeros
Expand All @@ -1414,6 +1435,7 @@ impl SIRTranslator {
let r = promote_to_physical(state, r_val, r_width, r_is_signed, common_ty);

let res_v = match op {
UnaryOp::Float { .. } => unreachable!("lowered separately"),
UnaryOp::Minus => state.builder.ins().ineg(r),
UnaryOp::Ident | UnaryOp::ToTwoState => r,
UnaryOp::BitNot => {
Expand Down Expand Up @@ -1475,6 +1497,7 @@ impl SIRTranslator {
let r_m = promote_to_physical(state, r_m_val, r_width, r_is_signed, common_ty);

let res_m = match op {
UnaryOp::Float { .. } => unreachable!("lowered separately"),
UnaryOp::Ident | UnaryOp::BitNot => r_m,
UnaryOp::ToTwoState => state.builder.ins().iconst(common_ty, 0),
UnaryOp::LogicNot | UnaryOp::Or => {
Expand Down
Loading
Loading