Skip to content

Commit

Permalink
Add Int comparison primitives in GHC.Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex McKenna authored and alex-mckenna committed Feb 5, 2021
1 parent 833ac34 commit 70718d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/2021-02-05T14_43_53+01_00_added_ltprim_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGED: Added a rule for missing Int comparisons in GHC.Classes in the compile time evaluator. [#1648](https://github.com/clash-lang/clash-compiler/issues/1648)
14 changes: 14 additions & 0 deletions clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,24 @@ ghcPrimStep tcm isSubj pInfo tys args mach = case primName pInfo of
}
in (\e -> setTerm (Data e) mach) <$> dc

"GHC.Classes.eqInt" | Just (i,j) <- intCLiterals args
-> reduce (boolToBoolLiteral tcm ty (i == j))

"GHC.Classes.neInt" | Just (i,j) <- intCLiterals args
-> reduce (boolToBoolLiteral tcm ty (i /= j))

"GHC.Classes.leInt" | Just (i,j) <- intCLiterals args
-> reduce (boolToBoolLiteral tcm ty (i <= j))

"GHC.Classes.ltInt" | Just (i,j) <- intCLiterals args
-> reduce (boolToBoolLiteral tcm ty (i < j))

"GHC.Classes.geInt" | Just (i,j) <- intCLiterals args
-> reduce (boolToBoolLiteral tcm ty (i >= j))

"GHC.Classes.gtInt" | Just (i,j) <- intCLiterals args
-> reduce (boolToBoolLiteral tcm ty (i > j))

"GHC.Classes.&&"
| [ lArg , rArg ] <- args
, eval <- Evaluator ghcStep ghcUnwind ghcPrimStep ghcPrimUnwind
Expand Down

0 comments on commit 70718d0

Please sign in to comment.