OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [cplx2.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out
2
 
3
// Copyright 2010 The Go Authors. All rights reserved.
4
// Use of this source code is governed by a BSD-style
5
// license that can be found in the LICENSE file.
6
 
7
package main
8
 
9
const (
10
        R = 5
11
        I = 6i
12
 
13
        C1 = R + I    // ADD(5,6)
14
        C2 = R - I    // SUB(5,-6)
15
        C3 = -(R + I) // ADD(5,6) NEG(-5,-6)
16
        C4 = -(R - I) // SUB(5,-6) NEG(-5,6)
17
 
18
        C5 = C1 + R // ADD(10,6)
19
        C6 = C1 + I // ADD(5,12)
20
 
21
        Ca = C5 + C6 // ADD(15,18)
22
        Cb = C5 - C6 // SUB(5,-6)
23
 
24
        Cc = C5 * C6 // MUL(-22,-150)
25
        Cd = C5 / C6 // DIV(0.721893,-0.532544)
26
        Ce = Cd * C6 // MUL(10,6) sb C5
27
)
28
 
29
func main() {
30
 
31
        var r complex64 = 5 + 0i
32
        if r != R {
33
                println("opcode 1", r, R)
34
                panic("fail")
35
        }
36
 
37
        var i complex64 = 6i
38
        if i != I {
39
                println("opcode 2", i, I)
40
                panic("fail")
41
        }
42
 
43
        c1 := r + i
44
        if c1 != C1 {
45
                println("opcode x", c1, C1)
46
                panic("fail")
47
        }
48
 
49
        c2 := r - i
50
        if c2 != C2 {
51
                println("opcode x", c2, C2)
52
                panic("fail")
53
        }
54
 
55
        c3 := -(r + i)
56
        if c3 != C3 {
57
                println("opcode x", c3, C3)
58
                panic("fail")
59
        }
60
 
61
        c4 := -(r - i)
62
        if c4 != C4 {
63
                println("opcode x", c4, C4)
64
                panic("fail")
65
        }
66
 
67
        c5 := c1 + r
68
        if c5 != C5 {
69
                println("opcode x", c5, C5)
70
                panic("fail")
71
        }
72
 
73
        c6 := c1 + i
74
        if c6 != C6 {
75
                println("opcode x", c6, C6)
76
                panic("fail")
77
        }
78
 
79
        ca := c5 + c6
80
        if ca != Ca {
81
                println("opcode x", ca, Ca)
82
                panic("fail")
83
        }
84
 
85
        cb := c5 - c6
86
        if cb != Cb {
87
                println("opcode x", cb, Cb)
88
                panic("fail")
89
        }
90
 
91
        cc := c5 * c6
92
        if cc != Cc {
93
                println("opcode x", cc, Cc)
94
                panic("fail")
95
        }
96
 
97
        cd := c5 / c6
98
        if cd != Cd {
99
                println("opcode x", cd, Cd)
100
                panic("fail")
101
        }
102
 
103
        ce := cd * c6
104
        if ce != Ce {
105
                println("opcode x", ce, Ce)
106
                panic("fail")
107
        }
108
 
109
        r32 := real(complex64(ce))
110
        if r32 != float32(real(Ce)) {
111
                println("real(complex64(ce))", r32, real(Ce))
112
                panic("fail")
113
        }
114
 
115
        r64 := real(complex128(ce))
116
        if r64 != real(Ce) {
117
                println("real(complex128(ce))", r64, real(Ce))
118
                panic("fail")
119
        }
120
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.