Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach GIRWriter About Types #98

Open
CodaFi opened this issue Mar 5, 2018 · 0 comments
Open

Teach GIRWriter About Types #98

CodaFi opened this issue Mar 5, 2018 · 0 comments

Comments

@CodaFi
Copy link
Member

CodaFi commented Mar 5, 2018

Currently, the GIRWriter doesn't really like Types all that much. This is current output of Tests/Seismography/switch.gir:

module switch where
@equal : (TYPE, TYPE, TYPE) -> ⊥ {
-- %0                                             -- users: %16, %24, %28, %5
-- %1                                             -- users: %17, %25, %29, %9, %21
-- %2                                             -- users: %14, %18, %26, %30
bb0(%0, %1, %2):
  %3 = function_ref @bb1                          -- user: %5
  %4 = function_ref @bb2                          -- user: %5
  switch_constr %0 ; example.Nat.z : %3 ; example.Nat.s : %4 -- id: %5

-- %6                                             -- users: %12
bb1(%6):
  %7 = function_ref @bb5                          -- user: %9
  %8 = function_ref @bb6                          -- user: %9
  switch_constr %1 ; example.Nat.z : %7 ; example.Nat.s : %8 -- id: %9

-- %10                                            -- users: %13
bb2(%10):
  %11 = function_ref @equal                       -- user: %14
  %12 = copy_value %6                             -- user: %14
  %13 = copy_value %10                            -- user: %14
  apply %11(%12 ; %13 ; %2) : ⊥                   -- id: %14

bb3:
  %15 = data_init_simple example.Bool.false       -- user: %18
  destroy_value %0                                -- id: %16
  destroy_value %1                                -- id: %17
  apply %2(%15) : TYPE                            -- id: %18

bb4:
  %19 = function_ref @bb3                         -- user: %21
  %20 = function_ref @bb4                         -- user: %21
  switch_constr %1 ; example.Nat.z : %19 ; example.Nat.s : %20 -- id: %21

bb5(%22):
  %23 = data_init_simple example.Bool.false       -- user: %26
  destroy_value %0                                -- id: %24
  destroy_value %1                                -- id: %25
  apply %2(%23) : TYPE                            -- id: %26

bb6:
  %27 = data_init_simple example.Bool.true        -- user: %30
  destroy_value %0                                -- id: %28
  destroy_value %1                                -- id: %29
  apply %2(%27) : TYPE                            -- id: %30

} -- end gir function equal

Ideally, it should look closer to this:

@equal : (example.Nat) -> (example.Nat) -> (example.Bool -> _) {
equal(%0 : example.Nat ; %1 : example.Nat ; %return : (example.Bool) -> _):
  %2 = function_ref @bb1
  %3 = function_ref @bb2
  switch_constr %0 : example.Nat ; case example.Nat.z : %2 ; case example.Nat.s : %3

bb1:
  %4 = function_ref @bb3
  %5 = function_ref @bb4
  switch_constr %1 : example.Nat ; case example.Nat.z : %4 ; case example.Nat.s : %5

bb2(%6 : example.Nat):
  %7 = function_ref @bb5
  %8 = function_ref @bb6
  switch_constr %1 : example.Nat ; case example.Nat.z : %7 ; case example.Nat.s : %8

bb3:
  %9 = data_init_simple example.Bool.true : example.Bool
  destroy_value %0 : example.Nat
  destroy_value %1 : example.Nat
  apply %return(%9) : (example.Bool) -> _

bb4(%10 : example.Nat):
  %11 = data_init_simple example.Bool.false : example.Bool
  destroy_value %0 : example.Nat
  destroy_value %1 : example.Nat
  apply %return(%11) : (example.Bool) -> _

bb5:
  %12 = data_init_simple example.Bool.false : example.Bool
  destroy_value %0 : example.Nat
  destroy_value %1 : example.Nat
  apply %return(%12) : (example.Bool) -> _

bb6(%13 : example.Nat):
  %14 = function_ref @equal
  %15 = copy_value %6 : example.Nat
  %16 = copy_value %13 : example.Nat
  apply %14(%15 ; %16 ; %return) : (example.Nat) -> (example.Nat) -> (example.Bool -> _)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant