--- /dev/null 2016-12-01 16:34:58.000000000 +0000 +++ new/test/compiler/intrinsics/bmi/VerifyLzcntBase.java 2016-12-01 16:34:58.191034353 +0000 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.intrinsics.bmi; + +/* + * Verify that the C2 implementations of lzcnt return correct + * values. + * This class is extended to provide Integer and Long implementation + * tests. + * @see VerifyLzcntI.java and VerifyLzcntL.java + */ +abstract class VerifyLzcntBase +{ + protected static final int WARMUP_LOOPCOUNT = 10000000; + protected static final int TEST_LOOPCOUNT = 100000000; + + protected long warmupLoopCount = WARMUP_LOOPCOUNT; + protected long testLoopCount = TEST_LOOPCOUNT; + + protected int count = 0; + protected int expCount = 0; + + protected static int expMax; + + protected T testValue; + + /** + * Create a new instance of VerifyLzcnt + **/ + protected VerifyLzcntBase() + { + } + + public void setTestLoopCount(long loopCount) + { + if (loopCount > 0) { + this.testLoopCount = loopCount; + } + } + + protected void testFail() + { + System.err.println("FAIL: test-value: " + valueToHexString() + + " expected: " + expCount + "; got: " + count); + } + + protected abstract int getCount(); + protected abstract void initValue(); + protected abstract void nextValue(); + protected abstract String valueToHexString(); + + public void runTest() + { + System.out.println("Test: " + toString()); + + warmup(); + run(); + } + + protected void warmup() + { + System.out.println("Warmup: " + warmupLoopCount + " iterations"); + + initValue(); + + for (int i=0; i