@@ -120,7 +120,7 @@ def opLayout : Bytecode.Op → LayoutM Unit
120120 pushDegrees $ .replicate 8 1
121121 bumpAuxiliaries 8
122122 bumpLookups
123- | .u8ShiftLeft _ | .u8ShiftRight _ | .u8Xor .. => do
123+ | .u8ShiftLeft _ | .u8ShiftRight _ | .u8Xor .. | .u8And .. | .u8Or .. => do
124124 pushDegree 1
125125 bumpAuxiliaries 1
126126 bumpLookups
@@ -246,7 +246,7 @@ partial def toIndex
246246 (term : TypedTerm) : StateM CompilerState (Array Bytecode.ValIdx) :=
247247 match term.inner with
248248 -- | .unsafeCast inner castTyp =>
249- -- if typSize layoutMap castTyp != typSize layoutMap term.typ.unwrap then
249+ -- if typSize layoutMap castTyp != typSize layoutMap term.typ then
250250 -- panic! "Impossible cast"
251251 -- else
252252 -- toIndex layoutMap bindings (.mk term.typ inner)
@@ -335,32 +335,32 @@ partial def toIndex
335335 -- pushOp (Bytecode.Op.preimg layout.index out layout.inputSize) layout.inputSize
336336 -- | _ => panic! "should not happen after typechecking"
337337 | .proj arg i => do
338- let typs := match arg.typ with
339- | .evaluates (.tuple typs) => typs
338+ let typs := match ( arg.typ, arg.escapes) with
339+ | (.tuple typs, false ) => typs
340340 | _ => panic! "Should not happen after typechecking"
341341 let offset := (typs.extract 0 i).foldl (init := 0 )
342342 fun acc typ => typSize layoutMap typ + acc
343343 let arg ← toIndex layoutMap bindings arg
344344 let length := typSize layoutMap typs[i]!
345345 pure $ arg.extract offset (offset + length)
346346 | .get arr i => do
347- let eltTyp := match arr.typ with
348- | .evaluates (.array typ _) => typ
347+ let eltTyp := match ( arr.typ, arr.escapes) with
348+ | (.array typ _, false ) => typ
349349 | _ => panic! "Should not happen after typechecking"
350350 let eltSize := typSize layoutMap eltTyp
351351 let offset := i * eltSize
352352 let arr ← toIndex layoutMap bindings arr
353353 pure $ arr.extract offset (offset + eltSize)
354354 | .slice arr i j => do
355- let eltTyp := match arr.typ with
356- | .evaluates (.array typ _) => typ
355+ let eltTyp := match ( arr.typ, arr.escapes) with
356+ | (.array typ _, false ) => typ
357357 | _ => panic! "Should not happen after typechecking"
358358 let eltSize := typSize layoutMap eltTyp
359359 let arr ← toIndex layoutMap bindings arr
360360 pure $ arr.extract (i * eltSize) (j * eltSize)
361361 | .set arr i val => do
362- let eltTyp := match arr.typ with
363- | .evaluates (.array typ _) => typ
362+ let eltTyp := match ( arr.typ, arr.escapes) with
363+ | (.array typ _, false ) => typ
364364 | _ => panic! "Should not happen after typechecking"
365365 let eltSize := typSize layoutMap eltTyp
366366 let arr ← toIndex layoutMap bindings arr
@@ -372,8 +372,8 @@ partial def toIndex
372372 let args ← toIndex layoutMap bindings arg
373373 pushOp (.store args)
374374 | .load ptr => do
375- let size := match ptr.typ.unwrap with
376- | .pointer typ => typSize layoutMap typ
375+ let size := match ( ptr.typ, ptr.escapes) with
376+ | ( .pointer typ, false ) => typSize layoutMap typ
377377 | _ => unreachable!
378378 let ptr ← expectIdx ptr
379379 pushOp (.load size ptr) size
@@ -421,6 +421,14 @@ partial def toIndex
421421 let i ← expectIdx i
422422 let j ← expectIdx j
423423 pushOp (.u8Add i j) 2
424+ | .u8And i j => do
425+ let i ← expectIdx i
426+ let j ← expectIdx j
427+ pushOp (.u8And i j)
428+ | .u8Or i j => do
429+ let i ← expectIdx i
430+ let j ← expectIdx j
431+ pushOp (.u8Or i j)
424432 | .debug label term ret => do
425433 let term ← term.mapM (toIndex layoutMap bindings)
426434 modify fun stt => { stt with ops := stt.ops.push (.debug label term) }
@@ -454,7 +462,7 @@ partial def TypedTerm.compile
454462 modify fun stt => { stt with ops := stt.ops.push (.debug label term) }
455463 ret.compile returnTyp layoutMap bindings
456464 | .match term cases =>
457- match term.typ.unwrapOr returnTyp with
465+ match term.typ with
458466 -- Also do this for tuple-like and array-like (one constructor only) datatypes
459467 | .tuple typs => match cases with
460468 | [(.tuple vars, branch)] => do
0 commit comments