use of claw.tatsu.xcodeml.xnode.common.XcodeML 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.xnode.common.XcodeML in project claw-compiler by C2SM-RCM.
the class LoopTest method mergeTest.
@Test
public void mergeTest() {
Context context = new TestContext();
XcodeML xcodeml = XmlHelper.getDummyXcodeProgram(context);
assertNotNull(xcodeml);
DimensionDefinition d1 = new DimensionDefinition("i", "1", "10");
Xnode inductionI = xcodeml.createVar(FortranType.INTEGER, "i", Xscope.LOCAL);
Xnode l1 = xcodeml.createDoStmt(inductionI, d1.generateIndexRange(xcodeml, true, false));
Xnode l2 = xcodeml.createDoStmt(inductionI, d1.generateIndexRange(xcodeml, true, false));
List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
assertFalse(fctDefs.isEmpty());
FfunctionDefinition f1 = fctDefs.get(0);
int doStmtCnt1 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
f1.body().append(l1);
f1.body().append(l2);
int doStmtCnt2 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
assertEquals(doStmtCnt1 + 2, doStmtCnt2);
try {
Loop.merge(l1, l2);
} catch (IllegalTransformationException e) {
fail();
}
int doStmtCnt3 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
assertEquals(doStmtCnt1 + 1, doStmtCnt3);
}
Aggregations