Search in sources :

Example 26 with FfunctionDefinition

use of claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition 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)

Example 27 with FfunctionDefinition

use of claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition in project claw-compiler by C2SM-RCM.

the class XmlHelper method createXfunctionDefinitionFromString.

public static FfunctionDefinition createXfunctionDefinitionFromString(String xml) {
    Xnode n = XmlHelper.getElementFromString(xml);
    assertNotNull(n);
    return new FfunctionDefinition(n);
}
Also used : Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) FfunctionDefinition(claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)

Aggregations

FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)27 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)16 Context (claw.tatsu.common.Context)13 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)11 Test (org.junit.Test)10 TestContext (helper.Utils.TestContext)9 XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)6 FmoduleDefinition (claw.tatsu.xcodeml.xnode.fortran.FmoduleDefinition)6 ClawTranslator (claw.wani.x2t.translator.ClawTranslator)6 Xid (claw.tatsu.xcodeml.xnode.common.Xid)4 DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)3 FunctionCall (claw.tatsu.xcodeml.abstraction.FunctionCall)3 PromotionInfo (claw.tatsu.xcodeml.abstraction.PromotionInfo)3 Xblock (claw.tatsu.xcodeml.abstraction.Xblock)3 HoistedNestedDoStatement (claw.tatsu.xcodeml.abstraction.HoistedNestedDoStatement)2 ReshapeInfo (claw.tatsu.xcodeml.abstraction.ReshapeInfo)2 FbasicType (claw.tatsu.xcodeml.xnode.fortran.FbasicType)2 FfunctionType (claw.tatsu.xcodeml.xnode.fortran.FfunctionType)2 Configuration (claw.wani.x2t.configuration.Configuration)2 Transformation (claw.shenron.transformation.Transformation)1