1579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson/*
2579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * Copyright (C) 2007 The Android Open Source Project
3579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson *
4579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * Licensed under the Apache License, Version 2.0 (the "License");
5579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * you may not use this file except in compliance with the License.
6579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * You may obtain a copy of the License at
7579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson *
8579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson *      http://www.apache.org/licenses/LICENSE-2.0
9579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson *
10579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * Unless required by applicable law or agreed to in writing, software
11579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
12579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * See the License for the specific language governing permissions and
14579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * limitations under the License.
15579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson */
16579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson
17579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilsonpackage com.android.dx.rop.code;
18579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson
19579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson/**
20579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * Interface for "advice" passed from the late stage of translation back
21579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * to the early stage. This allows for the final target architecture to
22579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * exert its influence early in the translation process without having
23579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson * the early stage code be explicitly tied to the target.
24579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson */
25579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilsonpublic interface TranslationAdvice {
26579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson    /**
27579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * Returns an indication of whether the target can directly represent an
28579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * instruction with the given opcode operating on the given arguments,
29579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * where the last source argument is used as a constant. (That is, the
30579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * last argument must have a type which indicates it is a known constant.)
31579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * The instruction associated must have exactly two sources.
32579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     *
33579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @param opcode {@code non-null;} the opcode
34579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @param sourceA {@code non-null;} the first source
35579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @param sourceB {@code non-null;} the second source
36579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @return {@code true} iff the target can represent the operation
37579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * using a constant for the last argument
38579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     */
39579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson    public boolean hasConstantOperation(Rop opcode,
40579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson            RegisterSpec sourceA, RegisterSpec sourceB);
41579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson
42579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson    /**
43579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * Returns true if the translation target requires the sources of the
44579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * specified opcode to be in order and contiguous (eg, for an invoke-range)
45579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     *
46579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @param opcode {@code non-null;} opcode
47579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @param sources {@code non-null;} source list
48579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @return {@code true} iff the target requires the sources to be
49579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * in order and contiguous.
50579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     */
51579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson    public boolean requiresSourcesInOrder(Rop opcode, RegisterSpecList sources);
52579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson
53579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson    /**
54579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * Gets the maximum register width that can be represented optimally.
55579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * For example, Dex bytecode does not have instruction forms that take
56579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * register numbers larger than 15 for all instructions so
57579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * DexTranslationAdvice returns 15 here.
58579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     *
59579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     * @return register count noted above
60579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson     */
61579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson    public int getMaxOptimalRegisterCount();
62579d7739c53a2707ad711a2d2cae46d7d782f06Jesse Wilson}
63