summary refs log tree commit diff
path: root/test/fpcnv.ssa
blob: 5fd3be9b97f2e130a1174ba33e2669791a8dacb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# floating point casts and conversions

function s $fneg(s %f) {
@fneg
	%b0 =w cast %f
	%b1 =w xor 2147483648, %b0
	%rs =s cast %b1
	ret %rs
}

function d $ftrunc(d %f) {
@ftrunc
	%l0 =l ftosi %f
	%rt =d sitof %l0
	ret %rt
}

# >>> driver
# extern float fneg(float);
# extern double ftrunc(double);
# int main() {
# 	if (fneg(1.23f) != -1.23f)  return 1;
# 	if (ftrunc(3.1415) != 3.0)  return 2;
# 	if (ftrunc(-1.234) != -1.0) return 3;
# 	return 0;
# }
# <<<