use of com.taobao.android.dx.rop.code.LocalItem in project atlas by alibaba.
the class SsaRenamer method setNameForSsaReg.
/**
* Records a debug (local variable) name for a specified register.
*
* @param ssaReg non-null named register spec in SSA name space
*/
private void setNameForSsaReg(RegisterSpec ssaReg) {
int reg = ssaReg.getReg();
LocalItem local = ssaReg.getLocalItem();
ssaRegToLocalItems.ensureCapacity(reg + 1);
while (ssaRegToLocalItems.size() <= reg) {
ssaRegToLocalItems.add(null);
}
ssaRegToLocalItems.set(reg, local);
}
use of com.taobao.android.dx.rop.code.LocalItem in project atlas by alibaba.
the class FirstFitLocalCombiningAllocator method printLocalVars.
/**
* Dumps local variable table to stdout for debugging.
*/
private void printLocalVars() {
System.out.println("Printing local vars");
for (Map.Entry<LocalItem, ArrayList<RegisterSpec>> e : localVariables.entrySet()) {
StringBuilder regs = new StringBuilder();
regs.append('{');
regs.append(' ');
for (RegisterSpec reg : e.getValue()) {
regs.append('v');
regs.append(reg.getReg());
regs.append(' ');
}
regs.append('}');
System.out.printf("Local: %s Registers: %s\n", e.getKey(), regs);
}
}
use of com.taobao.android.dx.rop.code.LocalItem in project atlas by alibaba.
the class NormalSsaInsn method getLocalAssignment.
/** {@inheritDoc} */
@Override
public RegisterSpec getLocalAssignment() {
RegisterSpec assignment;
if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
assignment = insn.getSources().get(0);
} else {
assignment = getResult();
}
if (assignment == null) {
return null;
}
LocalItem local = assignment.getLocalItem();
if (local == null) {
return null;
}
return assignment;
}
use of com.taobao.android.dx.rop.code.LocalItem in project atlas by alibaba.
the class FirstFitLocalCombiningAllocator method adjustAndMapSourceRangeRange.
/**
* Maps the source registers of the specified instruction such that they
* will fall in a contiguous range in rop form. Moves are inserted as
* necessary to allow the range to be allocated.
*
* @param insn {@code non-null;} insn whos sources to process
*/
private void adjustAndMapSourceRangeRange(NormalSsaInsn insn) {
int newRegStart = findRangeAndAdjust(insn);
RegisterSpecList sources = insn.getSources();
int szSources = sources.size();
int nextRopReg = newRegStart;
for (int i = 0; i < szSources; i++) {
RegisterSpec source = sources.get(i);
int sourceReg = source.getReg();
int category = source.getCategory();
int curRopReg = nextRopReg;
nextRopReg += category;
if (ssaRegsMapped.get(sourceReg)) {
continue;
}
LocalItem localItem = getLocalItemForReg(sourceReg);
addMapping(source, curRopReg);
if (localItem != null) {
markReserved(curRopReg, category);
ArrayList<RegisterSpec> similarRegisters = localVariables.get(localItem);
int szSimilar = similarRegisters.size();
/*
* Try to map all SSA registers also associated with
* this local.
*/
for (int j = 0; j < szSimilar; j++) {
RegisterSpec similarSpec = similarRegisters.get(j);
int similarReg = similarSpec.getReg();
// Don't map anything that's also a source.
if (-1 != sources.indexOfRegister(similarReg)) {
continue;
}
// Registers left unmapped will get handled later.
tryMapReg(similarSpec, curRopReg, category);
}
}
}
}
use of com.taobao.android.dx.rop.code.LocalItem in project atlas by alibaba.
the class ConstCollector method fixLocalAssignment.
/**
* Inserts mark-locals if necessary when changing a register. If
* the definition of {@code origReg} is associated with a local
* variable, then insert a mark-local for {@code newReg} just below
* it. We expect the definition of {@code origReg} to ultimately
* be removed by the dead code eliminator
*
* @param origReg {@code non-null;} original register
* @param newReg {@code non-null;} new register that will replace
* {@code origReg}
*/
private void fixLocalAssignment(RegisterSpec origReg, RegisterSpec newReg) {
for (SsaInsn use : ssaMeth.getUseListForRegister(origReg.getReg())) {
RegisterSpec localAssignment = use.getLocalAssignment();
if (localAssignment == null) {
continue;
}
if (use.getResult() == null) {
/*
* This is a mark-local. it will be updated when all uses
* are updated.
*/
continue;
}
LocalItem local = localAssignment.getLocalItem();
// Un-associate original use.
use.setResultLocal(null);
// Now add a mark-local to the new reg immediately after.
newReg = newReg.withLocalItem(local);
SsaInsn newInsn = SsaInsn.makeFromRop(new PlainInsn(Rops.opMarkLocal(newReg), SourcePosition.NO_INFO, null, RegisterSpecList.make(newReg)), use.getBlock());
ArrayList<SsaInsn> insns = use.getBlock().getInsns();
insns.add(insns.indexOf(use) + 1, newInsn);
}
}
Aggregations