{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module GHC.CmmToAsm.SPARC.Ppr (
pprNatCmmDecl,
pprBasicBlock,
pprData,
pprInstr,
pprFormat,
pprImm,
pprDataItem
)
where
import GHC.Prelude
import Data.Word
import qualified Data.Array.Unsafe as U ( castSTUArray )
import Data.Array.ST
import Control.Monad.ST
import GHC.CmmToAsm.SPARC.Regs
import GHC.CmmToAsm.SPARC.Instr
import GHC.CmmToAsm.SPARC.Cond
import GHC.CmmToAsm.SPARC.Imm
import GHC.CmmToAsm.SPARC.AddrMode
import GHC.CmmToAsm.SPARC.Base
import GHC.Platform.Reg
import GHC.CmmToAsm.Format
import GHC.CmmToAsm.Ppr
import GHC.CmmToAsm.Config
import GHC.CmmToAsm.Types
import GHC.CmmToAsm.Utils
import GHC.Cmm hiding (topInfoTable)
import GHC.Cmm.Ppr()
import GHC.Cmm.BlockId
import GHC.Cmm.CLabel
import GHC.Cmm.Dataflow.Label
import GHC.Cmm.Dataflow.Collections
import GHC.Types.Unique ( pprUniqueAlways )
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Platform
import GHC.Data.FastString
pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc
pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc
pprNatCmmDecl NCGConfig
config (CmmData Section
section RawCmmStatics
dats) =
NCGConfig -> Section -> SDoc
pprSectionAlign NCGConfig
config Section
section
SDoc -> SDoc -> SDoc
$$ Platform -> RawCmmStatics -> SDoc
pprDatas (NCGConfig -> Platform
ncgPlatform NCGConfig
config) RawCmmStatics
dats
pprNatCmmDecl NCGConfig
config proc :: NatCmmDecl RawCmmStatics Instr
proc@(CmmProc LabelMap RawCmmStatics
top_info CLabel
lbl [GlobalReg]
_ (ListGraph [GenBasicBlock Instr]
blocks)) =
let platform :: Platform
platform = NCGConfig -> Platform
ncgPlatform NCGConfig
config in
case NatCmmDecl RawCmmStatics Instr -> Maybe RawCmmStatics
forall a i b. GenCmmDecl a (LabelMap i) (ListGraph b) -> Maybe i
topInfoTable NatCmmDecl RawCmmStatics Instr
proc of
Maybe RawCmmStatics
Nothing ->
NCGConfig -> Section -> SDoc
pprSectionAlign NCGConfig
config (SectionType -> CLabel -> Section
Section SectionType
Text CLabel
lbl) SDoc -> SDoc -> SDoc
$$
Platform -> CLabel -> SDoc
pprLabel Platform
platform CLabel
lbl SDoc -> SDoc -> SDoc
$$
[SDoc] -> SDoc
vcat ((GenBasicBlock Instr -> SDoc) -> [GenBasicBlock Instr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> LabelMap RawCmmStatics -> GenBasicBlock Instr -> SDoc
pprBasicBlock Platform
platform LabelMap RawCmmStatics
top_info) [GenBasicBlock Instr]
blocks)
Just (CmmStaticsRaw CLabel
info_lbl [CmmStatic]
_) ->
(if Platform -> Bool
platformHasSubsectionsViaSymbols Platform
platform
then NCGConfig -> Section -> SDoc
pprSectionAlign NCGConfig
config Section
dspSection SDoc -> SDoc -> SDoc
$$
Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform (CLabel -> CLabel
mkDeadStripPreventer CLabel
info_lbl) SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
':'
else SDoc
empty) SDoc -> SDoc -> SDoc
$$
[SDoc] -> SDoc
vcat ((GenBasicBlock Instr -> SDoc) -> [GenBasicBlock Instr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> LabelMap RawCmmStatics -> GenBasicBlock Instr -> SDoc
pprBasicBlock Platform
platform LabelMap RawCmmStatics
top_info) [GenBasicBlock Instr]
blocks) SDoc -> SDoc -> SDoc
$$
(if Platform -> Bool
platformHasSubsectionsViaSymbols Platform
platform
then
String -> SDoc
text String
"\t.long "
SDoc -> SDoc -> SDoc
<+> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
info_lbl
SDoc -> SDoc -> SDoc
<+> Char -> SDoc
char Char
'-'
SDoc -> SDoc -> SDoc
<+> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform (CLabel -> CLabel
mkDeadStripPreventer CLabel
info_lbl)
else SDoc
empty)
dspSection :: Section
dspSection :: Section
dspSection = SectionType -> CLabel -> Section
Section SectionType
Text (CLabel -> Section) -> CLabel -> Section
forall a b. (a -> b) -> a -> b
$
String -> CLabel
forall a. String -> a
panic String
"subsections-via-symbols doesn't combine with split-sections"
pprBasicBlock :: Platform -> LabelMap RawCmmStatics -> NatBasicBlock Instr -> SDoc
pprBasicBlock :: Platform -> LabelMap RawCmmStatics -> GenBasicBlock Instr -> SDoc
pprBasicBlock Platform
platform LabelMap RawCmmStatics
info_env (BasicBlock BlockId
blockid [Instr]
instrs)
= SDoc
maybe_infotable SDoc -> SDoc -> SDoc
$$
Platform -> CLabel -> SDoc
pprLabel Platform
platform (BlockId -> CLabel
blockLbl BlockId
blockid) SDoc -> SDoc -> SDoc
$$
[SDoc] -> SDoc
vcat ((Instr -> SDoc) -> [Instr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> Instr -> SDoc
pprInstr Platform
platform) [Instr]
instrs)
where
maybe_infotable :: SDoc
maybe_infotable = case KeyOf LabelMap -> LabelMap RawCmmStatics -> Maybe RawCmmStatics
forall (map :: * -> *) a.
IsMap map =>
KeyOf map -> map a -> Maybe a
mapLookup BlockId
KeyOf LabelMap
blockid LabelMap RawCmmStatics
info_env of
Maybe RawCmmStatics
Nothing -> SDoc
empty
Just (CmmStaticsRaw CLabel
info_lbl [CmmStatic]
info) ->
SectionType -> SDoc
pprAlignForSection SectionType
Text SDoc -> SDoc -> SDoc
$$
[SDoc] -> SDoc
vcat ((CmmStatic -> SDoc) -> [CmmStatic] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> CmmStatic -> SDoc
pprData Platform
platform) [CmmStatic]
info) SDoc -> SDoc -> SDoc
$$
Platform -> CLabel -> SDoc
pprLabel Platform
platform CLabel
info_lbl
pprDatas :: Platform -> RawCmmStatics -> SDoc
pprDatas :: Platform -> RawCmmStatics -> SDoc
pprDatas Platform
platform (CmmStaticsRaw CLabel
alias [CmmStaticLit (CmmLabel CLabel
lbl), CmmStaticLit CmmLit
ind, CmmStatic
_, CmmStatic
_])
| CLabel
lbl CLabel -> CLabel -> Bool
forall a. Eq a => a -> a -> Bool
== CLabel
mkIndStaticInfoLabel
, let labelInd :: CmmLit -> Maybe CLabel
labelInd (CmmLabelOff CLabel
l Int
_) = CLabel -> Maybe CLabel
forall a. a -> Maybe a
Just CLabel
l
labelInd (CmmLabel CLabel
l) = CLabel -> Maybe CLabel
forall a. a -> Maybe a
Just CLabel
l
labelInd CmmLit
_ = Maybe CLabel
forall a. Maybe a
Nothing
, Just CLabel
ind' <- CmmLit -> Maybe CLabel
labelInd CmmLit
ind
, CLabel
alias CLabel -> CLabel -> Bool
`mayRedirectTo` CLabel
ind'
= Platform -> CLabel -> SDoc
pprGloblDecl Platform
platform CLabel
alias
SDoc -> SDoc -> SDoc
$$ String -> SDoc
text String
".equiv" SDoc -> SDoc -> SDoc
<+> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
alias SDoc -> SDoc -> SDoc
<> SDoc
comma SDoc -> SDoc -> SDoc
<> Platform -> CmmLit -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform (CLabel -> CmmLit
CmmLabel CLabel
ind')
pprDatas Platform
platform (CmmStaticsRaw CLabel
lbl [CmmStatic]
dats) = [SDoc] -> SDoc
vcat (Platform -> CLabel -> SDoc
pprLabel Platform
platform CLabel
lbl SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: (CmmStatic -> SDoc) -> [CmmStatic] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> CmmStatic -> SDoc
pprData Platform
platform) [CmmStatic]
dats)
pprData :: Platform -> CmmStatic -> SDoc
pprData :: Platform -> CmmStatic -> SDoc
pprData Platform
platform CmmStatic
d = case CmmStatic
d of
CmmString ByteString
str -> ByteString -> SDoc
pprString ByteString
str
CmmFileEmbed String
path -> String -> SDoc
pprFileEmbed String
path
CmmUninitialised Int
bytes -> String -> SDoc
text String
".skip " SDoc -> SDoc -> SDoc
<> Int -> SDoc
int Int
bytes
CmmStaticLit CmmLit
lit -> Platform -> CmmLit -> SDoc
pprDataItem Platform
platform CmmLit
lit
pprGloblDecl :: Platform -> CLabel -> SDoc
pprGloblDecl :: Platform -> CLabel -> SDoc
pprGloblDecl Platform
platform CLabel
lbl
| Bool -> Bool
not (CLabel -> Bool
externallyVisibleCLabel CLabel
lbl) = SDoc
empty
| Bool
otherwise = String -> SDoc
text String
".global " SDoc -> SDoc -> SDoc
<> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
lbl
pprTypeAndSizeDecl :: Platform -> CLabel -> SDoc
pprTypeAndSizeDecl :: Platform -> CLabel -> SDoc
pprTypeAndSizeDecl Platform
platform CLabel
lbl
= if Platform -> OS
platformOS Platform
platform OS -> OS -> Bool
forall a. Eq a => a -> a -> Bool
== OS
OSLinux Bool -> Bool -> Bool
&& CLabel -> Bool
externallyVisibleCLabel CLabel
lbl
then String -> SDoc
text String
".type " SDoc -> SDoc -> SDoc
<> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
lbl SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
", @object"
else SDoc
empty
pprLabel :: Platform -> CLabel -> SDoc
pprLabel :: Platform -> CLabel -> SDoc
pprLabel Platform
platform CLabel
lbl =
Platform -> CLabel -> SDoc
pprGloblDecl Platform
platform CLabel
lbl
SDoc -> SDoc -> SDoc
$$ Platform -> CLabel -> SDoc
pprTypeAndSizeDecl Platform
platform CLabel
lbl
SDoc -> SDoc -> SDoc
$$ (Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
lbl SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
':')
instance OutputableP Platform Instr where
pdoc :: Platform -> Instr -> SDoc
pdoc = Platform -> Instr -> SDoc
pprInstr
pprReg :: Reg -> SDoc
pprReg :: Reg -> SDoc
pprReg Reg
reg
= case Reg
reg of
RegVirtual VirtualReg
vr
-> case VirtualReg
vr of
VirtualRegI Unique
u -> String -> SDoc
text String
"%vI_" SDoc -> SDoc -> SDoc
<> Unique -> SDoc
pprUniqueAlways Unique
u
VirtualRegHi Unique
u -> String -> SDoc
text String
"%vHi_" SDoc -> SDoc -> SDoc
<> Unique -> SDoc
pprUniqueAlways Unique
u
VirtualRegF Unique
u -> String -> SDoc
text String
"%vF_" SDoc -> SDoc -> SDoc
<> Unique -> SDoc
pprUniqueAlways Unique
u
VirtualRegD Unique
u -> String -> SDoc
text String
"%vD_" SDoc -> SDoc -> SDoc
<> Unique -> SDoc
pprUniqueAlways Unique
u
RegReal RealReg
rr
-> case RealReg
rr of
RealRegSingle Int
r1
-> Int -> SDoc
pprReg_ofRegNo Int
r1
RealRegPair Int
r1 Int
r2
-> String -> SDoc
text String
"(" SDoc -> SDoc -> SDoc
<> Int -> SDoc
pprReg_ofRegNo Int
r1
SDoc -> SDoc -> SDoc
<> SDoc
vbar SDoc -> SDoc -> SDoc
<> Int -> SDoc
pprReg_ofRegNo Int
r2
SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
")"
pprReg_ofRegNo :: Int -> SDoc
pprReg_ofRegNo :: Int -> SDoc
pprReg_ofRegNo Int
i
= case Int
i of {
Int
0 -> String -> SDoc
text String
"%g0"; Int
1 -> String -> SDoc
text String
"%g1";
Int
2 -> String -> SDoc
text String
"%g2"; Int
3 -> String -> SDoc
text String
"%g3";
Int
4 -> String -> SDoc
text String
"%g4"; Int
5 -> String -> SDoc
text String
"%g5";
Int
6 -> String -> SDoc
text String
"%g6"; Int
7 -> String -> SDoc
text String
"%g7";
Int
8 -> String -> SDoc
text String
"%o0"; Int
9 -> String -> SDoc
text String
"%o1";
Int
10 -> String -> SDoc
text String
"%o2"; Int
11 -> String -> SDoc
text String
"%o3";
Int
12 -> String -> SDoc
text String
"%o4"; Int
13 -> String -> SDoc
text String
"%o5";
Int
14 -> String -> SDoc
text String
"%o6"; Int
15 -> String -> SDoc
text String
"%o7";
Int
16 -> String -> SDoc
text String
"%l0"; Int
17 -> String -> SDoc
text String
"%l1";
Int
18 -> String -> SDoc
text String
"%l2"; Int
19 -> String -> SDoc
text String
"%l3";
Int
20 -> String -> SDoc
text String
"%l4"; Int
21 -> String -> SDoc
text String
"%l5";
Int
22 -> String -> SDoc
text String
"%l6"; Int
23 -> String -> SDoc
text String
"%l7";
Int
24 -> String -> SDoc
text String
"%i0"; Int
25 -> String -> SDoc
text String
"%i1";
Int
26 -> String -> SDoc
text String
"%i2"; Int
27 -> String -> SDoc
text String
"%i3";
Int
28 -> String -> SDoc
text String
"%i4"; Int
29 -> String -> SDoc
text String
"%i5";
Int
30 -> String -> SDoc
text String
"%i6"; Int
31 -> String -> SDoc
text String
"%i7";
Int
32 -> String -> SDoc
text String
"%f0"; Int
33 -> String -> SDoc
text String
"%f1";
Int
34 -> String -> SDoc
text String
"%f2"; Int
35 -> String -> SDoc
text String
"%f3";
Int
36 -> String -> SDoc
text String
"%f4"; Int
37 -> String -> SDoc
text String
"%f5";
Int
38 -> String -> SDoc
text String
"%f6"; Int
39 -> String -> SDoc
text String
"%f7";
Int
40 -> String -> SDoc
text String
"%f8"; Int
41 -> String -> SDoc
text String
"%f9";
Int
42 -> String -> SDoc
text String
"%f10"; Int
43 -> String -> SDoc
text String
"%f11";
Int
44 -> String -> SDoc
text String
"%f12"; Int
45 -> String -> SDoc
text String
"%f13";
Int
46 -> String -> SDoc
text String
"%f14"; Int
47 -> String -> SDoc
text String
"%f15";
Int
48 -> String -> SDoc
text String
"%f16"; Int
49 -> String -> SDoc
text String
"%f17";
Int
50 -> String -> SDoc
text String
"%f18"; Int
51 -> String -> SDoc
text String
"%f19";
Int
52 -> String -> SDoc
text String
"%f20"; Int
53 -> String -> SDoc
text String
"%f21";
Int
54 -> String -> SDoc
text String
"%f22"; Int
55 -> String -> SDoc
text String
"%f23";
Int
56 -> String -> SDoc
text String
"%f24"; Int
57 -> String -> SDoc
text String
"%f25";
Int
58 -> String -> SDoc
text String
"%f26"; Int
59 -> String -> SDoc
text String
"%f27";
Int
60 -> String -> SDoc
text String
"%f28"; Int
61 -> String -> SDoc
text String
"%f29";
Int
62 -> String -> SDoc
text String
"%f30"; Int
63 -> String -> SDoc
text String
"%f31";
Int
_ -> String -> SDoc
text String
"very naughty sparc register" }
pprFormat :: Format -> SDoc
pprFormat :: Format -> SDoc
pprFormat Format
x
= case Format
x of
Format
II8 -> String -> SDoc
text String
"ub"
Format
II16 -> String -> SDoc
text String
"uh"
Format
II32 -> String -> SDoc
text String
""
Format
II64 -> String -> SDoc
text String
"d"
Format
FF32 -> String -> SDoc
text String
""
Format
FF64 -> String -> SDoc
text String
"d"
pprStFormat :: Format -> SDoc
pprStFormat :: Format -> SDoc
pprStFormat Format
x
= case Format
x of
Format
II8 -> String -> SDoc
text String
"b"
Format
II16 -> String -> SDoc
text String
"h"
Format
II32 -> String -> SDoc
text String
""
Format
II64 -> String -> SDoc
text String
"x"
Format
FF32 -> String -> SDoc
text String
""
Format
FF64 -> String -> SDoc
text String
"d"
pprCond :: Cond -> SDoc
pprCond :: Cond -> SDoc
pprCond Cond
c
= case Cond
c of
Cond
ALWAYS -> String -> SDoc
text String
""
Cond
NEVER -> String -> SDoc
text String
"n"
Cond
GEU -> String -> SDoc
text String
"geu"
Cond
LU -> String -> SDoc
text String
"lu"
Cond
EQQ -> String -> SDoc
text String
"e"
Cond
GTT -> String -> SDoc
text String
"g"
Cond
GE -> String -> SDoc
text String
"ge"
Cond
GU -> String -> SDoc
text String
"gu"
Cond
LTT -> String -> SDoc
text String
"l"
Cond
LE -> String -> SDoc
text String
"le"
Cond
LEU -> String -> SDoc
text String
"leu"
Cond
NE -> String -> SDoc
text String
"ne"
Cond
NEG -> String -> SDoc
text String
"neg"
Cond
POS -> String -> SDoc
text String
"pos"
Cond
VC -> String -> SDoc
text String
"vc"
Cond
VS -> String -> SDoc
text String
"vs"
pprAddr :: Platform -> AddrMode -> SDoc
pprAddr :: Platform -> AddrMode -> SDoc
pprAddr Platform
platform AddrMode
am
= case AddrMode
am of
AddrRegReg Reg
r1 (RegReal (RealRegSingle Int
0))
-> Reg -> SDoc
pprReg Reg
r1
AddrRegReg Reg
r1 Reg
r2
-> [SDoc] -> SDoc
hcat [ Reg -> SDoc
pprReg Reg
r1, Char -> SDoc
char Char
'+', Reg -> SDoc
pprReg Reg
r2 ]
AddrRegImm Reg
r1 (ImmInt Int
i)
| Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 -> Reg -> SDoc
pprReg Reg
r1
| Bool -> Bool
not (Int -> Bool
forall a. Integral a => a -> Bool
fits13Bits Int
i) -> Int -> SDoc
forall a b. Show a => a -> b
largeOffsetError Int
i
| Bool
otherwise -> [SDoc] -> SDoc
hcat [ Reg -> SDoc
pprReg Reg
r1, SDoc
pp_sign, Int -> SDoc
int Int
i ]
where
pp_sign :: SDoc
pp_sign = if Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 then Char -> SDoc
char Char
'+' else SDoc
empty
AddrRegImm Reg
r1 (ImmInteger Integer
i)
| Integer
i Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
0 -> Reg -> SDoc
pprReg Reg
r1
| Bool -> Bool
not (Integer -> Bool
forall a. Integral a => a -> Bool
fits13Bits Integer
i) -> Integer -> SDoc
forall a b. Show a => a -> b
largeOffsetError Integer
i
| Bool
otherwise -> [SDoc] -> SDoc
hcat [ Reg -> SDoc
pprReg Reg
r1, SDoc
pp_sign, Integer -> SDoc
integer Integer
i ]
where
pp_sign :: SDoc
pp_sign = if Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0 then Char -> SDoc
char Char
'+' else SDoc
empty
AddrRegImm Reg
r1 Imm
imm
-> [SDoc] -> SDoc
hcat [ Reg -> SDoc
pprReg Reg
r1, Char -> SDoc
char Char
'+', Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm ]
pprImm :: Platform -> Imm -> SDoc
pprImm :: Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm
= case Imm
imm of
ImmInt Int
i -> Int -> SDoc
int Int
i
ImmInteger Integer
i -> Integer -> SDoc
integer Integer
i
ImmCLbl CLabel
l -> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
l
ImmIndex CLabel
l Int
i -> Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform CLabel
l SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'+' SDoc -> SDoc -> SDoc
<> Int -> SDoc
int Int
i
ImmLit SDoc
s -> SDoc
s
ImmConstantSum Imm
a Imm
b
-> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
a SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'+' SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
b
ImmConstantDiff Imm
a Imm
b
-> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
a SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'-' SDoc -> SDoc -> SDoc
<> SDoc
lparen SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
b SDoc -> SDoc -> SDoc
<> SDoc
rparen
LO Imm
i
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"%lo(", Platform -> Imm -> SDoc
pprImm Platform
platform Imm
i, SDoc
rparen ]
HI Imm
i
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"%hi(", Platform -> Imm -> SDoc
pprImm Platform
platform Imm
i, SDoc
rparen ]
ImmFloat Rational
_ -> String -> SDoc
text String
"naughty float immediate"
ImmDouble Rational
_ -> String -> SDoc
text String
"naughty double immediate"
pprSectionAlign :: NCGConfig -> Section -> SDoc
pprSectionAlign :: NCGConfig -> Section -> SDoc
pprSectionAlign NCGConfig
config sec :: Section
sec@(Section SectionType
seg CLabel
_) =
NCGConfig -> Section -> SDoc
pprSectionHeader NCGConfig
config Section
sec SDoc -> SDoc -> SDoc
$$
SectionType -> SDoc
pprAlignForSection SectionType
seg
pprAlignForSection :: SectionType -> SDoc
pprAlignForSection :: SectionType -> SDoc
pprAlignForSection SectionType
seg =
case SectionType
seg of
SectionType
Text -> String -> SDoc
text String
".align 4"
SectionType
Data -> String -> SDoc
text String
".align 8"
SectionType
ReadOnlyData -> String -> SDoc
text String
".align 8"
SectionType
RelocatableReadOnlyData -> String -> SDoc
text String
".align 8"
SectionType
UninitialisedData -> String -> SDoc
text String
".align 8"
SectionType
ReadOnlyData16 -> String -> SDoc
text String
".align 16"
SectionType
CString -> String -> SDoc
text String
".align 8"
OtherSection String
_ -> String -> SDoc
forall a. String -> a
panic String
"PprMach.pprSectionHeader: unknown section"
pprDataItem :: Platform -> CmmLit -> SDoc
pprDataItem :: Platform -> CmmLit -> SDoc
pprDataItem Platform
platform CmmLit
lit
= [SDoc] -> SDoc
vcat (Format -> CmmLit -> [SDoc]
ppr_item (CmmType -> Format
cmmTypeFormat (CmmType -> Format) -> CmmType -> Format
forall a b. (a -> b) -> a -> b
$ Platform -> CmmLit -> CmmType
cmmLitType Platform
platform CmmLit
lit) CmmLit
lit)
where
imm :: Imm
imm = CmmLit -> Imm
litToImm CmmLit
lit
ppr_item :: Format -> CmmLit -> [SDoc]
ppr_item Format
II8 CmmLit
_ = [String -> SDoc
text String
"\t.byte\t" SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm]
ppr_item Format
II32 CmmLit
_ = [String -> SDoc
text String
"\t.long\t" SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm]
ppr_item Format
FF32 (CmmFloat Rational
r Width
_)
= let bs :: [Int]
bs = Float -> [Int]
floatToBytes (Rational -> Float
forall a. Fractional a => Rational -> a
fromRational Rational
r)
in (Int -> SDoc) -> [Int] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (\Int
b -> String -> SDoc
text String
"\t.byte\t" SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform (Int -> Imm
ImmInt Int
b)) [Int]
bs
ppr_item Format
FF64 (CmmFloat Rational
r Width
_)
= let bs :: [Int]
bs = Double -> [Int]
doubleToBytes (Rational -> Double
forall a. Fractional a => Rational -> a
fromRational Rational
r)
in (Int -> SDoc) -> [Int] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (\Int
b -> String -> SDoc
text String
"\t.byte\t" SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform (Int -> Imm
ImmInt Int
b)) [Int]
bs
ppr_item Format
II16 CmmLit
_ = [String -> SDoc
text String
"\t.short\t" SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm]
ppr_item Format
II64 CmmLit
_ = [String -> SDoc
text String
"\t.quad\t" SDoc -> SDoc -> SDoc
<> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm]
ppr_item Format
_ CmmLit
_ = String -> [SDoc]
forall a. String -> a
panic String
"SPARC.Ppr.pprDataItem: no match"
floatToBytes :: Float -> [Int]
floatToBytes :: Float -> [Int]
floatToBytes Float
f
= (forall s. ST s [Int]) -> [Int]
forall a. (forall s. ST s a) -> a
runST (do
STUArray s Int Float
arr <- (Int, Int) -> ST s (STUArray s Int Float)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ ((Int
0::Int),Int
3)
STUArray s Int Float -> Int -> Float -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> i -> e -> m ()
writeArray STUArray s Int Float
arr Int
0 Float
f
STUArray s Int Word8
arr <- STUArray s Int Float -> ST s (STUArray s Int Word8)
forall s. STUArray s Int Float -> ST s (STUArray s Int Word8)
castFloatToWord8Array STUArray s Int Float
arr
Word8
i0 <- STUArray s Int Word8 -> Int -> ST s Word8
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> i -> m e
readArray STUArray s Int Word8
arr Int
0
Word8
i1 <- STUArray s Int Word8 -> Int -> ST s Word8
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> i -> m e
readArray STUArray s Int Word8
arr Int
1
Word8
i2 <- STUArray s Int Word8 -> Int -> ST s Word8
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> i -> m e
readArray STUArray s Int Word8
arr Int
2
Word8
i3 <- STUArray s Int Word8 -> Int -> ST s Word8
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> i -> m e
readArray STUArray s Int Word8
arr Int
3
[Int] -> ST s [Int]
forall (m :: * -> *) a. Monad m => a -> m a
return ((Word8 -> Int) -> [Word8] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Word8
i0,Word8
i1,Word8
i2,Word8
i3])
)
castFloatToWord8Array :: STUArray s Int Float -> ST s (STUArray s Int Word8)
castFloatToWord8Array :: STUArray s Int Float -> ST s (STUArray s Int Word8)
castFloatToWord8Array = STUArray s Int Float -> ST s (STUArray s Int Word8)
forall s ix a b. STUArray s ix a -> ST s (STUArray s ix b)
U.castSTUArray
pprInstr :: Platform -> Instr -> SDoc
pprInstr :: Platform -> Instr -> SDoc
pprInstr Platform
platform = \case
COMMENT FastString
_ -> SDoc
empty
DELTA Int
d -> Platform -> Instr -> SDoc
pprInstr Platform
platform (FastString -> Instr
COMMENT (String -> FastString
mkFastString (String
"\tdelta = " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
d)))
NEWBLOCK BlockId
_ -> String -> SDoc
forall a. String -> a
panic String
"X86.Ppr.pprInstr: NEWBLOCK"
LDATA Section
_ RawCmmStatics
_ -> String -> SDoc
forall a. String -> a
panic String
"PprMach.pprInstr: LDATA"
LD Format
FF64 AddrMode
_ Reg
reg
| RegReal (RealRegSingle{}) <- Reg
reg
-> String -> SDoc
forall a. String -> a
panic String
"SPARC.Ppr: not emitting potentially misaligned LD FF64 instr"
LD Format
format AddrMode
addr Reg
reg
-> [SDoc] -> SDoc
hcat [
String -> SDoc
text String
"\tld",
Format -> SDoc
pprFormat Format
format,
Char -> SDoc
char Char
'\t',
SDoc
lbrack,
Platform -> AddrMode -> SDoc
pprAddr Platform
platform AddrMode
addr,
SDoc
pp_rbracket_comma,
Reg -> SDoc
pprReg Reg
reg
]
ST Format
FF64 Reg
reg AddrMode
_
| RegReal (RealRegSingle{}) <- Reg
reg
-> String -> SDoc
forall a. String -> a
panic String
"SPARC.Ppr: not emitting potentially misaligned ST FF64 instr"
ST Format
format Reg
reg AddrMode
addr
-> [SDoc] -> SDoc
hcat [
String -> SDoc
text String
"\tst",
Format -> SDoc
pprStFormat Format
format,
Char -> SDoc
char Char
'\t',
Reg -> SDoc
pprReg Reg
reg,
SDoc
pp_comma_lbracket,
Platform -> AddrMode -> SDoc
pprAddr Platform
platform AddrMode
addr,
SDoc
rbrack
]
ADD Bool
x Bool
cc Reg
reg1 RI
ri Reg
reg2
| Bool -> Bool
not Bool
x Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
cc Bool -> Bool -> Bool
&& RI -> Bool
riZero RI
ri
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"\tmov\t", Reg -> SDoc
pprReg Reg
reg1, SDoc
comma, Reg -> SDoc
pprReg Reg
reg2 ]
| Bool
otherwise
-> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (if Bool
x then String -> SDoc
text String
"addx" else String -> SDoc
text String
"add") Bool
cc Reg
reg1 RI
ri Reg
reg2
SUB Bool
x Bool
cc Reg
reg1 RI
ri Reg
reg2
| Bool -> Bool
not Bool
x Bool -> Bool -> Bool
&& Bool
cc Bool -> Bool -> Bool
&& Reg
reg2 Reg -> Reg -> Bool
forall a. Eq a => a -> a -> Bool
== Reg
g0
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"\tcmp\t", Reg -> SDoc
pprReg Reg
reg1, SDoc
comma, Platform -> RI -> SDoc
pprRI Platform
platform RI
ri ]
| Bool -> Bool
not Bool
x Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
cc Bool -> Bool -> Bool
&& RI -> Bool
riZero RI
ri
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"\tmov\t", Reg -> SDoc
pprReg Reg
reg1, SDoc
comma, Reg -> SDoc
pprReg Reg
reg2 ]
| Bool
otherwise
-> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (if Bool
x then String -> SDoc
text String
"subx" else String -> SDoc
text String
"sub") Bool
cc Reg
reg1 RI
ri Reg
reg2
AND Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"and") Bool
b Reg
reg1 RI
ri Reg
reg2
ANDN Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"andn") Bool
b Reg
reg1 RI
ri Reg
reg2
OR Bool
b Reg
reg1 RI
ri Reg
reg2
| Bool -> Bool
not Bool
b Bool -> Bool -> Bool
&& Reg
reg1 Reg -> Reg -> Bool
forall a. Eq a => a -> a -> Bool
== Reg
g0
-> let doit :: SDoc
doit = [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"\tmov\t", Platform -> RI -> SDoc
pprRI Platform
platform RI
ri, SDoc
comma, Reg -> SDoc
pprReg Reg
reg2 ]
in case RI
ri of
RIReg Reg
rrr | Reg
rrr Reg -> Reg -> Bool
forall a. Eq a => a -> a -> Bool
== Reg
reg2 -> SDoc
empty
RI
_ -> SDoc
doit
| Bool
otherwise
-> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"or") Bool
b Reg
reg1 RI
ri Reg
reg2
ORN Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"orn") Bool
b Reg
reg1 RI
ri Reg
reg2
XOR Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"xor") Bool
b Reg
reg1 RI
ri Reg
reg2
XNOR Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"xnor") Bool
b Reg
reg1 RI
ri Reg
reg2
SLL Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"sll") Bool
False Reg
reg1 RI
ri Reg
reg2
SRL Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"srl") Bool
False Reg
reg1 RI
ri Reg
reg2
SRA Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"sra") Bool
False Reg
reg1 RI
ri Reg
reg2
RDY Reg
rd -> String -> SDoc
text String
"\trd\t%y," SDoc -> SDoc -> SDoc
<> Reg -> SDoc
pprReg Reg
rd
WRY Reg
reg1 Reg
reg2
-> String -> SDoc
text String
"\twr\t"
SDoc -> SDoc -> SDoc
<> Reg -> SDoc
pprReg Reg
reg1
SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
','
SDoc -> SDoc -> SDoc
<> Reg -> SDoc
pprReg Reg
reg2
SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
','
SDoc -> SDoc -> SDoc
<> String -> SDoc
text String
"%y"
SMUL Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"smul") Bool
b Reg
reg1 RI
ri Reg
reg2
UMUL Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"umul") Bool
b Reg
reg1 RI
ri Reg
reg2
SDIV Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"sdiv") Bool
b Reg
reg1 RI
ri Reg
reg2
UDIV Bool
b Reg
reg1 RI
ri Reg
reg2 -> Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform (String -> SDoc
text String
"udiv") Bool
b Reg
reg1 RI
ri Reg
reg2
SETHI Imm
imm Reg
reg
-> [SDoc] -> SDoc
hcat [
String -> SDoc
text String
"\tsethi\t",
Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm,
SDoc
comma,
Reg -> SDoc
pprReg Reg
reg
]
Instr
NOP -> String -> SDoc
text String
"\tnop"
FABS Format
format Reg
reg1 Reg
reg2
-> SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg (String -> SDoc
text String
"fabs") Format
format Reg
reg1 Reg
reg2
FADD Format
format Reg
reg1 Reg
reg2 Reg
reg3
-> SDoc -> Format -> Reg -> Reg -> Reg -> SDoc
pprFormatRegRegReg (String -> SDoc
text String
"fadd") Format
format Reg
reg1 Reg
reg2 Reg
reg3
FCMP Bool
e Format
format Reg
reg1 Reg
reg2
-> SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg (if Bool
e then String -> SDoc
text String
"fcmpe" else String -> SDoc
text String
"fcmp")
Format
format Reg
reg1 Reg
reg2
FDIV Format
format Reg
reg1 Reg
reg2 Reg
reg3
-> SDoc -> Format -> Reg -> Reg -> Reg -> SDoc
pprFormatRegRegReg (String -> SDoc
text String
"fdiv") Format
format Reg
reg1 Reg
reg2 Reg
reg3
FMOV Format
format Reg
reg1 Reg
reg2
-> SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg (String -> SDoc
text String
"fmov") Format
format Reg
reg1 Reg
reg2
FMUL Format
format Reg
reg1 Reg
reg2 Reg
reg3
-> SDoc -> Format -> Reg -> Reg -> Reg -> SDoc
pprFormatRegRegReg (String -> SDoc
text String
"fmul") Format
format Reg
reg1 Reg
reg2 Reg
reg3
FNEG Format
format Reg
reg1 Reg
reg2
-> SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg (String -> SDoc
text String
"fneg") Format
format Reg
reg1 Reg
reg2
FSQRT Format
format Reg
reg1 Reg
reg2
-> SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg (String -> SDoc
text String
"fsqrt") Format
format Reg
reg1 Reg
reg2
FSUB Format
format Reg
reg1 Reg
reg2 Reg
reg3
-> SDoc -> Format -> Reg -> Reg -> Reg -> SDoc
pprFormatRegRegReg (String -> SDoc
text String
"fsub") Format
format Reg
reg1 Reg
reg2 Reg
reg3
FxTOy Format
format1 Format
format2 Reg
reg1 Reg
reg2
-> [SDoc] -> SDoc
hcat [
String -> SDoc
text String
"\tf",
(case Format
format1 of
Format
II32 -> String -> SDoc
text String
"ito"
Format
FF32 -> String -> SDoc
text String
"sto"
Format
FF64 -> String -> SDoc
text String
"dto"
Format
_ -> String -> SDoc
forall a. String -> a
panic String
"SPARC.Ppr.pprInstr.FxToY: no match"),
(case Format
format2 of
Format
II32 -> String -> SDoc
text String
"i\t"
Format
II64 -> String -> SDoc
text String
"x\t"
Format
FF32 -> String -> SDoc
text String
"s\t"
Format
FF64 -> String -> SDoc
text String
"d\t"
Format
_ -> String -> SDoc
forall a. String -> a
panic String
"SPARC.Ppr.pprInstr.FxToY: no match"),
Reg -> SDoc
pprReg Reg
reg1, SDoc
comma, Reg -> SDoc
pprReg Reg
reg2
]
BI Cond
cond Bool
b BlockId
blockid
-> [SDoc] -> SDoc
hcat [
String -> SDoc
text String
"\tb", Cond -> SDoc
pprCond Cond
cond,
if Bool
b then SDoc
pp_comma_a else SDoc
empty,
Char -> SDoc
char Char
'\t',
Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform (BlockId -> CLabel
blockLbl BlockId
blockid)
]
BF Cond
cond Bool
b BlockId
blockid
-> [SDoc] -> SDoc
hcat [
String -> SDoc
text String
"\tfb", Cond -> SDoc
pprCond Cond
cond,
if Bool
b then SDoc
pp_comma_a else SDoc
empty,
Char -> SDoc
char Char
'\t',
Platform -> CLabel -> SDoc
forall env a. OutputableP env a => env -> a -> SDoc
pdoc Platform
platform (BlockId -> CLabel
blockLbl BlockId
blockid)
]
JMP AddrMode
addr -> String -> SDoc
text String
"\tjmp\t" SDoc -> SDoc -> SDoc
<> Platform -> AddrMode -> SDoc
pprAddr Platform
platform AddrMode
addr
JMP_TBL AddrMode
op [Maybe BlockId]
_ CLabel
_ -> Platform -> Instr -> SDoc
pprInstr Platform
platform (AddrMode -> Instr
JMP AddrMode
op)
CALL (Left Imm
imm) Int
n Bool
_
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"\tcall\t", Platform -> Imm -> SDoc
pprImm Platform
platform Imm
imm, SDoc
comma, Int -> SDoc
int Int
n ]
CALL (Right Reg
reg) Int
n Bool
_
-> [SDoc] -> SDoc
hcat [ String -> SDoc
text String
"\tcall\t", Reg -> SDoc
pprReg Reg
reg, SDoc
comma, Int -> SDoc
int Int
n ]
pprRI :: Platform -> RI -> SDoc
pprRI :: Platform -> RI -> SDoc
pprRI Platform
platform = \case
RIReg Reg
r -> Reg -> SDoc
pprReg Reg
r
RIImm Imm
r -> Platform -> Imm -> SDoc
pprImm Platform
platform Imm
r
pprFormatRegReg :: SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg :: SDoc -> Format -> Reg -> Reg -> SDoc
pprFormatRegReg SDoc
name Format
format Reg
reg1 Reg
reg2
= [SDoc] -> SDoc
hcat [
Char -> SDoc
char Char
'\t',
SDoc
name,
(case Format
format of
Format
FF32 -> String -> SDoc
text String
"s\t"
Format
FF64 -> String -> SDoc
text String
"d\t"
Format
_ -> String -> SDoc
forall a. String -> a
panic String
"SPARC.Ppr.pprFormatRegReg: no match"),
Reg -> SDoc
pprReg Reg
reg1,
SDoc
comma,
Reg -> SDoc
pprReg Reg
reg2
]
pprFormatRegRegReg :: SDoc -> Format -> Reg -> Reg -> Reg -> SDoc
pprFormatRegRegReg :: SDoc -> Format -> Reg -> Reg -> Reg -> SDoc
pprFormatRegRegReg SDoc
name Format
format Reg
reg1 Reg
reg2 Reg
reg3
= [SDoc] -> SDoc
hcat [
Char -> SDoc
char Char
'\t',
SDoc
name,
(case Format
format of
Format
FF32 -> String -> SDoc
text String
"s\t"
Format
FF64 -> String -> SDoc
text String
"d\t"
Format
_ -> String -> SDoc
forall a. String -> a
panic String
"SPARC.Ppr.pprFormatRegReg: no match"),
Reg -> SDoc
pprReg Reg
reg1,
SDoc
comma,
Reg -> SDoc
pprReg Reg
reg2,
SDoc
comma,
Reg -> SDoc
pprReg Reg
reg3
]
pprRegRIReg :: Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg :: Platform -> SDoc -> Bool -> Reg -> RI -> Reg -> SDoc
pprRegRIReg Platform
platform SDoc
name Bool
b Reg
reg1 RI
ri Reg
reg2
= [SDoc] -> SDoc
hcat [
Char -> SDoc
char Char
'\t',
SDoc
name,
if Bool
b then String -> SDoc
text String
"cc\t" else Char -> SDoc
char Char
'\t',
Reg -> SDoc
pprReg Reg
reg1,
SDoc
comma,
Platform -> RI -> SDoc
pprRI Platform
platform RI
ri,
SDoc
comma,
Reg -> SDoc
pprReg Reg
reg2
]
pp_rbracket_comma :: SDoc
pp_rbracket_comma :: SDoc
pp_rbracket_comma = String -> SDoc
text String
"],"
pp_comma_lbracket :: SDoc
pp_comma_lbracket :: SDoc
pp_comma_lbracket = String -> SDoc
text String
",["
pp_comma_a :: SDoc
pp_comma_a :: SDoc
pp_comma_a = String -> SDoc
text String
",a"