This PR adds support for representing more inductive as enums, summarized up as extending support to those that fail to be enums because of parameters or irrelevant fields. While this is nice to have, it is actually motivated by correctness of a future desired optimization. The existing type representation is unsound if we implement `object`/`tobject` distinction between values guaranteed to be an object pointer and those that may also be a tagged scalar. In particular, types like the ones added in this PR's tests would have all of their constructors encoded via tagged values, but under the natural extension of the existing rules of type representation they would be considered `object` rather than `tobject`.
44 lines
757 B
Text
44 lines
757 B
Text
inductive E1 (n : Nat) where
|
|
| a
|
|
| b
|
|
| c
|
|
|
|
/--
|
|
trace: [Compiler.IR] [result]
|
|
def e1 : u8 :=
|
|
let x_1 : u8 := 2;
|
|
ret x_1
|
|
-/
|
|
#guard_msgs in
|
|
set_option trace.compiler.ir.result true in
|
|
def e1 : E1 7 := .c
|
|
|
|
inductive E2 where
|
|
| a (p : 0 = 0)
|
|
| b (p : 1 = 1)
|
|
| c (p : 0 = 1)
|
|
|
|
/--
|
|
trace: [Compiler.IR] [result]
|
|
def e2 : u8 :=
|
|
let x_1 : u8 := 1;
|
|
ret x_1
|
|
-/
|
|
#guard_msgs in
|
|
set_option trace.compiler.ir.result true in
|
|
def e2 : E2 := .b rfl
|
|
|
|
inductive E3 (m n : Nat) where
|
|
| a (p : 0 = 0)
|
|
| b (p : 1 = 1)
|
|
| c (p : 0 = 0) (q : 1 = 1)
|
|
|
|
/--
|
|
trace: [Compiler.IR] [result]
|
|
def e3 : u8 :=
|
|
let x_1 : u8 := 2;
|
|
ret x_1
|
|
-/
|
|
#guard_msgs in
|
|
set_option trace.compiler.ir.result true in
|
|
def e3 : E3 7 11 := .c rfl rfl
|