37 Commits

Author SHA1 Message Date
b7decb3923 Add fixed point multiplication tests 2024-08-29 22:07:08 -07:00
89424a914e Rewrite test framework
This new framework does not automatically register test suites, but it
is much simpler to use. I might revisit the old approach later, but for
now this works, KISS.
2024-08-18 23:55:17 -07:00
c1fa39cd8c Add string_view equal/not equal comparison operators 2024-08-18 23:51:22 -07:00
0711ec1fc1 Add test running 2024-08-18 14:04:09 -07:00
589676854c Replace TARGET_ARM_MODE pragma with ARM_MODE function attributes 2024-08-03 17:28:27 -06:00
eb4412847e Add noexcept specifier to fixed point operations 2024-08-03 16:18:20 -06:00
b3a6dd48d0 Fix incorrect attribute placement on fixed::operator/
Function attributes should be placed in the function declaration, not
definition.
2024-08-03 16:15:17 -06:00
d0557bad3e Fix incorrect fixed point division result
Division was not returning the result as raw.
2024-08-02 23:26:24 -06:00
8d23f2cf09 Fix fixed point number compilation failures during attempted inlining
Currently, some fixed point operations (notably multiplication) fail to
compile when used in Thumb-mode routines. This occurs because GCC
attempts to inline the operation into the Thumb-mode routine, but the
operation uses ARM-mode only instructions. This commit adds the ".arm"
directive into the inline assembly of the implementation, which informs
GCC that the assembly uses ARM-mode instructions and prevents inlining.
As a result, fixed point numbers can be used from both ARM-mode and
Thumb-mode code without issues! Usage in ARM-mode should still be
preferred for optimal performance though.
2024-08-02 22:10:39 -06:00
233512f5b4 Add initial vector4 implementation 2024-07-30 11:49:07 -06:00
2181557d9d Remove conditional fixed point number inlining
Caused issues with ODR rule violations. Now fixed point numbers should
only be used in ARM-mode. Attempting to use them in Thumb-mode will
cause a compilation failure. This commit also moves operator/ into IWRAM
on the GBA.
2024-07-30 11:45:08 -06:00
9561686585 Optimize and expand fixed point number implementation
Before this commit, fixed point multiplication was implemented using an
assembly routine in a separate translation unit. This commit implements
this routine directly using inline assembly. By doing so, these
operations can be inlined when called from ARM code. Fixed point
division is implemented as well, along with various documentation and
style improvements.
2024-07-28 19:24:47 -06:00
f87111abbf Add ability to disable logging
If MTL_LOGGING_DISABLED is defined, logging is disabled. Otherwise, it
is enabled.
2024-06-19 19:36:26 -06:00
f354b2d733 Change log level to use an enum instead of uint 2024-06-19 19:29:45 -06:00
82f60f4767 Refactor string_stream and string_streamx, and provide ENDL selection
option

This commit refactors string_stream and string_streamx into a common
basic_string_stream template class. When the EXT template == true, the
string_streamx formatting options are enabled, they default to disabled.
These options are enabled at compile time, and do not affect performance
when they are disabled. By implementing the two streams in this manner,
duplicated code is removed.

This commit also adds the ENDL template paramter. When ENDL is set to
zero, no endline character is printed when piping mtl::endl. Otherwise,
the character is printed. Defaults to '\n'. This allows logging on the
GBA to handle mtl::endl correctly and not print two newlines on the MGBA
emulator.
2024-04-10 08:39:30 -06:00
554c88f7f2 Fix udiv100000 and udiv1000000000 ASM macros changing the source
register
2024-04-04 04:18:36 -06:00
4e56cb5269 Fix type stdin instead of stdout 2024-03-27 00:59:10 -06:00
3efafa84c2 Add log 2024-03-27 00:32:54 -06:00
04fcbecc43 Fix incorrect usage of platform specific function 2024-03-27 00:30:45 -06:00
1159162e50 Change armv4t integer to string conversion to use an unrolled loop
This implementation also writes the digits from left to right instead of
right to left. Using this method we can write the string to the
beginning of the buffer and still avoid reversing the string. It also
has the benefit of being slightly slower than the previous
implementation. The function's signature changed as well because there
is no longer a reason to pass the buffer size or a pointer to output the
start of the string.
2024-03-25 17:13:29 -06:00
bbb3c15002 Add armv4t assembly optimized integer to string conversion functions 2024-03-24 01:07:24 -06:00
2beab09f7d Add armv4t assembly optimized division and modulo by 10 2024-03-24 00:30:56 -06:00
dcb91bac19 Optimize string single character append
Now uses a specialized implementation instead of the append multiple
characters implementation. Useful for appending single characters to
string streams (ex. newline).
2024-03-21 20:35:22 -06:00
c8162e6974 Update CMakeLists.txt to use globbing, and support arch. dependent files
CONFIGURE_DEPENDS option was added in CMake v3.12. This option allows the
build system to automatically re-run CMake if the glob changes, solving the
major issue with globbing. May have a performance impact, but it should be
negligible compared to the time spent building.
2024-03-10 21:55:50 -06:00
9166710926 Implement istring replace, append, erase 2024-03-10 20:50:09 -06:00
d4b13b36f6 Implement istring comparison operators
Not thoroughly tested.
2024-03-07 21:29:44 -07:00
ef39d535e2 Remove iterators from string and string_view
Iterators could probably be implemented efficiently, but it is not a
priority at the moment. They are removed for the time being.
2024-03-07 19:38:00 -07:00
52d91aa752 Change istring to use string_view for the majority of its operations
The istring and string_view operators have identical implementations. By
changing the istring operators to cast to string_view and use that
implementation instead, the number of redundant implementations is
reduced. This does incurr a small performance penalty, around 15 cycles
when tested on the MGBA Gameboy Advance emulator (uses an armv7tdmi).
When compared to the time operations take, the performance difference is
negligible. Ex. An insertion with two 8 character strings takes around
450 cycles.
2024-03-07 16:28:18 -07:00
c9f3a57cfb Implement istring::insert with given index and count 2024-03-07 16:07:21 -07:00
232808770f Implement string::copy and string_view::copy 2024-03-07 15:57:29 -07:00
236b5661ad Fix mtl_rmemcpy32 incorrectly calculating the number of bytes and words 2024-03-07 15:53:10 -07:00
56ea8ad91d Change strings to use mtl::memmove instead of memcpy ot std::memmove 2024-03-07 14:32:46 -07:00
ecac9d2087 Change strings to use string_view instead of const char*
Because the length of a string_view is computed at compile time, it is
faster for simple copies.
2024-03-07 14:25:39 -07:00
913e54252a Add initial string_view implementation 2024-03-07 14:24:10 -07:00
34495b580b Add initial fixed point number implementation 2024-03-06 23:42:48 -07:00
dd07c57d7a Fix rmemcpy32 not copying chunks correctly 2024-03-06 23:00:38 -07:00
3f8bcf2f61 Add cmake files and initial memcpy/string implementation 2024-03-04 20:44:58 -07:00