summary refs log tree commit diff
path: root/test/fpcnv.ssa
blob: d9851d8b024294099528569989bd14283b056712 (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 =w dtosi %f
	%rt =d swtof %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;
# }
# <<<