Skip to content

Commit

Permalink
w2c float literals: add decimal value in comment
Browse files Browse the repository at this point in the history
  • Loading branch information
keithw committed Feb 23, 2024
1 parent 52fd540 commit bf9bd7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/c-writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1251,11 +1251,13 @@ void CWriter::Write(const Const& const_) {
break;

case Type::F32:
Writef("f32_reinterpret_i32(0x%" PRIx32 ")", const_.f32_bits());
Writef("f32_reinterpret_i32(0x%" PRIx32 " /* %.9g */)", const_.f32_bits(),
Bitcast<float>(const_.f32_bits()));
break;

case Type::F64:
Writef("f64_reinterpret_i64(0x%" PRIx64 ")", const_.f64_bits());
Writef("f64_reinterpret_i64(0x%" PRIx64 " /* %.17g */)",
const_.f64_bits(), Bitcast<double>(const_.f64_bits()));
break;

case Type::V128: {
Expand Down
4 changes: 2 additions & 2 deletions test/wasm2c/tail-calls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ void w2c_test_tailcaller_0(w2c_test* instance) {
u32 var_i0, var_i2;
f32 var_f1;
var_i0 = 1u;
var_f1 = f32_reinterpret_i32(0x40000000);
var_f1 = f32_reinterpret_i32(0x40000000 /* 2 */);
var_i2 = 0u;
static_assert(sizeof(struct wasm_multi_if) <= 1024);
CHECK_CALL_INDIRECT(instance->w2c_tab, w2c_test_i32_f32, var_i2);
Expand Down Expand Up @@ -855,7 +855,7 @@ void wasm_tailcall_w2c_test_tailcaller_0(void **instance_ptr, void *tail_call_st
u32 var_i0, var_i2;
f32 var_f1;
var_i0 = 1u;
var_f1 = f32_reinterpret_i32(0x40000000);
var_f1 = f32_reinterpret_i32(0x40000000 /* 2 */);
var_i2 = 0u;
static_assert(sizeof(struct wasm_multi_if) <= 1024);
CHECK_CALL_INDIRECT(instance->w2c_tab, w2c_test_i32_f32, var_i2);
Expand Down

0 comments on commit bf9bd7b

Please sign in to comment.