From: sewardj Date: Thu, 3 Feb 2000 18:01:03 +0000 (+0000) Subject: [project @ 2000-02-03 18:01:03 by sewardj] X-Git-Tag: Approximately_9120_patches~5158 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=1aa0765b34932e36e85625fe6fa1b21255139ffb;p=ghc-hetmet.git [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. --- diff --git a/ghc/compiler/nativeGen/AsmCodeGen.lhs b/ghc/compiler/nativeGen/AsmCodeGen.lhs index fe2fcbf..e3a16c3 100644 --- a/ghc/compiler/nativeGen/AsmCodeGen.lhs +++ b/ghc/compiler/nativeGen/AsmCodeGen.lhs @@ -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} diff --git a/ghc/compiler/nativeGen/MachCode.lhs b/ghc/compiler/nativeGen/MachCode.lhs index fb88fc6..820b5ae 100644 --- a/ghc/compiler/nativeGen/MachCode.lhs +++ b/ghc/compiler/nativeGen/MachCode.lhs @@ -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} diff --git a/ghc/compiler/nativeGen/NOTES b/ghc/compiler/nativeGen/NOTES index 9927b6e..5f76d69 100644 --- a/ghc/compiler/nativeGen/NOTES +++ b/ghc/compiler/nativeGen/NOTES @@ -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. diff --git a/ghc/compiler/nativeGen/PprMach.lhs b/ghc/compiler/nativeGen/PprMach.lhs index 23f81a9..a3fe5de 100644 --- a/ghc/compiler/nativeGen/PprMach.lhs +++ b/ghc/compiler/nativeGen/PprMach.lhs @@ -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 ; ", diff --git a/ghc/compiler/nativeGen/RegAllocInfo.lhs b/ghc/compiler/nativeGen/RegAllocInfo.lhs index 53d651e..23aef3b 100644 --- a/ghc/compiler/nativeGen/RegAllocInfo.lhs +++ b/ghc/compiler/nativeGen/RegAllocInfo.lhs @@ -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} diff --git a/ghc/compiler/nativeGen/StixPrim.lhs b/ghc/compiler/nativeGen/StixPrim.lhs index 2d86439..353bd33 100644 --- a/ghc/compiler/nativeGen/StixPrim.lhs +++ b/ghc/compiler/nativeGen/StixPrim.lhs @@ -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}