use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class XcodeML method importVar.
/**
* Create a copy with a new hash type of an integer variable element from one
* XcodeML unit to the current unit.
*
* @param base Base variable element to be copied.
* @param xcodemlSrc Source XcodeML unit.
* @return The newly created element in the current XcodeML unit.
* @throws IllegalTransformationException If the variable element doesn't meet
* the criteria.
*/
private Xnode importVar(Xnode base, XcodeML xcodemlSrc) throws IllegalTransformationException {
String typeValue = base.getType();
if (!FortranType.INTEGER.isOfType(typeValue)) {
throw new IllegalTransformationException("Only integer variable are " + "supported as lower/upper bound value for promoted arrays.");
}
FbasicType type = xcodemlSrc.getTypeTable().getBasicType(typeValue);
FbasicType bType = createBasicType(FortranType.INTEGER, Intent.NONE);
if (type != null) {
bType.setIntent(type.getIntent());
}
return createVar(bType.getType(), base.value(), Xscope.fromString(base.getAttribute(Xattr.SCOPE)));
}
use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class PragmaTest method splitByContTest2.
@Test
public void splitByContTest2() {
Context context = new TestContext();
context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
assertFalse(fctDefs.isEmpty());
FfunctionDefinition fd = fctDefs.get(0);
assertNotNull(fd.body());
List<Xnode> previous = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
Xnode p = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
fd.body().append(p);
p.setValue("acc data copyin(a) acc present(b)");
try {
Pragma.splitByCont(p, CompilerDirective.OPENACC.getPrefix(), xcodeml);
List<Xnode> splittedPragma = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
assertEquals(previous.size() + 2, splittedPragma.size());
} catch (IllegalTransformationException e) {
fail();
}
}
use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class ScaGPU method transformReturnStatement.
private void transformReturnStatement(XcodeProgram xcodeml) throws IllegalTransformationException {
List<Xnode> returns = _fctDef.matchAll(Xcode.F_RETURN_STATEMENT);
if (returns.isEmpty()) {
// No return statement to be transformed
return;
}
if (returns.size() > 1) {
throw new IllegalTransformationException("RETURN transformation is " + "currently limited to one per subroutine/function");
}
Xnode returnStmt = returns.get(0);
if (!canTransformReturn(returnStmt)) {
throw new IllegalTransformationException("RETURN statement cannot be " + "transformed.");
}
Xnode thenBody = returnStmt.ancestor();
Xnode thenNode = thenBody.ancestor();
Xnode ifNode = thenNode.ancestor();
Xnode elseNode = xcodeml.createElse();
ifNode.append(elseNode);
returnStmt.delete();
thenBody.append(xcodeml.createComment("CLAW: RETURN statement transformed for parallel region"));
Body.shiftIn(ifNode.nextSibling(), _fctDef.lastChild(), elseNode.body(), true);
}
use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class LoopTest method mergeFailTest.
@Test
public void mergeFailTest() {
Context context = new TestContext();
XcodeML xcodeml = XmlHelper.getDummyXcodeProgram(context);
assertNotNull(xcodeml);
Xnode n1 = xcodeml.createNode(Xcode.F_IF_STATEMENT);
Xnode n2 = xcodeml.createNode(Xcode.F_IF_STATEMENT);
try {
Loop.merge(n1, null);
fail();
} catch (IllegalTransformationException ignored) {
}
try {
Loop.merge(null, n2);
fail();
} catch (IllegalTransformationException ignored) {
}
try {
Loop.merge(n1, n2);
fail();
} catch (IllegalTransformationException ignored) {
}
}
use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class ClawTranslatorDriver method transform.
/**
* Apply all the transformation in the pipeline.
*
* @throws Exception
*/
public void transform() throws Exception {
try {
if (!_canTransform) {
return;
}
for (Map.Entry<Class<?>, TransformationGroup> entry : _translator.getGroups().entrySet()) {
Message.debug(context(), "Apply transformation: " + entry.getValue().transformationName() + " - " + entry.getValue().count());
try {
entry.getValue().applyTransformations(_translationUnit, _translator);
Message.warnings(context(), _translationUnit);
} catch (IllegalTransformationException itex) {
_translationUnit.addError(itex.getMessage(), itex.getStartLine());
flushErrors();
throw itex;
} catch (Exception ex) {
_translationUnit.addError("Unexpected error: " + ex.getMessage(), 0);
if (context().getXmOption().isDebugOutput()) {
StringWriter errors = new StringWriter();
ex.printStackTrace(new PrintWriter(errors));
_translationUnit.addError(errors.toString(), 0);
}
flushErrors();
throw ex;
}
}
} catch (Exception ex) {
context().getErrorStream().println("Transformation exception: " + ex.getMessage());
throw ex;
}
}
Aggregations