Mercurial > octave-nkf
comparison test/jit.tst @ 18326:421bed6994f0
jit compiler: Add support for switch statement
* libinterp/corefcn/pt-jit.cc (jit_convert::visit_switch_command):
JIT compile switch statement.
* test/jit.tst: Add tests for switch statement
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Sun, 05 Jan 2014 17:51:52 +0100 |
parents | 2a8243d8327a |
children | 3af93835be56 |
comparison
equal
deleted
inserted
replaced
18325:2a8243d8327a | 18326:421bed6994f0 |
---|---|
24 %! global __old_jit_startcnt__; | 24 %! global __old_jit_startcnt__; |
25 %! __old_jit_enable__ = jit_enable (true); | 25 %! __old_jit_enable__ = jit_enable (true); |
26 %! __old_jit_startcnt__ = jit_startcnt (1000); | 26 %! __old_jit_startcnt__ = jit_startcnt (1000); |
27 | 27 |
28 ## Test some simple cases that compile. | 28 ## Test some simple cases that compile. |
29 | |
30 %!testif HAVE_LLVM | 29 %!testif HAVE_LLVM |
31 %! jit_failure_count (0) | 30 %! jit_failure_count (0) |
32 %! for i=1:1e6 | 31 %! for i=1:1e6 |
33 %! if (i < 5) | 32 %! if (i < 5) |
34 %! break; | 33 %! break; |
94 %! break; | 93 %! break; |
95 %! endif | 94 %! endif |
96 %! endparfor | 95 %! endparfor |
97 %! assert (i, 100); | 96 %! assert (i, 100); |
98 %! assert (jit_failure_count, 0); | 97 %! assert (jit_failure_count, 0); |
99 | 98 ## Test some switch statements |
99 %!testif HAVE_LLVM | |
100 %! jit_failure_count (0) | |
101 %! do | |
102 %! switch (1) | |
103 %! end; | |
104 %! until(1) | |
105 %! assert (jit_failure_count, 0); | |
106 | |
107 %!testif HAVE_LLVM | |
108 %! jit_failure_count (0) | |
109 %! do | |
110 %! switch (1) | |
111 %! case 1 | |
112 %! break; | |
113 %! end; | |
114 %! until(1) | |
115 %! assert (jit_failure_count, 0); | |
116 | |
117 %!testif HAVE_LLVM | |
118 %! jit_failure_count (0) | |
119 %! do | |
120 %! switch (1) | |
121 %! otherwise | |
122 %! break; | |
123 %! end; | |
124 %! until(1) | |
125 %! assert (jit_failure_count, 0); | |
126 | |
127 %!testif HAVE_LLVM | |
128 %! jit_failure_count (0) | |
129 %! do | |
130 %! switch (1) | |
131 %! case 1 | |
132 %! break; | |
133 %! otherwise | |
134 %! break; | |
135 %! end; | |
136 %! until(1) | |
137 %! assert (jit_failure_count, 0); | |
138 | |
139 %!testif HAVE_LLVM | |
140 %! jit_failure_count (0) | |
141 %! i=0; | |
142 %! a=0; | |
143 %! b=0; | |
144 %! do | |
145 %! i=i+1; | |
146 %! switch (i) | |
147 %! case 1 | |
148 %! continue; | |
149 %! case 2 | |
150 %! b=1; | |
151 %! continue; | |
152 %! case 4 | |
153 %! break; | |
154 %! otherwise | |
155 %! a=a+5; | |
156 %! end; | |
157 %! a=a+1; | |
158 %! until(0); | |
159 %! assert (i, 4); | |
160 %! assert (a, 6); | |
161 %! assert (b, 1); | |
162 %! assert (jit_failure_count, 0); | |
163 | |
164 ## Some more complex calculations | |
100 %!testif HAVE_LLVM | 165 %!testif HAVE_LLVM |
101 %! jit_failure_count (0) | 166 %! jit_failure_count (0) |
102 %! inc = 1e-5; | 167 %! inc = 1e-5; |
103 %! result = 0; | 168 %! result = 0; |
104 %! for ii = 0:inc:1 | 169 %! for ii = 0:inc:1 |