public boolean canAccept(ScopeEntry entry) { BasicType basicType = (BasicType) entry.getType().getWithoutQualifiers(); if (!(basicType.getElementType().equals(elementType))) { return false; } if (entries.stream() .anyMatch(x -> x.getVariablesDeclaration() == entry.getVariablesDeclaration())) { return false; } return currentWidth() + basicType.getNumElements() <= MAX_WIDTH; }
private void getReductionOpportunitiesForUnusedGlobals() { for (String name : currentScope.keys()) { ScopeEntry entry = currentScope.lookupScopeEntry(name); assert entry.hasVariableDeclInfo(); assert referencedScopeEntries.peek() != null; if (!referencedScopeEntries.peek().contains(entry)) { addOpportunity(new VariableDeclReductionOpportunity(entry.getVariableDeclInfo(), entry.getVariablesDeclaration(), getVistitationDepth())); } } }
private boolean nonConst(VariableIdentifierExpr variableIdentifierExpr) { final ScopeEntry se = currentScope.lookupScopeEntry(variableIdentifierExpr.getName()); return se != null && se.hasVariablesDeclaration() && !se.getVariablesDeclaration().getBaseType() .hasQualifier(TypeQualifier.CONST); }
@Override public void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr) { super.visitVariableIdentifierExpr(variableIdentifierExpr); ScopeEntry se = currentScope.lookupScopeEntry(variableIdentifierExpr.getName()); if (se == null) { // We are traversing a block in isolation, so we won't have a scope entry for any variable // declared outside the block. return; } if (se.getVariablesDeclaration() == declToTransform.getVariablesDeclaration()) { parentMap.getParent(variableIdentifierExpr).replaceChild( variableIdentifierExpr, structifiedExpr.clone()); } } }.visit(block);
new VariableDeclReductionOpportunity( entry.getVariableDeclInfo(), entry.getVariablesDeclaration(), getVistitationDepth()));