Search in sources :

Example 1 with XcodeML

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) {
    }
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) IllegalTransformationException(claw.tatsu.xcodeml.exception.IllegalTransformationException) TestContext(helper.Utils.TestContext) XcodeML(claw.tatsu.xcodeml.xnode.common.XcodeML) Test(org.junit.Test)

Example 2 with XcodeML

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);
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) FfunctionDefinition(claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition) IllegalTransformationException(claw.tatsu.xcodeml.exception.IllegalTransformationException) TestContext(helper.Utils.TestContext) XcodeML(claw.tatsu.xcodeml.xnode.common.XcodeML) DimensionDefinition(claw.tatsu.xcodeml.abstraction.DimensionDefinition) Test(org.junit.Test)

Aggregations

Context (claw.tatsu.common.Context)2 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)2 XcodeML (claw.tatsu.xcodeml.xnode.common.XcodeML)2 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)2 TestContext (helper.Utils.TestContext)2 Test (org.junit.Test)2 DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)1 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)1