Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
alexbiehl-gc
GHC
Commits
46048449
Commit
46048449
authored
24 years ago
by
Simon Marlow
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 2000-05-15 11:39:32 by simonmar]
The NCG should now support _ccall_GC (i.e. foreign import safe).
parent
5442794a
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/compiler/nativeGen/StixPrim.lhs
+22
-12
22 additions, 12 deletions
ghc/compiler/nativeGen/StixPrim.lhs
with
22 additions
and
12 deletions
ghc/compiler/nativeGen/StixPrim.lhs
+
22
−
12
View file @
46048449
...
...
@@ -20,7 +20,7 @@ import Literal ( Literal(..), word2IntLit )
import CallConv ( cCallConv )
import PrimOp ( PrimOp(..), CCall(..), CCallTarget(..) )
import PrimRep ( PrimRep(..), isFloatingRep )
import UniqSupply ( returnUs, thenUs, UniqSM )
import UniqSupply ( returnUs, thenUs,
getUniqueUs,
UniqSM )
import Constants ( mIN_INTLIKE )
import Outputable
...
...
@@ -235,20 +235,22 @@ primCode [] WriteForeignObjOp [obj, v]
returnUs (\xs -> assign : xs)
\end{code}
ToDo: saving/restoring of volatile regs around ccalls.
\begin{code}
--primCode lhs (CCallOp fn is_asm may_gc) rhs
primCode lhs (CCallOp (CCall (StaticTarget fn) is_asm may_gc cconv)) rhs
| is_asm = error "ERROR: Native code generator can't handle casm"
| may_gc = error "ERROR: Native code generator can't handle _ccall_GC_\n"
| otherwise
= case lhs of
[] -> returnUs (\xs -> (StCall fn cconv VoidRep args) : xs)
[lhs] ->
let lhs' = amodeToStix lhs
pk = if isFloatingRep (getAmodeRep lhs) then DoubleRep else IntRep
call = StAssign pk lhs' (StCall fn cconv pk args)
in
returnUs (\xs -> call : xs)
| not may_gc = returnUs (\xs -> ccall : xs)
| otherwise =
getUniqueUs `thenUs` \ uniq ->
let
id = StReg (StixTemp uniq IntRep)
suspend = StAssign IntRep id
(StCall SLIT("suspendThread") cconv IntRep [stgBaseReg])
resume = StCall SLIT("resumeThread") cconv VoidRep [id]
in
returnUs (\xs -> suspend : ccall : resume : xs)
where
args = map amodeCodeForCCall rhs
amodeCodeForCCall x =
...
...
@@ -259,6 +261,14 @@ primCode lhs (CCallOp (CCall (StaticTarget fn) is_asm may_gc cconv)) rhs
ByteArrayRep -> StIndex IntRep base arrWordsHS
ForeignObjRep -> StIndex PtrRep base fixedHS
_ -> base
ccall = case lhs of
[] -> StCall fn cconv VoidRep args
[lhs] ->
let lhs' = amodeToStix lhs
pk = if isFloatingRep (getAmodeRep lhs) then DoubleRep else IntRep
in
StAssign pk lhs' (StCall fn cconv pk args)
\end{code}
DataToTagOp won't work for 64-bit archs, as it is.
...
...
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