summary refs log tree commit diff
path: root/test/fpcnv.ssa
blob: 06d2478296b4f97d447fd23b030bef6debc502e1 (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
28
29
# floating point casts and conversions

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

export
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;
# }
# <<<