Skip to content

Commit

Permalink
IR: Let primitive expressions take manifest arguments
Browse files Browse the repository at this point in the history
Triggered by the clean-up necessary post #560 I finally fixe something
that bothered me a long time:

The IR pretends that primitive values are first-class functions, but
they are never compiled that way (and should not, and maybe even cannot,
as in the case of `@serialize` with a lying polymorophic type), instead
they _always_ have manifest arguments.

So this gives `PrimE` an `exp list`.

At this point, there is no fundamental difference anymore between an
unary operation and a primitive with one argument. So unary and binary
operations and relations become just one such primtive operations.
This removes redundancy in IR-to-IR passes.

There is currently an `OtherPrim` constructor that still takes a string.
Eventually, this should disappear, replaced by an ADT of the actual
prims we support, e.g. a `NumericConversion of (Type.prim, Type.prim)`
constructor instead of the unstructured `"Int->Word32"` strings right
now. This would also allow for a nicer backend, as common code is
easiler shared between the many conversions.
  • Loading branch information
nomeata committed Jul 15, 2019
1 parent 01dd5c1 commit 8762595
Show file tree
Hide file tree
Showing 19 changed files with 462 additions and 481 deletions.
2 changes: 0 additions & 2 deletions src/as_values/prim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ let prim = function
let nobbles = mapi (fun i f -> f i) (classify_utf8_leader (of_int (Char.code s.[0]))) in
let code = fold_left (fun acc nobble -> logor (shift_left acc 6) nobble) 0l nobbles in
k (Tup [Word32 (of_int (length nobbles)); Char (to_int code)])
| "@serialize" -> fun v k -> k (Serialized v)
| "@deserialize" -> fun v k -> k (as_serialized v)

| "array_len" -> fun v k ->
k (Int (Int.of_int (Array.length (Value.as_array v))))
Expand Down
Loading

0 comments on commit 8762595

Please sign in to comment.