Replies: 8 comments
-
In this case, block_fold type must be (int * int)->llvalue->(int * int) due to second argument of the fold_left_functions. |
Beta Was this translation helpful? Give feedback.
-
I think my function type is correct. Block_fold function type is already (int * int)->llvalue->(int * int).... |
Beta Was this translation helpful? Give feedback.
-
The error message said, your function type is (a'->b')->llvalue->a'->b'. |
Beta Was this translation helpful? Give feedback.
-
According to Ocaml website( https://ocaml.org/learn/tutorials/common_error_messages.html ), |
Beta Was this translation helpful? Give feedback.
-
According to the error msg, your function type is somewhat wrong. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/prosyslab-classroom/llvm-primer/blob/master/example.md |
Beta Was this translation helpful? Give feedback.
-
Some general tips:
let scan_block : (int * int) -> llblock -> (int * int)
= fun (num_all, num_call) blk ->
Llvm.fold_left_instrs (* for each instruction in the block *)
(fun (num_all, num_call) instr ->
match Llvm.instr_opcode instr with (* count depending on the instruction opcode *)
| Llvm.Opcode.Call -> (num_all + 1, num_call + 1)
| _ -> (num_all + 1, num_call))
(num_all, num_call) blk Also you can annotate types for arbitrary expressions such as
|
Beta Was this translation helpful? Give feedback.
-
I found out the reason. I forgot to write semicolon for line delimiter. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-

I'm trying to use fold_left_functions and I'm confused about the argument type. In the website, https://llvm.moe/ocaml/Llvm.html said val fold_left_functions : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'aSo fold_left_functions takes a function whose type is (a'->llvalue->'a) as the first argument.
However, in the VM machine, ((a'->b')->llvalue->a'->b') is needed.
Am I misunderstanding something..?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions