Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[omr-dev] When to generate TreeTops

I was wondering how to decide whether a TreeTop must be generated. In
the example below (this is in my wip C api but the operations should
be clear). Here the function takes an argument of type int32_t* and I
am trying to get/set the value at array offset 1.

static bool test2_il(JIT_ILInjectorRef ilinjector, void *userdata) {
    JIT_CreateBlocks(ilinjector, 1);
    JIT_SetCurrentBlock(ilinjector, 0);
    auto index = JIT_ConstInt32(4); // Byte offset of int32_t[1]
    auto base = JIT_LoadParameter(ilinjector, 0); // Load arg
    auto value = JIT_ArrayLoad(ilinjector, base, index, JIT_Int32); //
Get arg[1]
    JIT_GenerateTreeTop(ilinjector, value); // Without TreeTop here we
get the stored value below
    JIT_ArrayStore(ilinjector, base, index, JIT_ConstInt32(42)); //
Set arg[1] = 42
    auto node = JIT_CreateNode1C(OP_ireturn, value);
    JIT_GenerateTreeTop(ilinjector, node);
    JIT_CFGAddEdge(ilinjector,
JIT_BlockAsCFGNode(JIT_GetCurrentBlock(ilinjector)),
JIT_GetCFGEnd(ilinjector));
    return true;
}

If I don't have the Load anchored in a TreeTop then the generated code
returns the value from the store - i.e. 42 instead of whatever was
originally at arg[1].

In general - what criteria should be used to decide whether to
generate TreeTop or not? (I have read the docs - I am looking for more
specific info).

Thanks and Regards
Dibyendu


Back to the top