changeset fdd2d34b0871 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=fdd2d34b0871
description:
mips: Floating point convert bug fix
In mips architecture, floating point convert instructions use the
FloatConvertOp format defined in src/arch/mips/isa/formats/fp.isa. The
type
of the operands in the ISA description file (_sw for signed word, or
_sf for
signed float, etc.) is used to create a type for the operand in C++.
Then the
operand is converted using the fpConvert() function in
src/arch/mips/utility.cc.
If we are converting from a word to a float, and we want to convert
0xffffffff,
we expect -1 to be passed into fpConvert(). Instead, we see MAX_INT
passed in.
Then fpConvert() converts _val_ to MAX_INT in single-precision floating
point,
and we get the wrong value.
To fix it, the signs of the convert operands are being changed from
unsigned to
signed in the MIPS ISA description.
Then, the FloatConvertOp format is being changed to insert a int32_t
into the
C++ code instead of a uint32_t.
Committed by: Nilay Vaish <[email protected]>
diffstat:
src/arch/mips/isa/decoder.isa | 8 ++++----
src/arch/mips/isa/formats/fp.isa | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diffs (44 lines):
diff -r 4b872fdba3af -r fdd2d34b0871 src/arch/mips/isa/decoder.isa
--- a/src/arch/mips/isa/decoder.isa Thu Dec 26 15:18:58 2013 -0600
+++ b/src/arch/mips/isa/decoder.isa Sun Dec 29 19:29:45 2013 -0600
@@ -1242,8 +1242,8 @@
//Field When rs=W
0x4: decode FUNCTION {
format FloatConvertOp {
- 0x20: cvt_s_w({{ val = Fs_uw; }}, ToSingle);
- 0x21: cvt_d_w({{ val = Fs_uw; }}, ToDouble);
+ 0x20: cvt_s_w({{ val = Fs_sw; }}, ToSingle);
+ 0x21: cvt_d_w({{ val = Fs_sw; }}, ToDouble);
0x26: CP1Unimpl::cvt_ps_w();
}
default: CP1Unimpl::unknown();
@@ -1255,8 +1255,8 @@
//floating point operations are enabled."
0x5: decode FUNCTION {
format FloatConvertOp {
- 0x20: cvt_s_l({{ val = Fs_ud; }}, ToSingle);
- 0x21: cvt_d_l({{ val = Fs_ud; }}, ToDouble);
+ 0x20: cvt_s_l({{ val = Fs_sd; }}, ToSingle);
+ 0x21: cvt_d_l({{ val = Fs_sd; }}, ToDouble);
0x26: CP1Unimpl::cvt_ps_l();
}
default: CP1Unimpl::unknown();
diff -r 4b872fdba3af -r fdd2d34b0871 src/arch/mips/isa/formats/fp.isa
--- a/src/arch/mips/isa/formats/fp.isa Thu Dec 26 15:18:58 2013 -0600
+++ b/src/arch/mips/isa/formats/fp.isa Sun Dec 29 19:29:45 2013 -0600
@@ -268,11 +268,11 @@
elif '_df' in code:
code = 'double ' + code + '\n'
convert += 'DOUBLE_TO_'
- elif '_uw' in code:
- code = 'uint32_t ' + code + '\n'
+ elif '_sw' in code:
+ code = 'int32_t ' + code + '\n'
convert += 'WORD_TO_'
- elif '_ud' in code:
- code = 'uint64_t ' + code + '\n'
+ elif '_sd' in code:
+ code = 'int64_t ' + code + '\n'
convert += 'LONG_TO_'
else:
sys.exit("Error Determining Source Type for Conversion")
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev