-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc][stdfix] Implement fixed point bitsfx functions in llvm libc #128413
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f6ff5d5
add: implement bitsfx for signed fixed point numbers
krishna2803 f7beac1
add: tests for some signed `bitsfx`
krishna2803 e98d4e2
add: entrypoints for bitsfx
krishna2803 24b27c8
chore: change From and To to T and XType respectively
krishna2803 1785342
add: bitsu{fx}
krishna2803 752ea6d
chore: reposition bitsfx in CMakeLists
krishna2803 7099e88
add: tests for bitsu{fx} and make the code consistent with {fx}bits
krishna2803 893c49f
chore: update CMakeLists for bitsfx tests
krishna2803 a52a666
chore: update docs
krishna2803 aa047dd
add: tests for bitsulk
krishna2803 851fc4b
chore: update docs
krishna2803 ba09fad
merge: branch 'main' into implement-bitsfx
krishna2803 00cd464
merge: branch 'main' into implement-bitsfx
krishna2803 6bd8393
fix: unintentional rename of `from` to `T`
krishna2803 02d120e
feat: add tests for `signed char`
krishna2803 66800a7
feat: add tests for `short fract`
krishna2803 baf2511
feat: add more tests
krishna2803 9d0a7d2
chore: remove unwanted header
krishna2803 2f9b642
refactor: remove switch in lieu of bit shifts for accum tests
krishna2803 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation of bitshk function --------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "bitshk.h" | ||
| #include "include/llvm-libc-macros/stdfix-macros.h" // short accum | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_hk_t | ||
| #include "src/__support/common.h" // LLVM_LIBC_FUNCTION | ||
| #include "src/__support/fixed_point/fx_bits.h" // fixed_point | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int_hk_t, bitshk, (short accum f)) { | ||
| return fixed_point::bitsfx<short accum, int_hk_t>(f); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation header for bitshk function ---------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDFIX_BITSHK_H | ||
| #define LLVM_LIBC_SRC_STDFIX_BITSHK_H | ||
|
|
||
| #include "include/llvm-libc-macros/stdfix-macros.h" // short accum | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_hk_t | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| int_hk_t bitshk(short accum f); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDFIX_BITSHK_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation of bitshr function --------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "bitshr.h" | ||
| #include "include/llvm-libc-macros/stdfix-macros.h" // short fract | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_hr_t | ||
| #include "src/__support/common.h" // LLVM_LIBC_FUNCTION | ||
| #include "src/__support/fixed_point/fx_bits.h" // fixed_point | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int_hr_t, bitshr, (short fract f)) { | ||
| return fixed_point::bitsfx<short fract, int_hr_t>(f); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation header for bitshr function ---------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDFIX_BITSHR_H | ||
| #define LLVM_LIBC_SRC_STDFIX_BITSHR_H | ||
|
|
||
| #include "include/llvm-libc-macros/stdfix-macros.h" // short fract | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_hr_t | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| int_hr_t bitshr(short fract f); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDFIX_BITSHR_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation for bitsk function --------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "bitsk.h" | ||
| #include "include/llvm-libc-macros/stdfix-macros.h" // accum | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_k_t | ||
| #include "src/__support/common.h" // LLVM_LIBC_FUNCTION | ||
| #include "src/__support/fixed_point/fx_bits.h" // fixed_point | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int_k_t, bitsk, (accum f)) { | ||
| return fixed_point::bitsfx<accum, int_k_t>(f); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation header for bitsk function ----------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDFIX_BITSK_H | ||
| #define LLVM_LIBC_SRC_STDFIX_BITSK_H | ||
|
|
||
| #include "include/llvm-libc-macros/stdfix-macros.h" // accum | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_k_t | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| int_k_t bitsk(accum f); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDFIX_BITSK_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Implementation for bitslk function -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "bitslk.h" | ||
| #include "include/llvm-libc-macros/stdfix-macros.h" // long accum | ||
| #include "include/llvm-libc-types/stdfix-types.h" // int_lk_t | ||
| #include "src/__support/common.h" // LLVM_LIBC_FUNCTION | ||
| #include "src/__support/fixed_point/fx_bits.h" // fixed_point | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int_lk_t, bitslk, (long accum f)) { | ||
| return fixed_point::bitsfx<long accum, int_lk_t>(f); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is the
from->There intentional?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.
oh sorry, that's an artifact of me doing a find and replace of a silly variable name that i overlooked
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.
fixed in 6bd83934