Search in sources :

Example 1 with BasicRegisterMapper

use of com.android.dx.ssa.BasicRegisterMapper in project buck by facebook.

the class SsaToRop method convert.

/**
     * Performs the conversion.
     *
     * @return {@code non-null;} rop-form output
     */
private RopMethod convert() {
    if (DEBUG) {
        interference.dumpToStdout();
    }
    // These are other allocators for debugging or historical comparison:
    // allocator = new NullRegisterAllocator(ssaMeth, interference);
    // allocator = new FirstFitAllocator(ssaMeth, interference);
    RegisterAllocator allocator = new FirstFitLocalCombiningAllocator(ssaMeth, interference, minimizeRegisters);
    RegisterMapper mapper = allocator.allocateRegisters();
    if (DEBUG) {
        System.out.println("Printing reg map");
        System.out.println(((BasicRegisterMapper) mapper).toHuman());
    }
    ssaMeth.setBackMode();
    ssaMeth.mapRegisters(mapper);
    removePhiFunctions();
    if (allocator.wantsParamsMovedHigh()) {
        moveParametersToHighRegisters();
    }
    removeEmptyGotos();
    RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex()));
    ropMethod = new IdenticalBlockCombiner(ropMethod).process();
    return ropMethod;
}
Also used : RegisterMapper(com.android.dx.ssa.RegisterMapper) BasicRegisterMapper(com.android.dx.ssa.BasicRegisterMapper) RopMethod(com.android.dx.rop.code.RopMethod)

Example 2 with BasicRegisterMapper

use of com.android.dx.ssa.BasicRegisterMapper in project buck by facebook.

the class SsaToRop method moveParametersToHighRegisters.

/**
     * Moves the parameter registers, which allocateRegisters() places
     * at the bottom of the frame, up to the top of the frame to match
     * Dalvik calling convention.
     */
private void moveParametersToHighRegisters() {
    int paramWidth = ssaMeth.getParamWidth();
    BasicRegisterMapper mapper = new BasicRegisterMapper(ssaMeth.getRegCount());
    int regCount = ssaMeth.getRegCount();
    for (int i = 0; i < regCount; i++) {
        if (i < paramWidth) {
            mapper.addMapping(i, regCount - paramWidth + i, 1);
        } else {
            mapper.addMapping(i, i - paramWidth, 1);
        }
    }
    if (DEBUG) {
        System.out.printf("Moving %d registers from 0 to %d\n", paramWidth, regCount - paramWidth);
    }
    ssaMeth.mapRegisters(mapper);
}
Also used : BasicRegisterMapper(com.android.dx.ssa.BasicRegisterMapper)

Example 3 with BasicRegisterMapper

use of com.android.dx.ssa.BasicRegisterMapper in project J2ME-Loader by nikita36078.

the class NullRegisterAllocator method allocateRegisters.

/**
 * {@inheritDoc}
 */
@Override
public RegisterMapper allocateRegisters() {
    int oldRegCount = ssaMeth.getRegCount();
    BasicRegisterMapper mapper = new BasicRegisterMapper(oldRegCount);
    for (int i = 0; i < oldRegCount; i++) {
        mapper.addMapping(i, i * 2, 2);
    }
    return mapper;
}
Also used : BasicRegisterMapper(com.android.dx.ssa.BasicRegisterMapper)

Example 4 with BasicRegisterMapper

use of com.android.dx.ssa.BasicRegisterMapper in project J2ME-Loader by nikita36078.

the class SsaToRop method convert.

/**
 * Performs the conversion.
 *
 * @return {@code non-null;} rop-form output
 */
private RopMethod convert() {
    if (DEBUG) {
        interference.dumpToStdout();
    }
    // These are other allocators for debugging or historical comparison:
    // allocator = new NullRegisterAllocator(ssaMeth, interference);
    // allocator = new FirstFitAllocator(ssaMeth, interference);
    RegisterAllocator allocator = new FirstFitLocalCombiningAllocator(ssaMeth, interference, minimizeRegisters);
    RegisterMapper mapper = allocator.allocateRegisters();
    if (DEBUG) {
        System.out.println("Printing reg map");
        System.out.println(((BasicRegisterMapper) mapper).toHuman());
    }
    ssaMeth.setBackMode();
    ssaMeth.mapRegisters(mapper);
    removePhiFunctions();
    if (allocator.wantsParamsMovedHigh()) {
        moveParametersToHighRegisters();
    }
    removeEmptyGotos();
    RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex()));
    ropMethod = new IdenticalBlockCombiner(ropMethod).process();
    return ropMethod;
}
Also used : RegisterMapper(com.android.dx.ssa.RegisterMapper) BasicRegisterMapper(com.android.dx.ssa.BasicRegisterMapper) RopMethod(com.android.dx.rop.code.RopMethod)

Example 5 with BasicRegisterMapper

use of com.android.dx.ssa.BasicRegisterMapper in project J2ME-Loader by nikita36078.

the class SsaToRop method moveParametersToHighRegisters.

/**
 * Moves the parameter registers, which allocateRegisters() places
 * at the bottom of the frame, up to the top of the frame to match
 * Dalvik calling convention.
 */
private void moveParametersToHighRegisters() {
    int paramWidth = ssaMeth.getParamWidth();
    BasicRegisterMapper mapper = new BasicRegisterMapper(ssaMeth.getRegCount());
    int regCount = ssaMeth.getRegCount();
    for (int i = 0; i < regCount; i++) {
        if (i < paramWidth) {
            mapper.addMapping(i, regCount - paramWidth + i, 1);
        } else {
            mapper.addMapping(i, i - paramWidth, 1);
        }
    }
    if (DEBUG) {
        System.out.printf("Moving %d registers from 0 to %d\n", paramWidth, regCount - paramWidth);
    }
    ssaMeth.mapRegisters(mapper);
}
Also used : BasicRegisterMapper(com.android.dx.ssa.BasicRegisterMapper)

Aggregations

BasicRegisterMapper (com.android.dx.ssa.BasicRegisterMapper)10 RopMethod (com.android.dx.rop.code.RopMethod)2 NormalSsaInsn (com.android.dx.ssa.NormalSsaInsn)2 RegisterMapper (com.android.dx.ssa.RegisterMapper)2 BitIntSet (com.android.dx.util.BitIntSet)2 IntSet (com.android.dx.util.IntSet)2