-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement floating point memory instructions #456
Conversation
lib/fizzy/execute.cpp
Outdated
@@ -315,7 +315,12 @@ inline T load(bytes_view input, size_t offset) noexcept | |||
template <typename DstT, typename SrcT> | |||
inline DstT extend(SrcT in) noexcept | |||
{ | |||
if constexpr (std::is_signed<SrcT>::value) | |||
if constexpr (std::is_floating_point_v<SrcT>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I like additional levels of generic helpers. But in this case I propose simpler implementation.
if constexpr (std::is_same_v<SrcT, DstT>)
return in;
// Handle else...
lib/fizzy/execute.cpp
Outdated
@@ -340,12 +342,21 @@ inline bool load_from_memory( | |||
return true; | |||
} | |||
|
|||
template <typename T> | |||
inline T pop_store_memory_arg(OperandStack& stack) noexcept |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see reason to pass OperandStack
in. Better to take Value
as argument and make it similar to extend
. Maybe call it shrink
or trunc
then?
Codecov Report
@@ Coverage Diff @@
## master #456 +/- ##
========================================
Coverage 99.52% 99.53%
========================================
Files 54 54
Lines 15507 15821 +314
========================================
+ Hits 15433 15747 +314
Misses 74 74 |
cce59e4
to
1b1f73e
Compare
707f100
to
167c41b
Compare
Please rebase |
c982cc0
to
cf6d852
Compare
c75b2e0
to
f58e876
Compare
(data (i32.const 12) "\00\00\c0\7f") ;; canonical NaN | ||
(data (i32.const 16) "\01\00\c0\7f") ;; arithmetic NaN | ||
(data (i32.const 20) "\01\00\80\7f") ;; signaling NaN | ||
(func (param i32) (result f32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add all the representations from floating_point_utils
, i.e. include infinity and -0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added -0 and infinities, also to store tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't want to stretch it too much, but would it make sense having every case form floating_point_utils:double_as_uint
, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More cases would ask for a general table approach... I'm inclined to say it's not worth it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't want to stretch it too much, but would it make sense having every case form
floating_point_utils:double_as_uint
, etc?
These values are not very specific. As it is is fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they are nice examples though, and shows if any part (beginning or end) is cut from loading/storing.
(data (i32.const 24) "\00\00\00\00\00\00\f8\7f") ;; canonical NaN | ||
(data (i32.const 32) "\01\00\00\00\00\00\f8\7f") ;; arithmetic NaN | ||
(data (i32.const 40) "\01\00\00\00\00\00\f0\7f") ;; signaling NaN | ||
(func (param i32) (result f64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
07555c1
to
85ee1c1
Compare
return value.as<DstT>(); | ||
else | ||
{ | ||
// Could use `.as<DstT>()` would we have overloads for uint8_t/uint16_t, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a static assert for is_integral? Not sure it is important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me otherwise but should wait for @chfast's review too.
No description provided.