Commit 1aa0765b authored by sewardj's avatar sewardj
Browse files

[project @ 2000-02-03 18:01:03 by sewardj]

Fix x86 NCG so the compiler can compile itself `-O':

-- Implement fake x86 insn GITOD/GITOF.
-- Implement primops ReadMutVarOp and WriteMutVarOp.
-- Pro tem, disable use of %eax as a spill temp.
-- Clarify wording of Rules of the Game comment in MachCode.
parent 10aa06e4
......@@ -89,6 +89,7 @@ nativeCodeGen absC us
insns = initUs_ us1 (codeGen stixOpt)
debug_stix = vcat (map pprStixTrees stixOpt)
in
trace "--------- native code generator ---------"
(debug_stix, insns)
\end{code}
......
......@@ -2743,7 +2743,7 @@ The Rules of the Game are:
* 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
......@@ -2752,8 +2752,9 @@ The Rules of the Game are:
* 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}
......
......@@ -26,6 +26,10 @@ All these bugs are for x86; I don't know about sparc/alpha.
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.
......
......@@ -1003,9 +1003,11 @@ pprInstr g@(GDTOI src dst)
= 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 ; ",
......
......@@ -581,8 +581,13 @@ findReservedRegs instrs
-- 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}
......
......@@ -256,6 +256,27 @@ primCode [lhs] DataToTagOp [arg]
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}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment