Java Code Examples for com.android.dx.ssa.PhiInsn#getResult()

The following examples show how to use com.android.dx.ssa.PhiInsn#getResult() . 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: SsaToRop.java    From Box with Apache License 2.0 5 votes vote down vote up
@Override
public void visitPhiInsn(PhiInsn insn) {
    RegisterSpecList sources = insn.getSources();
    RegisterSpec result = insn.getResult();
    int sz = sources.size();

    for (int i = 0; i < sz; i++) {
        RegisterSpec source = sources.get(i);
        SsaBasicBlock predBlock = blocks.get(
                insn.predBlockIndexForSourcesIndex(i));

        predBlock.addMoveToEnd(result, source);
    }
}
 
Example 2
Source File: SsaToRop.java    From Box with Apache License 2.0 5 votes vote down vote up
@Override
public void visitPhiInsn(PhiInsn insn) {
    RegisterSpecList sources = insn.getSources();
    RegisterSpec result = insn.getResult();
    int sz = sources.size();

    for (int i = 0; i < sz; i++) {
        RegisterSpec source = sources.get(i);
        SsaBasicBlock predBlock = blocks.get(
                insn.predBlockIndexForSourcesIndex(i));

        predBlock.addMoveToEnd(result, source);
    }
}
 
Example 3
Source File: SsaToRop.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
@Override
public void visitPhiInsn(PhiInsn insn) {
          RegisterSpecList sources = insn.getSources();
          RegisterSpec result = insn.getResult();
          int sz = sources.size();

          for (int i = 0; i < sz; i++) {
              RegisterSpec source = sources.get(i);
              SsaBasicBlock predBlock = blocks.get(
                      insn.predBlockIndexForSourcesIndex(i));

              predBlock.addMoveToEnd(result, source);
          }
      }
 
Example 4
Source File: SsaToRop.java    From buck with Apache License 2.0 5 votes vote down vote up
public void visitPhiInsn(PhiInsn insn) {
    RegisterSpecList sources = insn.getSources();
    RegisterSpec result = insn.getResult();
    int sz = sources.size();

    for (int i = 0; i < sz; i++) {
        RegisterSpec source = sources.get(i);
        SsaBasicBlock predBlock = blocks.get(
                insn.predBlockIndexForSourcesIndex(i));

        predBlock.addMoveToEnd(result, source);
    }
}
 
Example 5
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Attempts to map the sources and result of a phi to a common register.
 * Will try existing mappings first, from most to least common. If none
 * of the registers have mappings yet, a new mapping is created.
 */
private void processPhiInsn(PhiInsn insn) {
    RegisterSpec result = insn.getResult();
    int resultReg = result.getReg();
    int category = result.getCategory();

    RegisterSpecList sources = insn.getSources();
    int sourcesSize = sources.size();

    // List of phi sources / result that need mapping
    ArrayList<RegisterSpec> ssaRegs = new ArrayList<RegisterSpec>();

    // Track how many times a particular mapping is found
    Multiset mapSet = new Multiset(sourcesSize + 1);

    /*
     * If the result of the phi has an existing mapping, get it.
     * Otherwise, add it to the list of regs that need mapping.
     */
    if (ssaRegsMapped.get(resultReg)) {
        mapSet.add(mapper.oldToNew(resultReg));
    } else {
        ssaRegs.add(result);
    }

    for (int i = 0; i < sourcesSize; i++) {
        RegisterSpec source = sources.get(i);
        SsaInsn def = ssaMeth.getDefinitionForRegister(source.getReg());
        RegisterSpec sourceDef = def.getResult();
        int sourceReg = sourceDef.getReg();

        /*
         * If a source of the phi has an existing mapping, get it.
         * Otherwise, add it to the list of regs that need mapping.
         */
        if (ssaRegsMapped.get(sourceReg)) {
            mapSet.add(mapper.oldToNew(sourceReg));
        } else {
            ssaRegs.add(sourceDef);
        }
    }

    // Try all existing mappings, with the most common ones first
    for (int i = 0; i < mapSet.getSize(); i++) {
        int maxReg = mapSet.getAndRemoveHighestCount();
        tryMapRegs(ssaRegs, maxReg, category, false);
    }

    // Map any remaining unmapped regs with whatever fits
    int mapReg = findNextUnreservedRopReg(paramRangeEnd, category);
    while (!tryMapRegs(ssaRegs, mapReg, category, false)) {
        mapReg = findNextUnreservedRopReg(mapReg + 1, category);
    }
}
 
Example 6
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Attempts to map the sources and result of a phi to a common register.
 * Will try existing mappings first, from most to least common. If none
 * of the registers have mappings yet, a new mapping is created.
 */
private void processPhiInsn(PhiInsn insn) {
    RegisterSpec result = insn.getResult();
    int resultReg = result.getReg();
    int category = result.getCategory();

    RegisterSpecList sources = insn.getSources();
    int sourcesSize = sources.size();

    // List of phi sources / result that need mapping
    ArrayList<RegisterSpec> ssaRegs = new ArrayList<RegisterSpec>();

    // Track how many times a particular mapping is found
    Multiset mapSet = new Multiset(sourcesSize + 1);

    /*
     * If the result of the phi has an existing mapping, get it.
     * Otherwise, add it to the list of regs that need mapping.
     */
    if (ssaRegsMapped.get(resultReg)) {
        mapSet.add(mapper.oldToNew(resultReg));
    } else {
        ssaRegs.add(result);
    }

    for (int i = 0; i < sourcesSize; i++) {
        RegisterSpec source = sources.get(i);
        SsaInsn def = ssaMeth.getDefinitionForRegister(source.getReg());
        RegisterSpec sourceDef = def.getResult();
        int sourceReg = sourceDef.getReg();

        /*
         * If a source of the phi has an existing mapping, get it.
         * Otherwise, add it to the list of regs that need mapping.
         */
        if (ssaRegsMapped.get(sourceReg)) {
            mapSet.add(mapper.oldToNew(sourceReg));
        } else {
            ssaRegs.add(sourceDef);
        }
    }

    // Try all existing mappings, with the most common ones first
    for (int i = 0; i < mapSet.getSize(); i++) {
        int maxReg = mapSet.getAndRemoveHighestCount();
        tryMapRegs(ssaRegs, maxReg, category, false);
    }

    // Map any remaining unmapped regs with whatever fits
    int mapReg = findNextUnreservedRopReg(paramRangeEnd, category);
    while (!tryMapRegs(ssaRegs, mapReg, category, false)) {
        mapReg = findNextUnreservedRopReg(mapReg + 1, category);
    }
}
 
Example 7
Source File: FirstFitLocalCombiningAllocator.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/**
 * Attempts to map the sources and result of a phi to a common register.
 * Will try existing mappings first, from most to least common. If none
 * of the registers have mappings yet, a new mapping is created.
 */
private void processPhiInsn(PhiInsn insn) {
    RegisterSpec result = insn.getResult();
    int resultReg = result.getReg();
    int category = result.getCategory();

    RegisterSpecList sources = insn.getSources();
    int sourcesSize = sources.size();

    // List of phi sources / result that need mapping
    ArrayList<RegisterSpec> ssaRegs = new ArrayList<RegisterSpec>();

    // Track how many times a particular mapping is found
    Multiset mapSet = new Multiset(sourcesSize + 1);

    /*
     * If the result of the phi has an existing mapping, get it.
     * Otherwise, add it to the list of regs that need mapping.
     */
    if (ssaRegsMapped.get(resultReg)) {
        mapSet.add(mapper.oldToNew(resultReg));
    } else {
        ssaRegs.add(result);
    }

    for (int i = 0; i < sourcesSize; i++) {
        RegisterSpec source = sources.get(i);
        SsaInsn def = ssaMeth.getDefinitionForRegister(source.getReg());
        RegisterSpec sourceDef = def.getResult();
        int sourceReg = sourceDef.getReg();

        /*
         * If a source of the phi has an existing mapping, get it.
         * Otherwise, add it to the list of regs that need mapping.
         */
        if (ssaRegsMapped.get(sourceReg)) {
            mapSet.add(mapper.oldToNew(sourceReg));
        } else {
            ssaRegs.add(sourceDef);
        }
    }

    // Try all existing mappings, with the most common ones first
    for (int i = 0; i < mapSet.getSize(); i++) {
        int maxReg = mapSet.getAndRemoveHighestCount();
        tryMapRegs(ssaRegs, maxReg, category, false);
    }

    // Map any remaining unmapped regs with whatever fits
    int mapReg = findNextUnreservedRopReg(paramRangeEnd, category);
    while (!tryMapRegs(ssaRegs, mapReg, category, false)) {
        mapReg = findNextUnreservedRopReg(mapReg + 1, category);
    }
}
 
Example 8
Source File: FirstFitLocalCombiningAllocator.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Attempts to map the sources and result of a phi to a common register.
 * Will try existing mappings first, from most to least common. If none
 * of the registers have mappings yet, a new mapping is created.
 */
private void processPhiInsn(PhiInsn insn) {
    RegisterSpec result = insn.getResult();
    int resultReg = result.getReg();
    int category = result.getCategory();

    RegisterSpecList sources = insn.getSources();
    int sourcesSize = sources.size();

    // List of phi sources / result that need mapping
    ArrayList<RegisterSpec> ssaRegs = new ArrayList<RegisterSpec>();

    // Track how many times a particular mapping is found
    Multiset mapSet = new Multiset(sourcesSize + 1);

    /*
     * If the result of the phi has an existing mapping, get it.
     * Otherwise, add it to the list of regs that need mapping.
     */
    if (ssaRegsMapped.get(resultReg)) {
        mapSet.add(mapper.oldToNew(resultReg));
    } else {
        ssaRegs.add(result);
    }

    for (int i = 0; i < sourcesSize; i++) {
        RegisterSpec source = sources.get(i);
        SsaInsn def = ssaMeth.getDefinitionForRegister(source.getReg());
        RegisterSpec sourceDef = def.getResult();
        int sourceReg = sourceDef.getReg();

        /*
         * If a source of the phi has an existing mapping, get it.
         * Otherwise, add it to the list of regs that need mapping.
         */
        if (ssaRegsMapped.get(sourceReg)) {
            mapSet.add(mapper.oldToNew(sourceReg));
        } else {
            ssaRegs.add(sourceDef);
        }
    }

    // Try all existing mappings, with the most common ones first
    for (int i = 0; i < mapSet.getSize(); i++) {
        int maxReg = mapSet.getAndRemoveHighestCount();
        tryMapRegs(ssaRegs, maxReg, category, false);
    }

    // Map any remaining unmapped regs with whatever fits
    int mapReg = findNextUnreservedRopReg(paramRangeEnd, category);
    while (!tryMapRegs(ssaRegs, mapReg, category, false)) {
        mapReg = findNextUnreservedRopReg(mapReg + 1, category);
    }
}