use of cx2x.translator.transformation.openacc.OpenAccContinuation in project claw-compiler by C2SM-RCM.
the class ClawXcodeMlTranslator method analyze.
/**
* Analysis the XcodeML code and produce a list of applicable transformation.
*/
public void analyze() {
_program = XcodeProgram.createFromFile(_xcodemlInputFile);
if (_program == null) {
abort();
}
// Check all pragma found in the program
for (Xnode pragma : _program.getAllStmt(Xcode.FPRAGMASTATEMENT)) {
// pragma does not start with the CLAW prefix
if (!ClawLanguage.startsWithClaw(pragma)) {
// Compile guard removal
if (_generator != null && _generator.isCompileGuard(pragma.value())) {
pragma.delete();
} else // Handle special transformation of OpenACC line continuation
if (pragma.value().toLowerCase().startsWith(ClawConstant.OPENACC_PREFIX)) {
OpenAccContinuation t = new OpenAccContinuation(new AnalyzedPragma(pragma));
addOrAbort(t);
}
// Not CLAW pragma, we do nothing
continue;
}
try {
// Analyze the raw pragma with the CLAW language parser
ClawLanguage analyzedPragma = ClawLanguage.analyze(pragma, _generator, _target);
// Create transformation object based on the directive
switch(analyzedPragma.getDirective()) {
case ARRAY_TO_CALL:
addOrAbort(new ArrayToFctCall(analyzedPragma));
break;
case KCACHE:
addOrAbort(new Kcaching(analyzedPragma));
break;
case LOOP_FUSION:
addOrAbort(new LoopFusion(analyzedPragma));
break;
case LOOP_INTERCHANGE:
addOrAbort(new LoopInterchange(analyzedPragma));
break;
case LOOP_EXTRACT:
addOrAbort(new LoopExtraction(analyzedPragma));
break;
case LOOP_HOIST:
HandleBlockDirective(analyzedPragma);
break;
case ARRAY_TRANSFORM:
HandleBlockDirective(analyzedPragma);
break;
case REMOVE:
HandleBlockDirective(analyzedPragma);
break;
case PARALLELIZE:
if (analyzedPragma.hasForwardClause()) {
addOrAbort(new ParallelizeForward(analyzedPragma));
} else {
addOrAbort(new Parallelize(analyzedPragma));
}
break;
case PRIMITIVE:
addOrAbort(new DirectivePrimitive(analyzedPragma));
break;
case IF_EXTRACT:
addOrAbort(new IfExtract(analyzedPragma));
break;
// driver handled directives
case IGNORE:
case VERBATIM:
break;
default:
_program.addError("Unrecognized CLAW directive", pragma.lineNo());
abort();
}
} catch (IllegalDirectiveException ex) {
System.err.println(ex.getMessage());
abort();
}
}
// Clean up block transformation map
for (Map.Entry<ClawDirectiveKey, ClawLanguage> entry : _blockDirectives.entrySet()) {
createBlockDirectiveTransformation(entry.getValue(), null);
}
// Add utility transformation
addOrAbort(new XcodeMLWorkaround(new ClawLanguage(_program)));
// Analysis done, the transformation can be performed.
_canTransform = true;
}
Aggregations