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
c246641d
Commit
c246641d
authored
1 year ago
by
Ben Gamari
Browse files
Options
Downloads
Patches
Plain Diff
Enable testing of Word64#, et al on 32-bit platforms
parent
e91bc499
No related branches found
No related tags found
1 merge request
!10
Enable testing of Word64# on 32-bit platforms
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
run-it/Run.hs
+3
-2
3 additions, 2 deletions
run-it/Run.hs
src/RunGhc.hs
+5
-10
5 additions, 10 deletions
src/RunGhc.hs
src/Width.hs
+0
-2
0 additions, 2 deletions
src/Width.hs
with
8 additions
and
14 deletions
run-it/Run.hs
+
3
−
2
View file @
c246641d
...
...
@@ -6,11 +6,12 @@ module Main where
import
GHC.Exts
import
GHC.Ptr
import
GHC.Word
import
System.Posix
(
RTLDFlags
(
..
),
dlopen
,
dlsym
,
dlclose
)
import
System.Environment
import
System.IO.MMap
foreign
import
prim
"stg_trampoline"
trampoline
::
Addr
#
->
Addr
#
->
Word
#
foreign
import
prim
"stg_trampoline"
trampoline
::
Addr
#
->
Addr
#
->
Word
64
#
main
::
IO
()
main
=
do
...
...
@@ -18,5 +19,5 @@ main = do
(
Ptr
p
,
_
,
_
,
_
)
<-
mmapFilePtr
"test"
ReadOnly
Nothing
dl
<-
dlopen
so
[
RTLD_NOW
]
Ptr
entry
<-
castFunPtrToPtr
<$>
dlsym
dl
"test"
print
$
W
#
(
trampoline
entry
p
)
print
$
W
64
#
(
trampoline
entry
p
)
dlclose
dl
This diff is collapsed.
Click to expand it.
src/RunGhc.hs
+
5
−
10
View file @
c246641d
...
...
@@ -82,7 +82,7 @@ mkStaticWrapper comp width = do
,
"{-# LANGUAGE UnliftedFFITypes #-}"
,
"{-# LANGUAGE MagicHash #-}"
,
"module Main where"
,
"import
Data
.Word"
,
"import
GHC
.Word"
,
"import GHC.Exts"
,
"import GHC.Ptr (Ptr(Ptr))"
,
"import qualified Data.ByteString as BS"
...
...
@@ -91,22 +91,17 @@ mkStaticWrapper comp width = do
,
"main :: IO ()"
,
"main = do"
,
" buf <- BS.readFile
\"
test
\"
"
,
" BS.unsafeUseAsCString buf $
\\
(Ptr p) -> print $ "
<>
toHsWord
width
"test p"
,
" BS.unsafeUseAsCString buf $
\\
(Ptr p) -> print $ "
<>
toHsWord
64
width
"test p"
]
hsType
::
Width
->
String
hsType
W8
=
"Word8#"
hsType
W16
=
"Word16#"
#
if
defined
(
WORD_SIZE_32BIT
)
hsType
W32
=
"Word32#"
hsType
W64
=
"Word64#"
#
else
hsType
W32
=
"Word32#"
hsType
W64
=
"Word#"
#
endif
toHsWord
::
Width
->
String
->
String
toHsWord
w
x
=
"W# "
<>
parens
(
extendFn
<>
" "
<>
parens
x
)
toHsWord
64
::
Width
->
String
->
String
toHsWord
64
w
x
=
"W
64
# "
<>
parens
(
extendFn
<>
" "
<>
parens
x
)
where
extendFn
|
w
==
W64
=
""
...
...
@@ -119,7 +114,7 @@ evalCmm em cmm = do
return
$
read
out
-- | Evaluate an 'Expr'.
evalExpr
::
EvalMethod
->
Expr
W
ordSize
->
IO
Natural
evalExpr
::
EvalMethod
->
Expr
W
64
->
IO
Natural
evalExpr
em
=
evalCmm
em
.
toCmmDecl
"test"
type
Cmm
=
String
...
...
This diff is collapsed.
Click to expand it.
src/Width.hs
+
0
−
2
View file @
c246641d
...
...
@@ -103,9 +103,7 @@ allWidths =
[
SomeWidth
(
Proxy
@
W8
)
,
SomeWidth
(
Proxy
@
W16
)
,
SomeWidth
(
Proxy
@
W32
)
#
if
WORD_SIZE_IN_BITS
==
64
,
SomeWidth
(
Proxy
@
W64
)
#
endif
]
forAllWidths
::
(
forall
w
.
(
KnownWidth
w
)
=>
Proxy
w
->
r
)
->
[
r
]
...
...
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