Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
test-primops
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
test-primops
Commits
1e783e15
Commit
1e783e15
authored
3 years ago
by
Ben Gamari
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
d746f1b3
Branches
float
No related tags found
No related merge requests found
Pipeline
#46399
failed
3 years ago
Stage: test
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/CCall.hs
+1
-0
1 addition, 0 deletions
src/CCall.hs
src/Expr.hs
+10
-2
10 additions, 2 deletions
src/Expr.hs
src/Expr.hs-boot
+5
-1
5 additions, 1 deletion
src/Expr.hs-boot
src/RefInterpreter.hs
+13
-0
13 additions, 0 deletions
src/RefInterpreter.hs
test-primops.cabal
+1
-0
1 addition, 0 deletions
test-primops.cabal
with
30 additions
and
3 deletions
src/CCall.hs
+
1
−
0
View file @
1e783e15
...
@@ -39,6 +39,7 @@ testCCall
...
@@ -39,6 +39,7 @@ testCCall
->
CCallDesc
->
CCallDesc
->
Property
->
Property
testCCall
comp
c
=
testCCall
comp
c
=
counterexample
(
cStub
c
)
$
counterexample
(
cCallCmm
c
)
$
ioProperty
$
withTempDirectory
"."
"tmp"
$
\
tmpDir
->
do
ioProperty
$
withTempDirectory
"."
"tmp"
$
\
tmpDir
->
do
writeFile
(
tmpDir
</>
"test_c.c"
)
(
cStub
c
)
writeFile
(
tmpDir
</>
"test_c.c"
)
(
cStub
c
)
writeFile
(
tmpDir
</>
"test.cmm"
)
(
cCallCmm
c
)
writeFile
(
tmpDir
</>
"test.cmm"
)
(
cCallCmm
c
)
...
...
This diff is collapsed.
Click to expand it.
src/Expr.hs
+
10
−
2
View file @
1e783e15
...
@@ -17,8 +17,6 @@ module Expr
...
@@ -17,8 +17,6 @@ module Expr
,
genExpr
,
genExpr
)
where
)
where
import
Data.Foldable
(
foldl'
)
import
qualified
Data.ByteString
as
BS
import
Numeric.Natural
import
Numeric.Natural
import
Control.Monad
import
Control.Monad
import
Data.Bits
as
Bits
import
Data.Bits
as
Bits
...
@@ -29,6 +27,7 @@ import Data.Proxy
...
@@ -29,6 +27,7 @@ import Data.Proxy
import
Prelude
hiding
(
truncate
)
import
Prelude
hiding
(
truncate
)
import
{-#
SOURCE
#-
}
RefInterpreter
import
{-#
SOURCE
#-
}
RefInterpreter
import
{-#
SOURCE
#-
}
FExpr
import
Width
import
Width
import
Number
import
Number
...
@@ -100,6 +99,10 @@ data Expr (width :: Width) where
...
@@ -100,6 +99,10 @@ data Expr (width :: Width) where
EZeroExt
::
forall
narrow
wide
.
(
KnownWidth
narrow
,
wide
`
WiderThan
`
narrow
)
EZeroExt
::
forall
narrow
wide
.
(
KnownWidth
narrow
,
wide
`
WiderThan
`
narrow
)
=>
Expr
narrow
->
Expr
wide
=>
Expr
narrow
->
Expr
wide
-- | Floating-point to signed integer conversion
EFSConv
::
FExpr
width
->
Expr
width
EFRel
::
FRelationalOp
->
FExpr
width
->
FExpr
width
->
Expr
WordSize
ELoad
::
Expr
WordSize
->
Expr
width
ELoad
::
Expr
WordSize
->
Expr
width
ELit
::
Number
width
->
Expr
width
ELit
::
Number
width
->
Expr
width
...
@@ -165,6 +168,8 @@ instance KnownWidth width => Arbitrary (Expr width) where
...
@@ -165,6 +168,8 @@ instance KnownWidth width => Arbitrary (Expr width) where
++
[
EZeroExt
a
]
++
[
EZeroExt
a
]
EZeroExt
a
->
shrinkUnOp
EZeroExt
a
EZeroExt
a
->
shrinkUnOp
EZeroExt
a
++
[
EZeroExt
b
|
EZeroExt
b
<-
pure
a
,
Wider
<-
pure
$
e
`
compareWidths
`
b
]
++
[
EZeroExt
b
|
EZeroExt
b
<-
pure
a
,
Wider
<-
pure
$
e
`
compareWidths
`
b
]
EFSConv
a
->
EFSConv
<$>
shrink
a
EFRel
op
a
b
->
EFRel
op
<$>
shrink
a
<*>
shrink
b
ELoad
a
->
shrinkUnOp
ELoad
a
ELoad
a
->
shrinkUnOp
ELoad
a
ELit
a
->
map
ELit
(
shrink
a
)
ELit
a
->
map
ELit
(
shrink
a
)
where
where
...
@@ -195,6 +200,7 @@ genExpr' _width = sized gen
...
@@ -195,6 +200,7 @@ genExpr' _width = sized gen
oneof
$
oneof
$
[
litGen
[
litGen
,
loadGen
,
loadGen
,
EFSConv
<$>
arbitrary
]
]
++
arithmeticGens
++
arithmeticGens
++
bitwiseGens
++
bitwiseGens
...
@@ -257,6 +263,8 @@ genExpr' _width = sized gen
...
@@ -257,6 +263,8 @@ genExpr' _width = sized gen
|
SameWidth
<-
Proxy
@
width
`
compareWidths
`
Proxy
@
WordSize
|
SameWidth
<-
Proxy
@
width
`
compareWidths
`
Proxy
@
WordSize
=
[
do
op
<-
arbitrary
=
[
do
op
<-
arbitrary
binOp
(
ERel
op
)
binOp
(
ERel
op
)
,
EFRel
@
W32
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
,
EFRel
@
W64
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
]
]
|
otherwise
=
[]
|
otherwise
=
[]
...
...
This diff is collapsed.
Click to expand it.
src/Expr.hs-boot
+
5
−
1
View file @
1e783e15
...
@@ -2,8 +2,12 @@
...
@@ -2,8 +2,12 @@
module
Expr
where
module
Expr
where
import
Width
(
Width
)
import
Test.QuickCheck
import
Width
(
Width
,
KnownWidth
)
data
Expr
(
width
::
Width
)
data
Expr
(
width
::
Width
)
type
role
Expr
nominal
type
role
Expr
nominal
instance
(
KnownWidth
width
)
=>
Arbitrary
(
Expr
width
)
This diff is collapsed.
Click to expand it.
src/RefInterpreter.hs
+
13
−
0
View file @
1e783e15
...
@@ -3,6 +3,7 @@ module RefInterpreter
...
@@ -3,6 +3,7 @@ module RefInterpreter
,
memoryContents
,
memoryContents
,
memoryOracle
,
memoryOracle
,
interpret
,
interpret
,
interpretFloat
)
where
)
where
import
Data.Bits
import
Data.Bits
...
@@ -12,6 +13,7 @@ import Numeric.Natural
...
@@ -12,6 +13,7 @@ import Numeric.Natural
import
Width
import
Width
import
Expr
import
Expr
import
FExpr
import
Number
import
Number
boolVal
::
Bool
->
Number
WordSize
boolVal
::
Bool
->
Number
WordSize
...
@@ -64,6 +66,17 @@ interpret (EZeroExt a) = zeroExtNumber (interpret a)
...
@@ -64,6 +66,17 @@ interpret (EZeroExt a) = zeroExtNumber (interpret a)
interpret
(
ELoad
off
)
=
memoryOracle
$
toUnsigned
$
interpret
off
interpret
(
ELoad
off
)
=
memoryOracle
$
toUnsigned
$
interpret
off
interpret
(
ELit
n
)
=
n
interpret
(
ELit
n
)
=
n
interpretFloat
::
forall
width
.
(
KnownWidth
width
)
=>
FExpr
width
->
FloatType
width
interpretFloat
(
FEAdd
a
b
)
=
interpretFloat
a
+
interpretFloat
b
interpretFloat
(
FESub
a
b
)
=
interpretFloat
a
-
interpretFloat
b
interpretFloat
(
FEMul
a
b
)
=
interpretFloat
a
-
interpretFloat
b
interpretFloat
(
FEQuot
a
b
)
=
interpretFloat
a
`
quot
`
interpretFloat
b
interpretFloat
(
FENegate
a
)
=
negate
(
interpretFloat
a
)
interpretFloat
(
FFromSInt
a
)
=
realToFrac
$
toSigned
$
interpret
a
interpretFloat
(
FConv
a
)
=
realToFrac
(
interpretFloat
a
)
memorySize
::
Natural
memorySize
::
Natural
memorySize
=
1
`
shiftL
`
22
memorySize
=
1
`
shiftL
`
22
...
...
This diff is collapsed.
Click to expand it.
test-primops.cabal
+
1
−
0
View file @
1e783e15
...
@@ -14,6 +14,7 @@ executable test-primops
...
@@ -14,6 +14,7 @@ executable test-primops
other-modules: Width,
other-modules: Width,
Number,
Number,
Expr,
Expr,
FExpr,
Expr.Parse,
Expr.Parse,
Interpreter,
Interpreter,
ToCmm,
ToCmm,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment