use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class NormalSsaInsn method setNewSources.
/**
* Changes the source list of the insn. New source list should be the
* same size and consist of sources of identical types.
*
* @param newSources non-null new sources list.
*/
public final void setNewSources(RegisterSpecList newSources) {
RegisterSpecList origSources = insn.getSources();
if (origSources.size() != newSources.size()) {
throw new RuntimeException("Sources counts don't match");
}
insn = insn.withNewRegisters(getResult(), newSources);
}
use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class NormalSsaInsn method mapSourceRegisters.
/** {@inheritDoc} */
@Override
public final void mapSourceRegisters(RegisterMapper mapper) {
RegisterSpecList oldSources = insn.getSources();
RegisterSpecList newSources = mapper.map(oldSources);
if (newSources != oldSources) {
insn = insn.withNewRegisters(getResult(), newSources);
getBlock().getParent().onSourcesChanged(this, oldSources);
}
}
use of com.taobao.android.dx.rop.code.RegisterSpecList 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.RegisterSpecList in project atlas by alibaba.
the class RegisterMapper method map.
/**
*
* @param sources old register list
* @return new mapped register list, or old if nothing has changed.
*/
public final RegisterSpecList map(RegisterSpecList sources) {
int sz = sources.size();
RegisterSpecList newSources = new RegisterSpecList(sz);
for (int i = 0; i < sz; i++) {
newSources.set(i, map(sources.get(i)));
}
newSources.setImmutable();
// Return the old sources if nothing has changed.
return newSources.equals(sources) ? sources : newSources;
}
use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class SCCP method simulatePhi.
/**
* Simulates a PHI node and set the lattice for the result
* to the appropriate value.
* Meet values:
* TOP x anything = TOP
* VARYING x anything = VARYING
* CONSTANT x CONSTANT = CONSTANT if equal constants, VARYING otherwise
* @param insn PHI to simulate.
*/
private void simulatePhi(PhiInsn insn) {
int phiResultReg = insn.getResult().getReg();
if (latticeValues[phiResultReg] == VARYING) {
return;
}
RegisterSpecList sources = insn.getSources();
int phiResultValue = TOP;
Constant phiConstant = null;
int sourceSize = sources.size();
for (int i = 0; i < sourceSize; i++) {
int predBlockIndex = insn.predBlockIndexForSourcesIndex(i);
int sourceReg = sources.get(i).getReg();
int sourceRegValue = latticeValues[sourceReg];
if (!executableBlocks.get(predBlockIndex)) {
continue;
}
if (sourceRegValue == CONSTANT) {
if (phiConstant == null) {
phiConstant = latticeConstants[sourceReg];
phiResultValue = CONSTANT;
} else if (!latticeConstants[sourceReg].equals(phiConstant)) {
phiResultValue = VARYING;
break;
}
} else {
phiResultValue = sourceRegValue;
break;
}
}
if (setLatticeValueTo(phiResultReg, phiResultValue, phiConstant)) {
addUsersToWorklist(phiResultReg, phiResultValue);
}
}
Aggregations