public String getVectorName() { return vectorVariableDeclInfo.getName(); }
@Override public void visitVariableDeclInfo(VariableDeclInfo variableDeclInfo) { names.add(variableDeclInfo.getName()); }
@Override protected void visitVariableDeclInfoAfterAddedToScope(VariableDeclInfo declInfo) { String renamedVariable; if (inUniformDecl && uniformMapping.containsKey(declInfo.getName())) { renamedVariable = uniformMapping.get(declInfo.getName()); } else { renamedVariable = renameVariable(declInfo.getName()); if (inUniformDecl) { uniformMapping.put(declInfo.getName(), renamedVariable); } } varDeclMapping.put(declInfo, renamedVariable); }
private boolean isLiveInjection(VariableDeclInfo variableDeclInfo) { return variableDeclInfo.getName().startsWith(Constants.LIVE_PREFIX); }
@Override public String toString() { return entries.stream().map(item -> item.getVariableDeclInfo().getName()) .collect(Collectors.toList()).toString(); }
private static boolean alreadyDeclaresInjectionSwitch(TranslationUnit tu) { return tu.getGlobalVarDeclInfos() .stream() .map(item -> item.getName()) .collect(Collectors.toList()) .contains(Constants.INJECTION_SWITCH); }
private static Optional<String> containsOutVariableBackup(BlockStmt block) { return block.getStmts().stream() .filter(item -> item instanceof DeclarationStmt) .map(item -> (DeclarationStmt) item) .filter(LiveOutputVariableWriteReductionOpportunities::isOutVariableBackup) .findFirst() .map(vdi -> vdi.getVariablesDeclaration().getDeclInfos() .stream().map(item -> item.getName()).findFirst().get()); }
@Override public void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration) { System.out.println("Entering variables declaration"); for (VariableDeclInfo vdi : variablesDeclaration.getDeclInfos()) { System.out.println(" " + vdi.getName()); } super.visitVariablesDeclaration(variablesDeclaration); System.out.println("Leaving variables declaration"); } }
@Override public void visitVariableDeclInfo(VariableDeclInfo variableDeclInfo) { super.visitVariableDeclInfo(variableDeclInfo); if (atGlobalScope() && !variableDeclInfo.getName().equals(Constants.INJECTION_SWITCH)) { // Initially, assume it is unused unusedGlobals.add(variableDeclInfo); } }
private boolean isOutVariableBackup(DeclarationStmt declarationStmt) { return declarationStmt.getVariablesDeclaration().getDeclInfos() .stream().anyMatch(vdi -> vdi.getName().equals(backupName)); }
private boolean blockAlreadyDeclaresVector() { // When we do multiple transformation passes, the same vectorization attempt might be applied // multiple times. If we would create a vector whose name is already declared in this block, // we bail out. return block.getStmts().stream().filter(item -> item instanceof DeclarationStmt) .map(item -> ((DeclarationStmt) item).getVariablesDeclaration().getDeclInfos()) .reduce(new ArrayList<>(), ListConcat::concatenate) .stream() .anyMatch(item -> item.getName().equals(mergeSet.getMergedName())); }
private boolean replacementVariableNameDeclaredInThisBlock() { return block.getStmts().stream() .filter(item -> item instanceof DeclarationStmt) .map(item -> (DeclarationStmt) item) .map(item -> item.getVariablesDeclaration()) .map(item -> item.getDeclInfos()) .reduce(Arrays.asList(), ListConcat::concatenate) .stream() .anyMatch(item -> item.getName().equals(findOriginalVariableInfo().getName())); }
@Override public void applyReductionImpl() { firstLoop.setCondition(secondLoop.getCondition()); enclosingBlock.removeStmt(secondLoop); final String splitLoopCounter = ((DeclarationStmt) firstLoop.getInit()) .getVariablesDeclaration().getDeclInfo(0).getName(); int originalNameBeginIndex = Constants.SPLIT_LOOP_COUNTER_PREFIX.length(); assert Character.isDigit(splitLoopCounter.charAt(originalNameBeginIndex)); while (Character.isDigit(splitLoopCounter.charAt(originalNameBeginIndex))) { originalNameBeginIndex++; } final String mergedLoopCounter = splitLoopCounter.substring(originalNameBeginIndex); ReplaceLoopCounter.replaceLoopCounter(firstLoop, splitLoopCounter, mergedLoopCounter); }
static boolean isStructifiedDeclaration(DeclarationStmt declarationStmt) { return declarationStmt.getVariablesDeclaration().getNumDecls() == 1 && declarationStmt.getVariablesDeclaration().getDeclInfo(0).getName() .startsWith(Constants.STRUCTIFICATION_STRUCT_PREFIX); }
@Override public void visitVariableDeclInfo(VariableDeclInfo variableDeclInfo) { super.visitVariableDeclInfo(variableDeclInfo); variableDeclInfo.setName(addPrefix(variableDeclInfo.getName())); }
private Optional<String> extractLoopCounter(ForStmt loop) { if (!(loop.getInit() instanceof DeclarationStmt)) { return Optional.empty(); } final DeclarationStmt init = (DeclarationStmt) loop.getInit(); if (init.getVariablesDeclaration().getNumDecls() != 1) { return Optional.empty(); } return Optional.of(init.getVariablesDeclaration().getDeclInfo(0).getName()); }
public String getMergedName() { final List<MergedVariablesComponentData> mergedVariablesComponentDataList = new ArrayList<>(); int currentOffset = 0; for (ScopeEntry entry : entries) { mergedVariablesComponentDataList.add( new MergedVariablesComponentData(currentOffset, getWidth(entry), entry.getVariableDeclInfo().getName())); currentOffset += getWidth(entry); } return getMergedName(mergedVariablesComponentDataList); }
private void addComponentVariableIfNotPresent() { if (getAllVariableDeclInfosInBlock() .stream() .anyMatch(item -> item.getName().equals(getComponentName()))) { return; } block.insertStmt(0, new DeclarationStmt(new VariablesDeclaration( getComponentType(), new VariableDeclInfo(getComponentName(), null, null)))); }
@Override public void visitFunctionCallExpr(FunctionCallExpr functionCallExpr) { super.visitFunctionCallExpr(functionCallExpr); for (int i = 0; i < functionCallExpr.getNumArgs(); i++) { Expr arg = functionCallExpr.getArg(i); if (arg instanceof VariableIdentifierExpr && ((VariableIdentifierExpr) arg) .getName().equals(declaration.getVariablesDeclaration().getDeclInfo(0).getName())) { functionCallExpr.setArg(i, new VariableIdentifierExpr(originalVariableInfo.getName())); } } }
@Override public void visitFunctionPrototype(FunctionPrototype functionPrototype) { super.visitFunctionPrototype(functionPrototype); for (int i = 0; i < functionPrototype.getNumParameters(); i++) { if (functionPrototype.getParameter(i).getType().getWithoutQualifiers() .equals(declaration.getVariablesDeclaration().getBaseType().getWithoutQualifiers())) { assert declaration.getVariablesDeclaration().getDeclInfo(0).getName() .equals(functionPrototype.getParameter(i).getName()); functionPrototype.getParameter(i).setName(originalVariableInfo.getName()); functionPrototype.getParameter(i).setType(originalVariableInfo.getType()); } } }