insns = initUs_ us1 (codeGen stixOpt)
debug_stix = vcat (map pprStixTrees stixOpt)
in
+ trace "--------- native code generator ---------"
(debug_stix, insns)
\end{code}
* You cannot assume anything about the destination register dst;
it may be anything, includind a fixed reg.
-* You may compute a value into a fixed reg, but you may not
+* You may compute an operand into a fixed reg, but you may not
subsequently change the contents of that fixed reg. If you
want to do so, first copy the value either to a temporary
or into dst. You are free to modify dst even if it happens
* You cannot assume that a fixed reg will stay live over an
arbitrary computation. The same applies to the dst reg.
-* Temporary regs obtained from getNewRegNCG are distinct from
- all other regs, and stay live over arbitrary computations.
+* Temporary regs obtained from getNewRegNCG are distinct from
+ each other and from all other regs, and stay live over
+ arbitrary computations.
\begin{code}
by the OS), and (2) if a signal should be handled on that stack
during argument construction, the args will get silently trashed.
+ Currently, implementation of GITOF et al use the stack, so are
+ incompatible with current ccall implementation. When the latter
+ is fixed, GITOF et al should present no problem.
+
-- nofib/real/hidden gets slightly different FP answers from the
via-C route; possibly due to exp/log not being done in-line.
= pprG g bogus
pprInstr g@(GITOF src dst)
- = pprG g bogus
+ = pprInstr (GITOD src dst)
pprInstr g@(GITOD src dst)
- = pprG g bogus
+ = pprG g (hcat [gtab, text "pushl ", pprReg L src,
+ text " ; ffree %st(7); fildl (%esp) ; ",
+ gpop dst 1, text " ; addl $4,%esp"])
pprInstr g@(GCMP sz src1 src2)
= pprG g (hcat [gtab, text "pushl %eax ; ",
-- dire straits (but still correct): see if we can bag %eax and %edx
++ if any hasFixedEAXorEDX instrs
then [] -- bummer
- else [ [ecx,edx,fake4,fake5],
- [ecx,edx,eax,fake4,fake5] ]
+ else --[ [ecx,edx,fake4,fake5],
+ -- [ecx,edx,eax,fake4,fake5] ]
+ -- pro tem, don't use %eax until we institute a check that
+ -- instrs doesn't do a CALL insn, since that effectively
+ -- uses %eax in a fixed way
+ [ [ecx,edx,fake4,fake5] ]
+
)
#endif
\end{code}
returnUs (\xs -> assign : xs)
\end{code}
+MutVars are pretty simple.
+#define writeMutVarzh(a,v) (P_)(((StgMutVar *)(a))->var)=(v)
+
+\begin{code}
+primCode [] WriteMutVarOp [aa,vv]
+ = let aa_s = amodeToStix aa
+ vv_s = amodeToStix vv
+ var_field = StIndex PtrRep aa_s fixedHS
+ assign = StAssign PtrRep (StInd PtrRep var_field) vv_s
+ in
+ returnUs (\xs -> assign : xs)
+
+primCode [rr] ReadMutVarOp [aa]
+ = let aa_s = amodeToStix aa
+ rr_s = amodeToStix rr
+ var_field = StIndex PtrRep aa_s fixedHS
+ assign = StAssign PtrRep rr_s (StInd PtrRep var_field)
+ in
+ returnUs (\xs -> assign : xs)
+\end{code}
+
Now the more mundane operations.
\begin{code}