diff options
-rw-r--r-- | src/binary-reader-opcnt.cc | 18 | ||||
-rw-r--r-- | test/opcodecnt/basic.txt | 10 | ||||
-rw-r--r-- | test/opcodecnt/immediates.txt | 10 |
3 files changed, 24 insertions, 14 deletions
diff --git a/src/binary-reader-opcnt.cc b/src/binary-reader-opcnt.cc index a837b114..40f68d22 100644 --- a/src/binary-reader-opcnt.cc +++ b/src/binary-reader-opcnt.cc @@ -24,6 +24,7 @@ #include "binary-reader-nop.h" #include "common.h" +#include "literal.h" #include "stream.h" namespace wabt { @@ -84,24 +85,33 @@ void OpcodeInfo::Write(Stream& stream) { break; case Kind::Uint32: - stream.Writef(" %u", *GetData<uint32_t>()); + stream.Writef(" %u (0x%x)", *GetData<uint32_t>(), *GetData<uint32_t>()); break; case Kind::Uint64: - stream.Writef(" %" PRIu64, *GetData<uint64_t>()); + stream.Writef(" %" PRIu64 " (0x%" PRIx64 ")", *GetData<uint64_t>(), + *GetData<uint64_t>()); break; case Kind::Index: stream.Writef(" %" PRIindex, *GetData<Index>()); break; - case Kind::Float32: + case Kind::Float32: { stream.Writef(" %g", *GetData<float>()); + char buffer[WABT_MAX_FLOAT_HEX + 1]; + WriteFloatHex(buffer, sizeof(buffer), *GetData<uint32_t>()); + stream.Writef(" (%s)", buffer); break; + } - case Kind::Float64: + case Kind::Float64: { stream.Writef(" %g", *GetData<double>()); + char buffer[WABT_MAX_DOUBLE_HEX + 1]; + WriteDoubleHex(buffer, sizeof(buffer), *GetData<uint64_t>()); + stream.Writef(" (%s)", buffer); break; + } case Kind::Uint32Uint32: WriteArray<uint32_t>( diff --git a/test/opcodecnt/basic.txt b/test/opcodecnt/basic.txt index 68ec37b4..a5e8d9e3 100644 --- a/test/opcodecnt/basic.txt +++ b/test/opcodecnt/basic.txt @@ -35,10 +35,10 @@ end: 2 br 0: 2 get_local 1: 2 i32.load 2, 0: 1 -i32.const 0: 1 -i32.const 1: 1 -i32.const 2: 1 -f32.const 2: 1 -f32.const 1: 1 +i32.const 0 (0x0): 1 +i32.const 1 (0x1): 1 +i32.const 2 (0x2): 1 +f32.const 2 (0x1p+1): 1 +f32.const 1 (0x1p+0): 1 f32.add: 1 ;;; STDOUT ;;) diff --git a/test/opcodecnt/immediates.txt b/test/opcodecnt/immediates.txt index 624decf7..7ded6b7c 100644 --- a/test/opcodecnt/immediates.txt +++ b/test/opcodecnt/immediates.txt @@ -50,7 +50,7 @@ f32.const: 1 f64.const: 1 Opcode counts with immediates: -i32.const 0: 4 +i32.const 0 (0x0): 4 end: 3 unreachable: 1 block: 1 @@ -60,8 +60,8 @@ br_table 0, 0, 0, 0, 0, 0: 1 return: 1 i32.load 2, 1: 1 i32.store 2, 3: 1 -i32.const 1: 1 -i64.const 2: 1 -f32.const 3.125: 1 -f64.const 4.5: 1 +i32.const 1 (0x1): 1 +i64.const 2 (0x2): 1 +f32.const 3.125 (0x1.9p+1): 1 +f64.const 4.5 (0x1.2p+2): 1 ;;; STDOUT ;;) |