mirror of
https://github.com/siemens-mobile-hacks/dc166-patch.git
synced 2026-11-25 19:37:24 +00:00
Support floating-point conditional expressions
This commit is contained in:
parent
b62387501d
commit
716361fa0f
5 changed files with 59 additions and 1 deletions
|
|
@ -5,7 +5,8 @@ Patches and runtime libraries for TASKING C166/ST10 v8.6r1 Build 753.
|
|||
Changes:
|
||||
|
||||
- removed compiler, linker and debugger demo restrictions;
|
||||
- enabled `float`/`double` code generation, fixed their Classic ABI and
|
||||
- enabled `float`/`double` code generation, including conditional
|
||||
expressions, fixed their Classic ABI and
|
||||
fixed IEEE `float`/`double` width conversions, including signed zero,
|
||||
subnormal values, round-to-nearest-even, infinities and NaNs, and fixed
|
||||
indexed `float` loads in Huge model;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
.equ emit_call, 0x00428db0
|
||||
.equ emit_indirect, 0x004531b0
|
||||
.equ emit_comma, 0x0041b580
|
||||
.equ emit_conditional,0x0041ec90
|
||||
.equ emit_deref, 0x004395c0
|
||||
.equ transfer_owner, 0x004187e0
|
||||
.equ release_owner, 0x00418800
|
||||
|
|
@ -139,6 +140,8 @@ fp_emitter:
|
|||
je .Lcall
|
||||
cmp al, 0x6b /* indirect/function call variant */
|
||||
je .Lindirect
|
||||
cmp al, 0x69 /* conditional expression */
|
||||
je .Lconditional
|
||||
cmp al, 0x2c /* comma */
|
||||
je .Lcomma
|
||||
jmp .Lunsupported
|
||||
|
|
@ -177,6 +180,8 @@ fp_emitter:
|
|||
je .Ldouble_call
|
||||
cmp al, 0x6b /* indirect/function call variant */
|
||||
je .Lindirect
|
||||
cmp al, 0x69 /* conditional expression */
|
||||
je .Lconditional
|
||||
cmp al, 0x2c /* comma */
|
||||
je .Lcomma
|
||||
jmp .Lunsupported
|
||||
|
|
@ -1051,6 +1056,14 @@ fp_emitter:
|
|||
add esp, 12
|
||||
jmp .Ldone
|
||||
|
||||
.Lconditional:
|
||||
push ebx
|
||||
push edi
|
||||
push esi
|
||||
call emit_conditional
|
||||
add esp, 12
|
||||
jmp .Ldone
|
||||
|
||||
.Lcomma:
|
||||
push ebx
|
||||
push edi
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ foreach(variant IN ITEMS ext ext2)
|
|||
add_runtime_iss_test("${variant}" "large" "iss-code-segment-boundaries")
|
||||
add_runtime_iss_test("${variant}" "huge" "fp-huge-indexed-load" "O2")
|
||||
foreach(model IN ITEMS tiny small medium large huge)
|
||||
add_runtime_iss_test("${variant}" "${model}" "fp-conditional" "O2")
|
||||
add_runtime_iss_test("${variant}" "${model}" "fp-f64-to-f32" "O2")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
|
|
|||
9
tests/cases/fp-conditional/conditional.c
Normal file
9
tests/cases/fp-conditional/conditional.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
float select_f32(float value, unsigned int select_value)
|
||||
{
|
||||
return select_value == 0x5a5aU ? value : 12345.0f;
|
||||
}
|
||||
|
||||
double select_f64(double value, unsigned int select_value)
|
||||
{
|
||||
return select_value == 0x5a5aU ? value : 12345.0;
|
||||
}
|
||||
34
tests/cases/fp-conditional/host.c
Normal file
34
tests/cases/fp-conditional/host.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "test.h"
|
||||
|
||||
extern float select_f32(float value, unsigned int select_value);
|
||||
extern double select_f64(double value, unsigned int select_value);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
test_f32 f32_input;
|
||||
test_f32 f32_output;
|
||||
test_f64 f64_input;
|
||||
test_f64 f64_output;
|
||||
|
||||
simulator_result = 0U;
|
||||
|
||||
f32_input.words[0] = 0x8000U;
|
||||
f32_input.words[1] = 0x0000U;
|
||||
f32_output.value = select_f32(f32_input.value, 0x5a5aU);
|
||||
test_check_f32(1U, &f32_output, 0x8000U, 0x0000U);
|
||||
f32_output.value = select_f32(f32_input.value, 0U);
|
||||
test_check_f32(2U, &f32_output, 0x4640U, 0xe400U);
|
||||
|
||||
f64_input.words[0] = 0x8000U;
|
||||
f64_input.words[1] = 0x0000U;
|
||||
f64_input.words[2] = 0x0000U;
|
||||
f64_input.words[3] = 0x0000U;
|
||||
f64_output.value = select_f64(f64_input.value, 0x5a5aU);
|
||||
test_check_f64(3U, &f64_output,
|
||||
0x8000U, 0x0000U, 0x0000U, 0x0000U);
|
||||
f64_output.value = select_f64(f64_input.value, 0U);
|
||||
test_check_f64(4U, &f64_output,
|
||||
0x40c8U, 0x1c80U, 0x0000U, 0x0000U);
|
||||
|
||||
simulator_stop();
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue