def make_assign_to_local_var(local_var_name: str, rhs):
    return sir.ExprStmt(expr=sir.AssignmentExpr(
        left=make_var_acc(local_var_name), op="=", right=rhs))
Exemple #2
0
# Eve toolchain

from devtools import debug  # noqa: F401

import eve  # noqa: F401
from gtc import common, sir
from gtc.unstructured import naive_codegen, sir_to_naive

field_acc_a = sir.FieldAccessExpr(name="field_a",
                                  vertical_offset=0,
                                  horizontal_offset=sir.ZeroOffset())
field_acc_b = sir.FieldAccessExpr(name="field_b",
                                  vertical_offset=0,
                                  horizontal_offset=sir.ZeroOffset())

assign_expr = sir.AssignmentExpr(left=field_acc_a, op="=", right=field_acc_b)
assign_expr_stmt = sir.ExprStmt(expr=assign_expr)
root = sir.BlockStmt(statements=[assign_expr_stmt])
ast = sir.AST(root=root)

vert_decl_stmt = sir.VerticalRegionDeclStmt(vertical_region=sir.VerticalRegion(
    ast=ast, interval=sir.Interval(), loop_order=common.LoopOrder.FORWARD))
ctrl_flow_ast = sir.AST(root=sir.BlockStmt(statements=[vert_decl_stmt]))

field_a = sir.Field(
    name="field_a",
    is_temporary=False,
    field_dimensions=sir.FieldDimensions(
        horizontal_dimension=sir.UnstructuredDimension(
            dense_location_type=sir.LocationType.Cell)),
)
Exemple #3
0
    dimension=0,
    op="=",
    init_list=[zavg_mul],
)

statements.append(zavg_decl)

#             sir_utils.make_assignment_stmt(sir_utils.make_field_access_expr(
#                 "zavgS_MXX"), sir_utils.make_binary_operator(sir_utils.make_field_access_expr("S_MXX"), "*", sir_utils.make_var_access_expr("zavg"))),
assign_zavgS_MXX = sir.ExprStmt(expr=sir.AssignmentExpr(
    left=sir.FieldAccessExpr(name="zavgS_MXX",
                             vertical_offset=0,
                             horizontal_offset=sir.ZeroOffset()),
    op="=",
    right=sir.BinaryOperator(
        left=sir.FieldAccessExpr(name="S_MXX",
                                 vertical_offset=0,
                                 horizontal_offset=sir.ZeroOffset()),
        op="*",
        right=sir.VarAccessExpr(name="zavg"),
    ),
))
statements.append(assign_zavgS_MXX)
#             sir_utils.make_assignment_stmt(sir_utils.make_field_access_expr(
#                 "zavgS_MYY"), sir_utils.make_binary_operator(sir_utils.make_field_access_expr("S_MYY"), "*", sir_utils.make_var_access_expr("zavg"))),
assign_zavgS_MYY = sir.ExprStmt(expr=sir.AssignmentExpr(
    left=sir.FieldAccessExpr(name="zavgS_MYY",
                             vertical_offset=0,
                             horizontal_offset=sir.ZeroOffset()),
    op="=",
    right=sir.BinaryOperator(