001/*
002 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023/*
024 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
025 */
026/*
027 */
028package com.oracle.graal.jtt.micro;
029
030import org.junit.*;
031
032import com.oracle.graal.jtt.*;
033
034public class BigParamsAlignment extends JTTTest {
035
036    public static int test(int num) {
037        int sum = 0;
038        if (num == 0) {
039            sum += testA(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
040            sum += testA(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
041            sum += testA(2, 1, 2, 3, 4, 5, 6, 7, 8, 9);
042            sum += testA(3, 1, 2, 3, 4, 5, 6, 7, 8, 9);
043            sum += testA(4, 1, 2, 3, 4, 5, 6, 7, 8, 9);
044            sum += testA(5, 1, 2, 3, 4, 5, 6, 7, 8, 9);
045            sum += testA(6, 1, 2, 3, 4, 5, 6, 7, 8, 9);
046            sum += testA(7, 1, 2, 3, 4, 5, 6, 7, 8, 9);
047            sum += testA(8, 1, 2, 3, 4, 5, 6, 7, 8, 9);
048        } else if (num == 1) {
049            sum += testB(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
050            sum += testB(1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
051            sum += testB(2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
052            sum += testB(3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
053            sum += testB(4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
054            sum += testB(5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
055            sum += testB(6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
056            sum += testB(7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
057            sum += testB(8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
058            sum += testB(9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
059        } else if (num == 2) {
060            for (int i = 0; i < 9; i++) {
061                sum += testA(i, 1, 2, 3, 4, 5, 6, 7, 8, 9);
062            }
063        } else if (num == 3) {
064            for (int i = 0; i < 10; i++) {
065                sum += testB(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
066            }
067        } else if (num == 4) {
068            for (int i = 0; i < 11; i++) {
069                sum += testC(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
070            }
071        } else if (num == 5) {
072            for (int i = 0; i < 12; i++) {
073                sum += testD(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
074            }
075        }
076        return sum;
077    }
078
079    private static int testA(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) {
080        switch (choice) {
081            case 0:
082                return p0;
083            case 1:
084                return p1;
085            case 2:
086                return p2;
087            case 3:
088                return p3;
089            case 4:
090                return p4;
091            case 5:
092                return p5;
093            case 6:
094                return p6;
095            case 7:
096                return p7;
097            case 8:
098                return p8;
099        }
100        return 42;
101    }
102
103    private static int testB(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9) {
104        switch (choice) {
105            case 0:
106                return p0;
107            case 1:
108                return p1;
109            case 2:
110                return p2;
111            case 3:
112                return p3;
113            case 4:
114                return p4;
115            case 5:
116                return p5;
117            case 6:
118                return p6;
119            case 7:
120                return p7;
121            case 8:
122                return p8;
123            case 9:
124                return p9;
125        }
126        return 42;
127    }
128
129    private static int testC(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) {
130        switch (choice) {
131            case 0:
132                return p0;
133            case 1:
134                return p1;
135            case 2:
136                return p2;
137            case 3:
138                return p3;
139            case 4:
140                return p4;
141            case 5:
142                return p5;
143            case 6:
144                return p6;
145            case 7:
146                return p7;
147            case 8:
148                return p8;
149            case 9:
150                return p9;
151            case 10:
152                return p10;
153        }
154        return 42;
155    }
156
157    private static int testD(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, int p11) {
158        switch (choice) {
159            case 0:
160                return p0;
161            case 1:
162                return p1;
163            case 2:
164                return p2;
165            case 3:
166                return p3;
167            case 4:
168                return p4;
169            case 5:
170                return p5;
171            case 6:
172                return p6;
173            case 7:
174                return p7;
175            case 8:
176                return p8;
177            case 9:
178                return p9;
179            case 10:
180                return p10;
181            case 11:
182                return p11;
183        }
184        return 42;
185    }
186
187    @Test
188    public void run0() throws Throwable {
189        runTest("test", 0);
190    }
191
192    @Test
193    public void run1() throws Throwable {
194        runTest("test", 1);
195    }
196
197    @Test
198    public void run2() throws Throwable {
199        runTest("test", 2);
200    }
201
202    @Test
203    public void run3() throws Throwable {
204        runTest("test", 3);
205    }
206
207    @Test
208    public void run4() throws Throwable {
209        runTest("test", 4);
210    }
211
212    @Test
213    public void run5() throws Throwable {
214        runTest("test", 5);
215    }
216
217    @Test
218    public void run6() throws Throwable {
219        runTest("test", 6);
220    }
221
222}