3f38a361d58cce4ac66e3d838a594d60c65ff798
[ghc-hetmet.git] / compiler / nativeGen / Instrs.hs
1 {-# OPTIONS -w #-}
2 -- The above warning supression flag is a temporary kludge.
3 -- While working on this module you are encouraged to remove it and fix
4 -- any warnings in the module. See
5 --     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
6 -- for details
7
8 -----------------------------------------------------------------------------
9 --
10 -- Machine-dependent assembly language
11 --
12 -- (c) The University of Glasgow 1993-2004
13 --
14 -----------------------------------------------------------------------------
15
16 #include "nativeGen/NCG.h"
17
18
19 module Instrs (
20         NatCmm,
21         NatCmmTop,
22         NatBasicBlock,
23         condUnsigned,
24         condToSigned,
25         condToUnsigned,
26
27 #if   alpha_TARGET_ARCH
28         module Alpha.Instr
29 #elif powerpc_TARGET_ARCH
30         module PPC.Instr
31 #elif i386_TARGET_ARCH || x86_64_TARGET_ARCH
32         module X86.Instr
33 #elif sparc_TARGET_ARCH
34         module SPARC.Instr
35 #else
36 #error "Instrs: not defined for this architecture"
37 #endif
38 )
39
40 where
41
42 #include "HsVersions.h"
43
44 import BlockId
45 import Regs
46 import Cmm
47 import CLabel           ( CLabel, pprCLabel )
48 import Panic            ( panic )
49 import Outputable
50 import FastString
51 import Constants       ( wORD_SIZE )
52
53 import GHC.Exts
54
55 #if   alpha_TARGET_ARCH
56 import Alpha.Instr
57 #elif powerpc_TARGET_ARCH
58 import PPC.Instr
59 #elif i386_TARGET_ARCH || x86_64_TARGET_ARCH
60 import X86.Instr
61 #elif sparc_TARGET_ARCH
62 import SPARC.Instr
63 #else
64 #error "Instrs: not defined for this architecture"
65 #endif
66
67
68 -- Our flavours of the Cmm types
69 -- Type synonyms for Cmm populated with native code
70
71 type NatCmm        = GenCmm CmmStatic [CmmStatic] (ListGraph Instr)
72 type NatCmmTop     = GenCmmTop CmmStatic [CmmStatic] (ListGraph Instr)
73 type NatBasicBlock = GenBasicBlock Instr
74
75
76 -- Condition utils
77 condUnsigned GU  = True
78 condUnsigned LU  = True
79 condUnsigned GEU = True
80 condUnsigned LEU = True
81 condUnsigned _   = False
82
83 condToSigned GU  = GTT
84 condToSigned LU  = LTT
85 condToSigned GEU = GE
86 condToSigned LEU = LE
87 condToSigned x   = x
88
89 condToUnsigned GTT = GU
90 condToUnsigned LTT = LU
91 condToUnsigned GE  = GEU
92 condToUnsigned LE  = LEU
93 condToUnsigned x   = x
94
95
96
97