Java Code Examples for com.android.dx.util.IntSet#iterator()

The following examples show how to use com.android.dx.util.IntSet#iterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 2
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 3
Source File: FirstFitLocalCombiningAllocator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 4
Source File: FirstFitLocalCombiningAllocator.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 5
Source File: RegisterAllocator.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Inserts a move instruction for a specified SSA register before a
 * specified instruction, creating a new SSA register and adjusting the
 * interference graph in the process. The insn currently must be the
 * last insn in a block.
 *
 * @param insn {@code non-null;} insn to insert move before, must
 * be last insn in block
 * @param reg {@code non-null;} SSA register to duplicate
 * @return {@code non-null;} spec of new SSA register created by move
 */
protected final RegisterSpec insertMoveBefore(SsaInsn insn,
        RegisterSpec reg) {
    SsaBasicBlock block = insn.getBlock();
    ArrayList<SsaInsn> insns = block.getInsns();
    int insnIndex = insns.indexOf(insn);

    if (insnIndex < 0) {
        throw new IllegalArgumentException (
                "specified insn is not in this block");
    }

    if (insnIndex != insns.size() - 1) {
        /*
         * Presently, the interference updater only works when
         * adding before the last insn, and the last insn must have no
         * result
         */
        throw new IllegalArgumentException(
                "Adding move here not supported:" + insn.toHuman());
    }

    /*
     * Get new register and make new move instruction.
     */

    // The new result must not have an associated local variable.
    RegisterSpec newRegSpec = RegisterSpec.make(ssaMeth.makeNewSsaReg(),
            reg.getTypeBearer());

    SsaInsn toAdd = SsaInsn.makeFromRop(
            new PlainInsn(Rops.opMove(newRegSpec.getType()),
                    SourcePosition.NO_INFO, newRegSpec,
                    RegisterSpecList.make(reg)), block);

    insns.add(insnIndex, toAdd);

    int newReg = newRegSpec.getReg();

    /*
     * Adjust interference graph based on what's live out of the current
     * block and what's used by the final instruction.
     */

    IntSet liveOut = block.getLiveOutRegs();
    IntIterator liveOutIter = liveOut.iterator();

    while (liveOutIter.hasNext()) {
        interference.add(newReg, liveOutIter.next());
    }

    // Everything that's a source in the last insn interferes.
    RegisterSpecList sources = insn.getSources();
    int szSources = sources.size();

    for (int i = 0; i < szSources; i++) {
        interference.add(newReg, sources.get(i).getReg());
    }

    ssaMeth.onInsnsChanged();

    return newRegSpec;
}
 
Example 6
Source File: RegisterAllocator.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Inserts a move instruction for a specified SSA register before a
 * specified instruction, creating a new SSA register and adjusting the
 * interference graph in the process. The insn currently must be the
 * last insn in a block.
 *
 * @param insn {@code non-null;} insn to insert move before, must
 * be last insn in block
 * @param reg {@code non-null;} SSA register to duplicate
 * @return {@code non-null;} spec of new SSA register created by move
 */
protected final RegisterSpec insertMoveBefore(SsaInsn insn,
        RegisterSpec reg) {
    SsaBasicBlock block = insn.getBlock();
    ArrayList<SsaInsn> insns = block.getInsns();
    int insnIndex = insns.indexOf(insn);

    if (insnIndex < 0) {
        throw new IllegalArgumentException (
                "specified insn is not in this block");
    }

    if (insnIndex != insns.size() - 1) {
        /*
         * Presently, the interference updater only works when
         * adding before the last insn, and the last insn must have no
         * result
         */
        throw new IllegalArgumentException(
                "Adding move here not supported:" + insn.toHuman());
    }

    /*
     * Get new register and make new move instruction.
     */

    // The new result must not have an associated local variable.
    RegisterSpec newRegSpec = RegisterSpec.make(ssaMeth.makeNewSsaReg(),
            reg.getTypeBearer());

    SsaInsn toAdd = SsaInsn.makeFromRop(
            new PlainInsn(Rops.opMove(newRegSpec.getType()),
                    SourcePosition.NO_INFO, newRegSpec,
                    RegisterSpecList.make(reg)), block);

    insns.add(insnIndex, toAdd);

    int newReg = newRegSpec.getReg();

    /*
     * Adjust interference graph based on what's live out of the current
     * block and what's used by the final instruction.
     */

    IntSet liveOut = block.getLiveOutRegs();
    IntIterator liveOutIter = liveOut.iterator();

    while (liveOutIter.hasNext()) {
        interference.add(newReg, liveOutIter.next());
    }

    // Everything that's a source in the last insn interferes.
    RegisterSpecList sources = insn.getSources();
    int szSources = sources.size();

    for (int i = 0; i < szSources; i++) {
        interference.add(newReg, sources.get(i).getReg());
    }

    ssaMeth.onInsnsChanged();

    return newRegSpec;
}
 
Example 7
Source File: RegisterAllocator.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/**
 * Inserts a move instruction for a specified SSA register before a
 * specified instruction, creating a new SSA register and adjusting the
 * interference graph in the process. The insn currently must be the
 * last insn in a block.
 *
 * @param insn {@code non-null;} insn to insert move before, must
 * be last insn in block
 * @param reg {@code non-null;} SSA register to duplicate
 * @return {@code non-null;} spec of new SSA register created by move
 */
protected final RegisterSpec insertMoveBefore(SsaInsn insn,
        RegisterSpec reg) {
    SsaBasicBlock block = insn.getBlock();
    ArrayList<SsaInsn> insns = block.getInsns();
    int insnIndex = insns.indexOf(insn);

    if (insnIndex < 0) {
        throw new IllegalArgumentException (
                "specified insn is not in this block");
    }

    if (insnIndex != insns.size() - 1) {
        /*
         * Presently, the interference updater only works when
         * adding before the last insn, and the last insn must have no
         * result
         */
        throw new IllegalArgumentException(
                "Adding move here not supported:" + insn.toHuman());
    }

    /*
     * Get new register and make new move instruction.
     */

    // The new result must not have an associated local variable.
    RegisterSpec newRegSpec = RegisterSpec.make(ssaMeth.makeNewSsaReg(),
            reg.getTypeBearer());

    SsaInsn toAdd = SsaInsn.makeFromRop(
            new PlainInsn(Rops.opMove(newRegSpec.getType()),
                    SourcePosition.NO_INFO, newRegSpec,
                    RegisterSpecList.make(reg)), block);

    insns.add(insnIndex, toAdd);

    int newReg = newRegSpec.getReg();

    /*
     * Adjust interference graph based on what's live out of the current
     * block and what's used by the final instruction.
     */

    IntSet liveOut = block.getLiveOutRegs();
    IntIterator liveOutIter = liveOut.iterator();

    while (liveOutIter.hasNext()) {
        interference.add(newReg, liveOutIter.next());
    }

    // Everything that's a source in the last insn interferes.
    RegisterSpecList sources = insn.getSources();
    int szSources = sources.size();

    for (int i = 0; i < szSources; i++) {
        interference.add(newReg, sources.get(i).getReg());
    }

    ssaMeth.onInsnsChanged();

    return newRegSpec;
}
 
Example 8
Source File: RegisterAllocator.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Inserts a move instruction for a specified SSA register before a
 * specified instruction, creating a new SSA register and adjusting the
 * interference graph in the process. The insn currently must be the
 * last insn in a block.
 *
 * @param insn {@code non-null;} insn to insert move before, must
 * be last insn in block
 * @param reg {@code non-null;} SSA register to duplicate
 * @return {@code non-null;} spec of new SSA register created by move
 */
protected final RegisterSpec insertMoveBefore(SsaInsn insn,
        RegisterSpec reg) {
    SsaBasicBlock block = insn.getBlock();
    ArrayList<SsaInsn> insns = block.getInsns();
    int insnIndex = insns.indexOf(insn);

    if (insnIndex < 0) {
        throw new IllegalArgumentException (
                "specified insn is not in this block");
    }

    if (insnIndex != insns.size() - 1) {
        /*
         * Presently, the interference updater only works when
         * adding before the last insn, and the last insn must have no
         * result
         */
        throw new IllegalArgumentException(
                "Adding move here not supported:" + insn.toHuman());
    }

    /*
     * Get new register and make new move instruction.
     */

    // The new result must not have an associated local variable.
    RegisterSpec newRegSpec = RegisterSpec.make(ssaMeth.makeNewSsaReg(),
            reg.getTypeBearer());

    SsaInsn toAdd = SsaInsn.makeFromRop(
            new PlainInsn(Rops.opMove(newRegSpec.getType()),
                    SourcePosition.NO_INFO, newRegSpec,
                    RegisterSpecList.make(reg)), block);

    insns.add(insnIndex, toAdd);

    int newReg = newRegSpec.getReg();

    /*
     * Adjust interference graph based on what's live out of the current
     * block and what's used by the final instruction.
     */

    IntSet liveOut = block.getLiveOutRegs();
    IntIterator liveOutIter = liveOut.iterator();

    while (liveOutIter.hasNext()) {
        interference.add(newReg, liveOutIter.next());
    }

    // Everything that's a source in the last insn interferes.
    RegisterSpecList sources = insn.getSources();
    int szSources = sources.size();

    for (int i = 0; i < szSources; i++) {
        interference.add(newReg, sources.get(i).getReg());
    }

    ssaMeth.onInsnsChanged();

    return newRegSpec;
}