Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libtcg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton
libtcg
Commits
9d8e9c09
Commit
9d8e9c09
authored
22 years ago
by
Fabrice Bellard
Browse files
Options
Downloads
Patches
Plain Diff
bsx/float tests
git-svn-id:
svn://svn.savannah.nongnu.org/qemu/trunk@21
c046a42c-6fe2-441c-8c8c-71466251a162
parent
d57c4e01
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/Makefile
+2
-2
2 additions, 2 deletions
tests/Makefile
tests/test-i386.c
+101
-0
101 additions, 0 deletions
tests/test-i386.c
with
103 additions
and
2 deletions
tests/Makefile
+
2
−
2
View file @
9d8e9c09
...
...
@@ -13,14 +13,14 @@ hello: hello.c
$(
CC
)
-nostdlib
$(
CFLAGS
)
-static
$(
LDFLAGS
)
-o
$@
$<
test1
:
test1.c
$(
CC
)
$(
CFLAGS
)
$(
LDFLAGS
)
-o
$@
$<
$(
CC
)
$(
CFLAGS
)
-static
$(
LDFLAGS
)
-o
$@
$<
test2
:
test2.c
$(
CC
)
$(
CFLAGS
)
$(
LDFLAGS
)
-o
$@
$<
# i386 emulation test (dump various opcodes) */
test-i386
:
test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h
$(
CC
)
$(
CFLAGS
)
$(
LDFLAGS
)
-static
-o
$@
$<
$(
CC
)
$(
CFLAGS
)
$(
LDFLAGS
)
-static
-o
$@
$<
-lm
test
:
test-i386
./test-i386
>
test-i386.ref
...
...
This diff is collapsed.
Click to expand it.
tests/test-i386.c
+
101
−
0
View file @
9d8e9c09
...
...
@@ -424,6 +424,105 @@ void test_mul(void)
test_divl
(
0x12343
,
0x12345678
,
0x81234567
);
}
#define TEST_BSX(op, size, op0)\
{\
int res, val, resz;\
val = op0;\
asm("xorl %1, %1 ; " #op " %" size "2, %" size "0 ; setz %b1" \
: "=r" (res), "=q" (resz)\
: "g" (val));\
printf("%-10s A=%08x R=%08x %d\n", #op, val, resz ? 0 : res, resz);\
}
void
test_bsx
(
void
)
{
TEST_BSX
(
bsrw
,
"w"
,
0
);
TEST_BSX
(
bsrw
,
"w"
,
0x12340128
);
TEST_BSX
(
bsrl
,
""
,
0
);
TEST_BSX
(
bsrl
,
""
,
0x00340128
);
TEST_BSX
(
bsfw
,
"w"
,
0
);
TEST_BSX
(
bsfw
,
"w"
,
0x12340128
);
TEST_BSX
(
bsfl
,
""
,
0
);
TEST_BSX
(
bsfl
,
""
,
0x00340128
);
}
void
test_fops
(
double
a
,
double
b
)
{
printf
(
"a=%f b=%f a+b=%f
\n
"
,
a
,
b
,
a
+
b
);
printf
(
"a=%f b=%f a-b=%f
\n
"
,
a
,
b
,
a
-
b
);
printf
(
"a=%f b=%f a*b=%f
\n
"
,
a
,
b
,
a
*
b
);
printf
(
"a=%f b=%f a/b=%f
\n
"
,
a
,
b
,
a
/
b
);
printf
(
"a=%f b=%f fmod(a, b)=%f
\n
"
,
a
,
b
,
fmod
(
a
,
b
));
printf
(
"a=%f sqrt(a)=%f
\n
"
,
a
,
sqrt
(
a
));
printf
(
"a=%f sin(a)=%f
\n
"
,
a
,
sin
(
a
));
printf
(
"a=%f cos(a)=%f
\n
"
,
a
,
cos
(
a
));
printf
(
"a=%f tan(a)=%f
\n
"
,
a
,
tan
(
a
));
printf
(
"a=%f log(a)=%f
\n
"
,
a
,
log
(
a
));
printf
(
"a=%f exp(a)=%f
\n
"
,
a
,
exp
(
a
));
printf
(
"a=%f b=%f atan2(a, b)=%f
\n
"
,
a
,
b
,
atan2
(
a
,
b
));
/* just to test some op combining */
printf
(
"a=%f asin(sin(a))=%f
\n
"
,
a
,
asin
(
sin
(
a
)));
printf
(
"a=%f acos(cos(a))=%f
\n
"
,
a
,
acos
(
cos
(
a
)));
printf
(
"a=%f atan(tan(a))=%f
\n
"
,
a
,
atan
(
tan
(
a
)));
}
void
test_fcmp
(
double
a
,
double
b
)
{
printf
(
"(%f<%f)=%d
\n
"
,
a
,
b
,
a
<
b
);
printf
(
"(%f<=%f)=%d
\n
"
,
a
,
b
,
a
<=
b
);
printf
(
"(%f==%f)=%d
\n
"
,
a
,
b
,
a
==
b
);
printf
(
"(%f>%f)=%d
\n
"
,
a
,
b
,
a
>
b
);
printf
(
"(%f<=%f)=%d
\n
"
,
a
,
b
,
a
>=
b
);
}
void
test_fcvt
(
double
a
)
{
float
fa
;
long
double
la
;
fa
=
a
;
la
=
a
;
printf
(
"(float)%f = %f
\n
"
,
a
,
fa
);
printf
(
"(long double)%f = %Lf
\n
"
,
a
,
la
);
printf
(
"a=%f floor(a)=%f
\n
"
,
a
,
floor
(
a
));
printf
(
"a=%f ceil(a)=%f
\n
"
,
a
,
ceil
(
a
));
printf
(
"a=%f rint(a)=%f
\n
"
,
a
,
rint
(
a
));
}
#define TEST(N) \
asm("fld" #N : "=t" (a)); \
printf("fld" #N "= %f\n", a);
void
test_fconst
(
void
)
{
double
a
;
TEST
(
1
);
TEST
(
l2t
);
TEST
(
l2e
);
TEST
(
pi
);
TEST
(
lg2
);
TEST
(
ln2
);
TEST
(
z
);
}
void
test_floats
(
void
)
{
test_fops
(
2
,
3
);
test_fops
(
1
.
4
,
-
5
);
test_fcmp
(
2
,
-
1
);
test_fcmp
(
2
,
2
);
test_fcmp
(
2
,
3
);
test_fcvt
(
1
.
0
/
7
.
0
);
test_fcvt
(
-
1
.
0
/
9
.
0
);
test_fcvt
(
1e30
);
test_fconst
();
}
static
void
*
call_end
__init_call
=
NULL
;
...
...
@@ -437,8 +536,10 @@ int main(int argc, char **argv)
func
=
*
ptr
++
;
func
();
}
test_bsx
();
test_mul
();
test_jcc
();
test_lea
();
test_floats
();
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment