Skip to content

[Question][Hw2] Clarifications needed on semantics.ml codes #21

@yusungsim

Description

@yusungsim

I have several questions to clarify my understanding on semantics.ml codes.

  1. Types of functions

Because there were no type annotations on the skeleton code, I want to check types of functions in the code.

eval: llvalue -> Memory -> Value
execute_block: (llbasicblock * llvalue) option -> llbasicblock -> Memory -> Memory
execute_instr: (llbasicblock * llvalue) option -> (llbasicblock  * llvalue) llpos -> Memory -> Memory
transfer: (llbasicblock * llvalue) option -> llvalue -> Memory -> Memory

Although it is not explicitly shown in the code or document, I think execute_block, execute_instr, transfer functions should have Memory return types, because it is implementing transitional semantics.
Are these correct types?

  1. Iterating through instructions in block

In execute_block function, execute_instr function is only once on the first instructions. This means that in order to compute total result of a block, there should be some kind of iteration through instructions in the block in execute_instr or transfer function. However we only have rooms to implement in transfer function, at each pattern cases. Does this mean that we need some recursion to iterate through the block? In addition, can we change the parts of codes other than failwith "Not implemented" so that this iteration can be efficiently implemented?

  1. Distinguishing Int (Int32) and Bool (Int 1) in eval function

Readme mentions that Int32 should be interpreted as Integer constant and Int1 should be interpreted as Bool. This should happen when matching ValueKind of expression in eval function. Given only e: llvalue which is matched to ValueKind.ConstantInt, how can we known that it's Int32 or Int1?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions