use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawTranslatorDriver method analyze.
/**
* Analysis the XcodeML/F directives and categorized them in corresponding
* transformation with the help of the translator.
*
* @throws Exception
*/
public void analyze(InputStream inStrm) throws Exception {
_translationUnit = XcodeProgram.createFromStream(inStrm, context());
if (_translationUnit.hasErrors()) {
flushErrors();
throw new Exception("Translation unit has errors");
}
if (cfg().getCurrentDirective() == CompilerDirective.OPENMP && cfg().getCurrentTarget() == Target.CPU) {
_translationUnit.addWarning("Fine grain OpenMP directive generation " + "is not advised for CPU target.", 0);
}
try {
// Check all pragma found in the translation unit
for (Xnode pragma : _translationUnit.matchAll(Xcode.F_PRAGMA_STATEMENT)) {
// Pragma can be handled by the translator so let it do its job.
if (_translator.isHandledPragma(pragma)) {
_translator.generateTransformation(_translationUnit, pragma);
} else {
// Check if the pragma is a compile guard
if (context().getGenerator().isCompileGuard(pragma.value())) {
pragma.delete();
} else {
// Handle special transformation of OpenACC line continuation
for (GroupConfiguration gc : cfg().getGroups()) {
if (gc.getTriggerType() == GroupConfiguration.TriggerType.DIRECTIVE && Pragma.getPrefix(pragma).equals(gc.getDirective())) {
generateTransformation(gc, new ClawPragma(pragma));
}
}
}
}
}
_translator.finalizeTranslation(_translationUnit);
} catch (IllegalDirectiveException e) {
_translationUnit.addError(e.getMessage(), e.getDirectiveLine());
flushErrors();
throw e;
} catch (IllegalTransformationException e) {
_translationUnit.addError(e.getMessage(), e.getStartLine());
flushErrors();
throw e;
}
// Generate transformation for translation_unit trigger type
for (GroupConfiguration gc : cfg().getGroups()) {
if (gc.getTriggerType() == GroupConfiguration.TriggerType.TRANSLATION_UNIT) {
generateTransformation(gc, null);
}
}
// Analysis done, the transformation can be performed.
_canTransform = true;
}
Aggregations