Skip to content
Snippets Groups Projects
Commit d3d20ba7 authored by Julian Seward's avatar Julian Seward
Browse files

[project @ 2000-01-13 14:11:51 by sewardj]

Rearrange top-level nativeGen plumbing so that -ddump-stix is visible
even if subsequent nativeGen passes crash.
parent 03d7cc2a
No related merge requests found
......@@ -75,7 +75,7 @@ codeOutput mod_name c_code h_code flat_abstractC ncg_uniqs
ncg_output_d = error "*** GHC not built with a native-code generator ***"
ncg_output_w = ncg_output_d
#else
(stix_raw, stix_opt, stix_final, ncg_output_d)
(stix_final, ncg_output_d)
= nativeCodeGen flat_absC_ncg ncg_uniqs
ncg_output_w = (\ f -> printForAsm f ncg_output_d)
#endif
......
......@@ -22,7 +22,8 @@ import PrimOp ( commutableOp, PrimOp(..) )
import RegAllocInfo ( mkMRegsState, MRegsState )
import Stix ( StixTree(..), StixReg(..), pprStixTrees )
import PrimRep ( isFloatingRep )
import UniqSupply ( returnUs, thenUs, mapUs, initUs_, UniqSM, UniqSupply )
import UniqSupply ( returnUs, thenUs, mapUs, initUs,
initUs_, UniqSM, UniqSupply )
import UniqFM ( UniqFM, emptyUFM, addToUFM, lookupUFM )
import Outputable
......@@ -76,40 +77,36 @@ The machine-dependent bits break down as follows:
\end{description}
So, here we go:
\begin{code}
nativeCodeGen :: AbstractC -> UniqSupply -> (SDoc, SDoc, SDoc, SDoc)
nativeCodeGen absC us = initUs_ us (runNCG absC)
nativeCodeGen :: AbstractC -> UniqSupply -> (SDoc, SDoc)
nativeCodeGen absC us
= let (stixRaw, us1) = initUs us (genCodeAbstractC absC)
stixOpt = map (map genericOpt) stixRaw
stixFinal = map x86floatFix stixOpt
insns = initUs_ us1 (codeGen stixFinal)
debug_stix = vcat (map pprStixTrees stixFinal)
in
(debug_stix, insns)
runNCG :: AbstractC -> UniqSM (SDoc, SDoc, SDoc, SDoc)
runNCG absC
= genCodeAbstractC absC `thenUs` \ stixRaw ->
let
stixOpt = map (map genericOpt) stixRaw
#if i386_TARGET_ARCH
stixFinal = map floatFix stixOpt
x86floatFix = floatFix
#else
stixFinal = stixOpt
x86floatFix = id
#endif
in
codeGen (stixRaw, stixOpt, stixFinal)
\end{code}
@codeGen@ is the top-level code-generation function:
\begin{code}
codeGen :: ([[StixTree]],[[StixTree]],[[StixTree]])
-> UniqSM (SDoc, SDoc, SDoc, SDoc)
codeGen :: [[StixTree]] -> UniqSM SDoc
codeGen (stixRaw, stixOpt, stixFinal)
codeGen stixFinal
= mapUs genMachCode stixFinal `thenUs` \ dynamic_codes ->
let
static_instrs = scheduleMachCode dynamic_codes
in
returnUs (
text "ppr'd stixRaw",
text "ppr'd stixOpt",
vcat (map pprStixTrees stixFinal),
vcat (map pprInstr static_instrs)
)
returnUs (vcat (map pprInstr static_instrs))
\end{code}
Top level code generator for a chunk of stix code:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment