Skip to content
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

Merged
merged 3 commits into from
Aug 11, 2020
Merged

Implement floating point memory instructions #456

merged 3 commits into from
Aug 11, 2020

Conversation

gumb0
Copy link
Collaborator

@gumb0 gumb0 commented Aug 4, 2020

No description provided.

lib/fizzy/execute.cpp Outdated Show resolved Hide resolved
@@ -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>)
Copy link
Collaborator

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...

@@ -340,12 +342,21 @@ inline bool load_from_memory(
return true;
}

template <typename T>
inline T pop_store_memory_arg(OperandStack& stack) noexcept
Copy link
Collaborator

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
Copy link

codecov bot commented Aug 5, 2020

Codecov Report

Merging #456 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##           master     #456    +/-   ##
========================================
  Coverage   99.52%   99.53%            
========================================
  Files          54       54            
  Lines       15507    15821   +314     
========================================
+ Hits        15433    15747   +314     
  Misses         74       74            

@gumb0 gumb0 force-pushed the memory-float branch 3 times, most recently from cce59e4 to 1b1f73e Compare August 5, 2020 17:45
test/spectests/spectests.cpp Outdated Show resolved Hide resolved
@axic axic changed the base branch from master to fp_utils August 7, 2020 10:59
@chfast chfast force-pushed the fp_utils branch 3 times, most recently from 707f100 to 167c41b Compare August 7, 2020 13:32
Base automatically changed from fp_utils to master August 7, 2020 13:51
@axic
Copy link
Member

axic commented Aug 7, 2020

Please rebase

@gumb0 gumb0 force-pushed the memory-float branch 9 times, most recently from c982cc0 to cf6d852 Compare August 11, 2020 10:25
@gumb0 gumb0 force-pushed the memory-float branch 2 times, most recently from c75b2e0 to f58e876 Compare August 11, 2020 10:30
@gumb0 gumb0 marked this pull request as ready for review August 11, 2020 10:30
@gumb0 gumb0 requested review from axic and chfast August 11, 2020 10:38
(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)
Copy link
Member

@axic axic Aug 11, 2020

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?

Copy link
Collaborator Author

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

Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Collaborator

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.

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@gumb0 gumb0 force-pushed the memory-float branch 2 times, most recently from 07555c1 to 85ee1c1 Compare August 11, 2020 18:28
@gumb0 gumb0 requested review from axic and chfast August 11, 2020 18:35
return value.as<DstT>();
else
{
// Could use `.as<DstT>()` would we have overloads for uint8_t/uint16_t,
Copy link
Member

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.

Copy link
Member

@axic axic left a 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.

@chfast chfast merged commit edf0288 into master Aug 11, 2020
@chfast chfast deleted the memory-float branch August 11, 2020 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants