Java Code Examples for com.android.dx.rop.code.RegisterSpec#isEvenRegister()

The following examples show how to use com.android.dx.rop.code.RegisterSpec#isEvenRegister() . 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: OutputFinisher.java    From Box with Apache License 2.0 4 votes vote down vote up
private void align64bits(Dop[] opcodes) {
  while (true) {
    int notAligned64bitRegAccess = 0;
    int aligned64bitRegAccess = 0;
    int notAligned64bitParamAccess = 0;
    int aligned64bitParamAccess = 0;
    int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount;
    int firstParameter = lastParameter - paramSize;

    // Collects the number of time that 64-bit registers are accessed aligned or not.
    for (DalvInsn insn : insns) {
      RegisterSpecList regs = insn.getRegisters();
      for (int usedRegIdx = 0; usedRegIdx < regs.size(); usedRegIdx++) {
        RegisterSpec reg = regs.get(usedRegIdx);
        if (reg.isCategory2()) {
          boolean isParameter = reg.getReg() >= firstParameter;
          if (reg.isEvenRegister()) {
            if (isParameter) {
              aligned64bitParamAccess++;
            } else {
              aligned64bitRegAccess++;
            }
          } else {
            if (isParameter) {
              notAligned64bitParamAccess++;
            } else {
              notAligned64bitRegAccess++;
            }
          }
        }
      }
    }

    if (notAligned64bitParamAccess > aligned64bitParamAccess
        && notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);
    } else if (notAligned64bitParamAccess > aligned64bitParamAccess) {
      addReservedParameters(1);
    } else if (notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);

      // Need to shift parameters if they exist and if number of unaligned is greater than
      // aligned. We test the opposite because we previously shift all registers by one,
      // so the number of aligned become the number of unaligned.
      if (paramSize != 0 && aligned64bitParamAccess > notAligned64bitParamAccess) {
        addReservedParameters(1);
      }
    } else {
      break;
    }

    if (!reserveRegisters(opcodes)) {
      break;
    }
  }
}
 
Example 2
Source File: OutputFinisher.java    From Box with Apache License 2.0 4 votes vote down vote up
private void align64bits(Dop[] opcodes) {
  while (true) {
    int notAligned64bitRegAccess = 0;
    int aligned64bitRegAccess = 0;
    int notAligned64bitParamAccess = 0;
    int aligned64bitParamAccess = 0;
    int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount;
    int firstParameter = lastParameter - paramSize;

    // Collects the number of time that 64-bit registers are accessed aligned or not.
    for (DalvInsn insn : insns) {
      RegisterSpecList regs = insn.getRegisters();
      for (int usedRegIdx = 0; usedRegIdx < regs.size(); usedRegIdx++) {
        RegisterSpec reg = regs.get(usedRegIdx);
        if (reg.isCategory2()) {
          boolean isParameter = reg.getReg() >= firstParameter;
          if (reg.isEvenRegister()) {
            if (isParameter) {
              aligned64bitParamAccess++;
            } else {
              aligned64bitRegAccess++;
            }
          } else {
            if (isParameter) {
              notAligned64bitParamAccess++;
            } else {
              notAligned64bitRegAccess++;
            }
          }
        }
      }
    }

    if (notAligned64bitParamAccess > aligned64bitParamAccess
        && notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);
    } else if (notAligned64bitParamAccess > aligned64bitParamAccess) {
      addReservedParameters(1);
    } else if (notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);

      // Need to shift parameters if they exist and if number of unaligned is greater than
      // aligned. We test the opposite because we previously shift all registers by one,
      // so the number of aligned become the number of unaligned.
      if (paramSize != 0 && aligned64bitParamAccess > notAligned64bitParamAccess) {
        addReservedParameters(1);
      }
    } else {
      break;
    }

    if (!reserveRegisters(opcodes)) {
      break;
    }
  }
}
 
Example 3
Source File: OutputFinisher.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
private void align64bits(Dop[] opcodes) {
  while (true) {
    int notAligned64bitRegAccess = 0;
    int aligned64bitRegAccess = 0;
    int notAligned64bitParamAccess = 0;
    int aligned64bitParamAccess = 0;
    int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount;
    int firstParameter = lastParameter - paramSize;

    // Collects the number of time that 64-bit registers are accessed aligned or not.
    for (DalvInsn insn : insns) {
      RegisterSpecList regs = insn.getRegisters();
      for (int usedRegIdx = 0; usedRegIdx < regs.size(); usedRegIdx++) {
        RegisterSpec reg = regs.get(usedRegIdx);
        if (reg.isCategory2()) {
          boolean isParameter = reg.getReg() >= firstParameter;
          if (reg.isEvenRegister()) {
            if (isParameter) {
              aligned64bitParamAccess++;
            } else {
              aligned64bitRegAccess++;
            }
          } else {
            if (isParameter) {
              notAligned64bitParamAccess++;
            } else {
              notAligned64bitRegAccess++;
            }
          }
        }
      }
    }

    if (notAligned64bitParamAccess > aligned64bitParamAccess
        && notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);
    } else if (notAligned64bitParamAccess > aligned64bitParamAccess) {
      addReservedParameters(1);
    } else if (notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);

      // Need to shift parameters if they exist and if number of unaligned is greater than
      // aligned. We test the opposite because we previously shift all registers by one,
      // so the number of aligned become the number of unaligned.
      if (paramSize != 0 && aligned64bitParamAccess > notAligned64bitParamAccess) {
        addReservedParameters(1);
      }
    } else {
      break;
    }

    if (!reserveRegisters(opcodes)) {
      break;
    }
  }
}
 
Example 4
Source File: OutputFinisher.java    From buck with Apache License 2.0 4 votes vote down vote up
private void align64bits(Dop[] opcodes) {
  while (true) {
    int notAligned64bitRegAccess = 0;
    int aligned64bitRegAccess = 0;
    int notAligned64bitParamAccess = 0;
    int aligned64bitParamAccess = 0;
    int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount;
    int firstParameter = lastParameter - paramSize;

    // Collects the number of time that 64-bit registers are accessed aligned or not.
    for (DalvInsn insn : insns) {
      RegisterSpecList regs = insn.getRegisters();
      for (int usedRegIdx = 0; usedRegIdx < regs.size(); usedRegIdx++) {
        RegisterSpec reg = regs.get(usedRegIdx);
        if (reg.isCategory2()) {
          boolean isParameter = reg.getReg() >= firstParameter;
          if (reg.isEvenRegister()) {
            if (isParameter) {
              aligned64bitParamAccess++;
            } else {
              aligned64bitRegAccess++;
            }
          } else {
            if (isParameter) {
              notAligned64bitParamAccess++;
            } else {
              notAligned64bitRegAccess++;
            }
          }
        }
      }
    }

    if (notAligned64bitParamAccess > aligned64bitParamAccess
        && notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);
    } else if (notAligned64bitParamAccess > aligned64bitParamAccess) {
      addReservedParameters(1);
    } else if (notAligned64bitRegAccess > aligned64bitRegAccess) {
      addReservedRegisters(1);

      // Need to shift parameters if they exist and if number of unaligned is greater than
      // aligned. We test the opposite because we previously shift all registers by one,
      // so the number of aligned become the number of unaligned.
      if (paramSize != 0 && aligned64bitParamAccess > notAligned64bitParamAccess) {
        addReservedParameters(1);
      }
    } else {
      break;
    }

    if (!reserveRegisters(opcodes)) {
      break;
    }
  }
}