{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE CPP #-}
module GHC.CmmToAsm.AArch64.Ppr (pprNatCmmDecl, pprInstr) where
import GHC.Prelude hiding (EQ)
import GHC.CmmToAsm.AArch64.Instr
import GHC.CmmToAsm.AArch64.Regs
import GHC.CmmToAsm.AArch64.Cond
import GHC.CmmToAsm.Ppr
import GHC.CmmToAsm.Format
import GHC.Platform.Reg
import GHC.CmmToAsm.Config
import GHC.CmmToAsm.Types
import GHC.CmmToAsm.Utils
import GHC.Cmm hiding (topInfoTable)
import GHC.Cmm.Dataflow.Collections
import GHC.Cmm.Dataflow.Label
import GHC.Types.Basic (Alignment, mkAlignment, alignmentBytes)
import GHC.Cmm.BlockId
import GHC.Cmm.CLabel
import GHC.Types.Unique ( pprUniqueAlways, getUnique )
import GHC.Platform
import GHC.Utils.Outputable
import GHC.Utils.Panic
pprProcAlignment :: IsDoc doc => NCGConfig -> doc
pprProcAlignment :: forall doc. IsDoc doc => NCGConfig -> doc
pprProcAlignment NCGConfig
config = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall doc. IsOutput doc => doc
empty (forall doc. IsDoc doc => Platform -> Alignment -> doc
pprAlign Platform
platform forall b c a. (b -> c) -> (a -> b) -> a -> c
. RegNo -> Alignment
mkAlignment) (NCGConfig -> Maybe RegNo
ncgProcAlignment NCGConfig
config)
where
platform :: Platform
platform = NCGConfig -> Platform
ncgPlatform NCGConfig
config
pprNatCmmDecl :: IsDoc doc => NCGConfig -> NatCmmDecl RawCmmStatics Instr -> doc
pprNatCmmDecl :: forall doc.
IsDoc doc =>
NCGConfig -> NatCmmDecl RawCmmStatics Instr -> doc
pprNatCmmDecl NCGConfig
config (CmmData Section
section RawCmmStatics
dats) =
forall doc. IsDoc doc => NCGConfig -> Section -> doc
pprSectionAlign NCGConfig
config Section
section forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsDoc doc => NCGConfig -> RawCmmStatics -> doc
pprDatas 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
forall doc. IsDoc doc => NCGConfig -> doc
pprProcAlignment NCGConfig
config forall doc. IsDoc doc => doc -> doc -> doc
$$
case forall a i b. GenCmmDecl a (LabelMap i) (ListGraph b) -> Maybe i
topInfoTable NatCmmDecl RawCmmStatics Instr
proc of
Maybe RawCmmStatics
Nothing ->
forall doc. IsDoc doc => NCGConfig -> Section -> doc
pprSectionAlign NCGConfig
config (SectionType -> CLabel -> Section
Section SectionType
Text CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => Platform -> CLabel -> doc
pprLabel Platform
platform CLabel
lbl forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map (forall doc.
IsDoc doc =>
NCGConfig -> LabelMap RawCmmStatics -> GenBasicBlock Instr -> doc
pprBasicBlock NCGConfig
config LabelMap RawCmmStatics
top_info) [GenBasicBlock Instr]
blocks) forall doc. IsDoc doc => doc -> doc -> doc
$$
(if NCGConfig -> Bool
ncgDwarfEnabled NCGConfig
config
then forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (CLabel -> CLabel
mkAsmTempEndLabel CLabel
lbl) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
':') else forall doc. IsOutput doc => doc
empty) forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => Platform -> CLabel -> doc
pprSizeDecl Platform
platform CLabel
lbl
Just (CmmStaticsRaw CLabel
info_lbl [CmmStatic]
_) ->
forall doc. IsDoc doc => NCGConfig -> Section -> doc
pprSectionAlign NCGConfig
config (SectionType -> CLabel -> Section
Section SectionType
Text CLabel
info_lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
(if Platform -> Bool
platformHasSubsectionsViaSymbols Platform
platform
then forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (CLabel -> CLabel
mkDeadStripPreventer CLabel
info_lbl) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
':')
else forall doc. IsOutput doc => doc
empty) forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map (forall doc.
IsDoc doc =>
NCGConfig -> LabelMap RawCmmStatics -> GenBasicBlock Instr -> doc
pprBasicBlock NCGConfig
config LabelMap RawCmmStatics
top_info) [GenBasicBlock Instr]
blocks) forall doc. IsDoc doc => doc -> doc -> doc
$$
(if Platform -> Bool
platformHasSubsectionsViaSymbols Platform
platform
then
forall doc. IsDoc doc => Line doc -> doc
line
forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\t.long "
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
info_lbl
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'-'
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (CLabel -> CLabel
mkDeadStripPreventer CLabel
info_lbl)
else forall doc. IsOutput doc => doc
empty) forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => Platform -> CLabel -> doc
pprSizeDecl Platform
platform CLabel
info_lbl
{-# SPECIALIZE pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc #-}
{-# SPECIALIZE pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> HDoc #-}
pprLabel :: IsDoc doc => Platform -> CLabel -> doc
pprLabel :: forall doc. IsDoc doc => Platform -> CLabel -> doc
pprLabel Platform
platform CLabel
lbl =
forall doc. IsDoc doc => Platform -> CLabel -> doc
pprGloblDecl Platform
platform CLabel
lbl
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsDoc doc => Platform -> CLabel -> doc
pprTypeDecl Platform
platform CLabel
lbl
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
':')
pprAlign :: IsDoc doc => Platform -> Alignment -> doc
pprAlign :: forall doc. IsDoc doc => Platform -> Alignment -> doc
pprAlign Platform
_platform Alignment
alignment
= forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\t.balign " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (Alignment -> RegNo
alignmentBytes Alignment
alignment)
pprAlignForSection :: IsDoc doc => Platform -> SectionType -> doc
pprAlignForSection :: forall doc. IsDoc doc => Platform -> SectionType -> doc
pprAlignForSection Platform
_platform SectionType
_seg
= forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
text String
"\t.balign 8")
pprSectionAlign :: IsDoc doc => NCGConfig -> Section -> doc
pprSectionAlign :: forall doc. IsDoc doc => NCGConfig -> Section -> doc
pprSectionAlign NCGConfig
_config (Section (OtherSection String
_) CLabel
_) =
forall a. HasCallStack => String -> a
panic String
"AArch64.Ppr.pprSectionAlign: unknown section"
pprSectionAlign NCGConfig
config sec :: Section
sec@(Section SectionType
seg CLabel
_) =
forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => NCGConfig -> Section -> doc
pprSectionHeader NCGConfig
config Section
sec)
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsDoc doc => Platform -> SectionType -> doc
pprAlignForSection (NCGConfig -> Platform
ncgPlatform NCGConfig
config) SectionType
seg
pprSizeDecl :: IsDoc doc => Platform -> CLabel -> doc
pprSizeDecl :: forall doc. IsDoc doc => Platform -> CLabel -> doc
pprSizeDecl Platform
platform CLabel
lbl
= if OS -> Bool
osElfTarget (Platform -> OS
platformOS Platform
platform)
then forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
text String
"\t.size" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => String -> doc
text String
", .-" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl)
else forall doc. IsOutput doc => doc
empty
pprBasicBlock :: IsDoc doc => NCGConfig -> LabelMap RawCmmStatics -> NatBasicBlock Instr
-> doc
pprBasicBlock :: forall doc.
IsDoc doc =>
NCGConfig -> LabelMap RawCmmStatics -> GenBasicBlock Instr -> doc
pprBasicBlock NCGConfig
config LabelMap RawCmmStatics
info_env (BasicBlock BlockId
blockid [Instr]
instrs)
= doc -> doc
maybe_infotable forall a b. (a -> b) -> a -> b
$
forall doc. IsDoc doc => Platform -> CLabel -> doc
pprLabel Platform
platform CLabel
asmLbl forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map (forall doc. IsDoc doc => Platform -> Instr -> doc
pprInstr Platform
platform) (forall a. a -> a
id [Instr]
optInstrs)) forall doc. IsDoc doc => doc -> doc -> doc
$$
(if NCGConfig -> Bool
ncgDwarfEnabled NCGConfig
config
then forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (CLabel -> CLabel
mkAsmTempEndLabel CLabel
asmLbl) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
':')
else forall doc. IsOutput doc => doc
empty
)
where
optInstrs :: [Instr]
optInstrs = forall a. (a -> Bool) -> [a] -> [a]
filter Instr -> Bool
f [Instr]
instrs
where f :: Instr -> Bool
f (MOV Operand
o1 Operand
o2) | Operand
o1 forall a. Eq a => a -> a -> Bool
== Operand
o2 = Bool
False
f Instr
_ = Bool
True
asmLbl :: CLabel
asmLbl = BlockId -> CLabel
blockLbl BlockId
blockid
platform :: Platform
platform = NCGConfig -> Platform
ncgPlatform NCGConfig
config
maybe_infotable :: doc -> doc
maybe_infotable doc
c = case forall (map :: * -> *) a.
IsMap map =>
KeyOf map -> map a -> Maybe a
mapLookup BlockId
blockid LabelMap RawCmmStatics
info_env of
Maybe RawCmmStatics
Nothing -> doc
c
Just (CmmStaticsRaw CLabel
info_lbl [CmmStatic]
info) ->
doc
infoTableLoc forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map (forall doc. IsDoc doc => NCGConfig -> CmmStatic -> doc
pprData NCGConfig
config) [CmmStatic]
info) forall doc. IsDoc doc => doc -> doc -> doc
$$
forall doc. IsDoc doc => Platform -> CLabel -> doc
pprLabel Platform
platform CLabel
info_lbl forall doc. IsDoc doc => doc -> doc -> doc
$$
doc
c forall doc. IsDoc doc => doc -> doc -> doc
$$
(if NCGConfig -> Bool
ncgDwarfEnabled NCGConfig
config
then forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (CLabel -> CLabel
mkAsmTempEndLabel CLabel
info_lbl) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
':')
else forall doc. IsOutput doc => doc
empty)
infoTableLoc :: doc
infoTableLoc = case [Instr]
instrs of
(l :: Instr
l@LOCATION{} : [Instr]
_) -> forall doc. IsDoc doc => Platform -> Instr -> doc
pprInstr Platform
platform Instr
l
[Instr]
_other -> forall doc. IsOutput doc => doc
empty
pprDatas :: IsDoc doc => NCGConfig -> RawCmmStatics -> doc
pprDatas :: forall doc. IsDoc doc => NCGConfig -> RawCmmStatics -> doc
pprDatas NCGConfig
config (CmmStaticsRaw CLabel
alias [CmmStaticLit (CmmLabel CLabel
lbl), CmmStaticLit CmmLit
ind, CmmStatic
_, CmmStatic
_])
| CLabel
lbl forall a. Eq a => a -> a -> Bool
== CLabel
mkIndStaticInfoLabel
, let labelInd :: CmmLit -> Maybe CLabel
labelInd (CmmLabelOff CLabel
l RegNo
_) = forall a. a -> Maybe a
Just CLabel
l
labelInd (CmmLabel CLabel
l) = forall a. a -> Maybe a
Just CLabel
l
labelInd CmmLit
_ = forall a. Maybe a
Nothing
, Just CLabel
ind' <- CmmLit -> Maybe CLabel
labelInd CmmLit
ind
, CLabel
alias CLabel -> CLabel -> Bool
`mayRedirectTo` CLabel
ind'
= forall doc. IsDoc doc => Platform -> CLabel -> doc
pprGloblDecl (NCGConfig -> Platform
ncgPlatform NCGConfig
config) CLabel
alias
forall doc. IsDoc doc => doc -> doc -> doc
$$ forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
text String
".equiv" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel (NCGConfig -> Platform
ncgPlatform NCGConfig
config) CLabel
alias forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel (NCGConfig -> Platform
ncgPlatform NCGConfig
config) CLabel
ind')
pprDatas NCGConfig
config (CmmStaticsRaw CLabel
lbl [CmmStatic]
dats)
= forall doc. IsDoc doc => [doc] -> doc
vcat (forall doc. IsDoc doc => Platform -> CLabel -> doc
pprLabel Platform
platform CLabel
lbl forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map (forall doc. IsDoc doc => NCGConfig -> CmmStatic -> doc
pprData NCGConfig
config) [CmmStatic]
dats)
where
platform :: Platform
platform = NCGConfig -> Platform
ncgPlatform NCGConfig
config
pprData :: IsDoc doc => NCGConfig -> CmmStatic -> doc
pprData :: forall doc. IsDoc doc => NCGConfig -> CmmStatic -> doc
pprData NCGConfig
_config (CmmString ByteString
str) = forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => ByteString -> doc
pprString ByteString
str)
pprData NCGConfig
_config (CmmFileEmbed String
path RegNo
_) = forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
pprFileEmbed String
path)
pprData NCGConfig
config (CmmUninitialised RegNo
bytes)
= forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ let platform :: Platform
platform = NCGConfig -> Platform
ncgPlatform NCGConfig
config
in if Platform -> OS
platformOS Platform
platform forall a. Eq a => a -> a -> Bool
== OS
OSDarwin
then forall doc. IsLine doc => String -> doc
text String
".space " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
bytes
else forall doc. IsLine doc => String -> doc
text String
".skip " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
bytes
pprData NCGConfig
config (CmmStaticLit CmmLit
lit) = forall doc. IsDoc doc => NCGConfig -> CmmLit -> doc
pprDataItem NCGConfig
config CmmLit
lit
pprGloblDecl :: IsDoc doc => Platform -> CLabel -> doc
pprGloblDecl :: forall doc. IsDoc doc => Platform -> CLabel -> doc
pprGloblDecl Platform
platform CLabel
lbl
| Bool -> Bool
not (CLabel -> Bool
externallyVisibleCLabel CLabel
lbl) = forall doc. IsOutput doc => doc
empty
| Bool
otherwise = forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
text String
"\t.globl " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl)
pprLabelType' :: IsLine doc => Platform -> CLabel -> doc
pprLabelType' :: forall doc. IsLine doc => Platform -> CLabel -> doc
pprLabelType' Platform
platform CLabel
lbl =
if CLabel -> Bool
isCFunctionLabel CLabel
lbl Bool -> Bool -> Bool
|| Bool
functionOkInfoTable then
forall doc. IsLine doc => String -> doc
text String
"@function"
else
forall doc. IsLine doc => String -> doc
text String
"@object"
where
functionOkInfoTable :: Bool
functionOkInfoTable = Platform -> Bool
platformTablesNextToCode Platform
platform Bool -> Bool -> Bool
&&
CLabel -> Bool
isInfoTableLabel CLabel
lbl Bool -> Bool -> Bool
&& Bool -> Bool
not (CLabel -> Bool
isCmmInfoTableLabel CLabel
lbl) Bool -> Bool -> Bool
&& Bool -> Bool
not (CLabel -> Bool
isConInfoTableLabel CLabel
lbl)
pprTypeDecl :: IsDoc doc => Platform -> CLabel -> doc
pprTypeDecl :: forall doc. IsDoc doc => Platform -> CLabel -> doc
pprTypeDecl Platform
platform CLabel
lbl
= if OS -> Bool
osElfTarget (Platform -> OS
platformOS Platform
platform) Bool -> Bool -> Bool
&& CLabel -> Bool
externallyVisibleCLabel CLabel
lbl
then forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
text String
".type " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => String -> doc
text String
", " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprLabelType' Platform
platform CLabel
lbl)
else forall doc. IsOutput doc => doc
empty
pprDataItem :: IsDoc doc => NCGConfig -> CmmLit -> doc
pprDataItem :: forall doc. IsDoc doc => NCGConfig -> CmmLit -> doc
pprDataItem NCGConfig
config CmmLit
lit
= forall doc. IsDoc doc => [Line doc] -> doc
lines_ (Format -> CmmLit -> [Line doc]
ppr_item (CmmType -> Format
cmmTypeFormat forall a b. (a -> b) -> a -> b
$ Platform -> CmmLit -> CmmType
cmmLitType Platform
platform CmmLit
lit) CmmLit
lit)
where
platform :: Platform
platform = NCGConfig -> Platform
ncgPlatform NCGConfig
config
imm :: Imm
imm = CmmLit -> Imm
litToImm CmmLit
lit
ppr_item :: Format -> CmmLit -> [Line doc]
ppr_item Format
II8 CmmLit
_ = [forall doc. IsLine doc => String -> doc
text String
"\t.byte\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
platform Imm
imm]
ppr_item Format
II16 CmmLit
_ = [forall doc. IsLine doc => String -> doc
text String
"\t.short\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
platform Imm
imm]
ppr_item Format
II32 CmmLit
_ = [forall doc. IsLine doc => String -> doc
text String
"\t.long\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
platform Imm
imm]
ppr_item Format
II64 CmmLit
_ = [forall doc. IsLine doc => String -> doc
text String
"\t.quad\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
platform Imm
imm]
ppr_item Format
FF32 (CmmFloat Rational
r Width
_)
= let bs :: [Word8]
bs = Float -> [Word8]
floatToBytes (forall a. Fractional a => Rational -> a
fromRational Rational
r)
in forall a b. (a -> b) -> [a] -> [b]
map (\Word8
b -> forall doc. IsLine doc => String -> doc
text String
"\t.byte\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
b)) [Word8]
bs
ppr_item Format
FF64 (CmmFloat Rational
r Width
_)
= let bs :: [Word8]
bs = Double -> [Word8]
doubleToBytes (forall a. Fractional a => Rational -> a
fromRational Rational
r)
in forall a b. (a -> b) -> [a] -> [b]
map (\Word8
b -> forall doc. IsLine doc => String -> doc
text String
"\t.byte\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
b)) [Word8]
bs
ppr_item Format
_ CmmLit
_ = forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"pprDataItem:ppr_item" (forall doc. IsLine doc => String -> doc
text forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show CmmLit
lit)
pprImm :: IsLine doc => Platform -> Imm -> doc
pprImm :: forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
_ (ImmInt RegNo
i) = forall doc. IsLine doc => RegNo -> doc
int RegNo
i
pprImm Platform
_ (ImmInteger Integer
i) = forall doc. IsLine doc => Integer -> doc
integer Integer
i
pprImm Platform
p (ImmCLbl CLabel
l) = forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
p CLabel
l
pprImm Platform
p (ImmIndex CLabel
l RegNo
i) = forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
p CLabel
l forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
'+' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
pprImm Platform
_ (ImmLit FastString
s) = forall doc. IsLine doc => FastString -> doc
ftext FastString
s
pprImm Platform
_ (ImmFloat Rational
f)
| Rational
f forall a. Eq a => a -> a -> Bool
== Rational
0 = forall doc. IsLine doc => String -> doc
text String
"wzr"
| Bool
otherwise = forall doc. IsLine doc => Float -> doc
float (forall a. Fractional a => Rational -> a
fromRational Rational
f)
pprImm Platform
_ (ImmDouble Rational
d)
| Rational
d forall a. Eq a => a -> a -> Bool
== Rational
0 = forall doc. IsLine doc => String -> doc
text String
"xzr"
| Bool
otherwise = forall doc. IsLine doc => Double -> doc
double (forall a. Fractional a => Rational -> a
fromRational Rational
d)
pprImm Platform
p (ImmConstantSum Imm
a Imm
b) = forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
p Imm
a forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
'+' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
p Imm
b
pprImm Platform
p (ImmConstantDiff Imm
a Imm
b) = forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
p Imm
a forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
'-'
forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
lparen forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
p Imm
b forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
rparen
asmComment :: SDoc -> SDoc
SDoc
c = forall doc. IsOutput doc => doc -> doc
whenPprDebug forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"#" forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
c
asmDoubleslashComment :: SDoc -> SDoc
SDoc
c = forall doc. IsOutput doc => doc -> doc
whenPprDebug forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"//" forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
c
asmMultilineComment :: SDoc -> SDoc
SDoc
c = forall doc. IsOutput doc => doc -> doc
whenPprDebug forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"/*" SDoc -> SDoc -> SDoc
$+$ SDoc
c SDoc -> SDoc -> SDoc
$+$ forall doc. IsLine doc => String -> doc
text String
"*/"
pprIm :: IsLine doc => Platform -> Imm -> doc
pprIm :: forall doc. IsLine doc => Platform -> Imm -> doc
pprIm Platform
platform Imm
im = case Imm
im of
ImmInt RegNo
i -> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
ImmInteger Integer
i -> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Integer -> doc
integer Integer
i
ImmFloat Rational
f | Rational
f forall a. Eq a => a -> a -> Bool
== Rational
0 -> forall doc. IsLine doc => String -> doc
text String
"wzr"
ImmFloat Rational
f -> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Float -> doc
float (forall a. Fractional a => Rational -> a
fromRational Rational
f)
ImmDouble Rational
d | Rational
d forall a. Eq a => a -> a -> Bool
== Rational
0 -> forall doc. IsLine doc => String -> doc
text String
"xzr"
ImmDouble Rational
d -> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Double -> doc
double (forall a. Fractional a => Rational -> a
fromRational Rational
d)
ImmCLbl CLabel
l -> forall doc. IsLine doc => Char -> doc
char Char
'=' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
l
ImmIndex CLabel
l RegNo
o -> forall doc. IsLine doc => String -> doc
text String
"[=" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
l forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
o forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
']'
Imm
_ -> forall a. HasCallStack => String -> a
panic String
"AArch64.pprIm"
pprExt :: IsLine doc => ExtMode -> doc
pprExt :: forall doc. IsLine doc => ExtMode -> doc
pprExt ExtMode
EUXTB = forall doc. IsLine doc => String -> doc
text String
"uxtb"
pprExt ExtMode
EUXTH = forall doc. IsLine doc => String -> doc
text String
"uxth"
pprExt ExtMode
EUXTW = forall doc. IsLine doc => String -> doc
text String
"uxtw"
pprExt ExtMode
EUXTX = forall doc. IsLine doc => String -> doc
text String
"uxtx"
pprExt ExtMode
ESXTB = forall doc. IsLine doc => String -> doc
text String
"sxtb"
pprExt ExtMode
ESXTH = forall doc. IsLine doc => String -> doc
text String
"sxth"
pprExt ExtMode
ESXTW = forall doc. IsLine doc => String -> doc
text String
"sxtw"
pprExt ExtMode
ESXTX = forall doc. IsLine doc => String -> doc
text String
"sxtx"
pprShift :: IsLine doc => ShiftMode -> doc
pprShift :: forall doc. IsLine doc => ShiftMode -> doc
pprShift ShiftMode
SLSL = forall doc. IsLine doc => String -> doc
text String
"lsl"
pprShift ShiftMode
SLSR = forall doc. IsLine doc => String -> doc
text String
"lsr"
pprShift ShiftMode
SASR = forall doc. IsLine doc => String -> doc
text String
"asr"
pprShift ShiftMode
SROR = forall doc. IsLine doc => String -> doc
text String
"ror"
pprOp :: IsLine doc => Platform -> Operand -> doc
pprOp :: forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
plat Operand
op = case Operand
op of
OpReg Width
w Reg
r -> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
w Reg
r
OpRegExt Width
w Reg
r ExtMode
x RegNo
0 -> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
w Reg
r forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => ExtMode -> doc
pprExt ExtMode
x
OpRegExt Width
w Reg
r ExtMode
x RegNo
i -> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
w Reg
r forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => ExtMode -> doc
pprExt ExtMode
x forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
OpRegShift Width
w Reg
r ShiftMode
s RegNo
i -> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
w Reg
r forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => ShiftMode -> doc
pprShift ShiftMode
s forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
OpImm Imm
im -> forall doc. IsLine doc => Platform -> Imm -> doc
pprIm Platform
plat Imm
im
OpImmShift Imm
im ShiftMode
s RegNo
i -> forall doc. IsLine doc => Platform -> Imm -> doc
pprIm Platform
plat Imm
im forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => ShiftMode -> doc
pprShift ShiftMode
s forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
OpAddr (AddrRegReg Reg
r1 Reg
r2) -> forall doc. IsLine doc => Char -> doc
char Char
'[' forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
W64 Reg
r1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
W64 Reg
r2 forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
']'
OpAddr (AddrRegImm Reg
r1 Imm
im) -> forall doc. IsLine doc => Char -> doc
char Char
'[' forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
W64 Reg
r1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Imm -> doc
pprImm Platform
plat Imm
im forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
']'
OpAddr (AddrReg Reg
r1) -> forall doc. IsLine doc => Char -> doc
char Char
'[' forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
W64 Reg
r1 forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Char -> doc
char Char
']'
pprReg :: forall doc. IsLine doc => Width -> Reg -> doc
pprReg :: forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
w Reg
r = case Reg
r of
RegReal (RealRegSingle RegNo
i) -> Width -> RegNo -> doc
ppr_reg_no Width
w RegNo
i
RegVirtual (VirtualRegI Unique
u) -> forall doc. IsLine doc => String -> doc
text String
"%vI_" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Unique -> doc
pprUniqueAlways Unique
u
RegVirtual (VirtualRegF Unique
u) -> forall doc. IsLine doc => String -> doc
text String
"%vF_" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Unique -> doc
pprUniqueAlways Unique
u
RegVirtual (VirtualRegD Unique
u) -> forall doc. IsLine doc => String -> doc
text String
"%vD_" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Unique -> doc
pprUniqueAlways Unique
u
Reg
_ -> forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"AArch64.pprReg" (forall doc. IsLine doc => String -> doc
text forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Reg
r)
where
ppr_reg_no :: Width -> Int -> doc
ppr_reg_no :: Width -> RegNo -> doc
ppr_reg_no Width
w RegNo
31
| Width
w forall a. Eq a => a -> a -> Bool
== Width
W64 = forall doc. IsLine doc => String -> doc
text String
"sp"
| Width
w forall a. Eq a => a -> a -> Bool
== Width
W32 = forall doc. IsLine doc => String -> doc
text String
"wsp"
ppr_reg_no Width
w RegNo
i
| RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
0, Width
w forall a. Eq a => a -> a -> Bool
== Width
W32 = forall doc. IsLine doc => String -> doc
text String
"wzr"
| RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
0, Width
w forall a. Eq a => a -> a -> Bool
== Width
W64 = forall doc. IsLine doc => String -> doc
text String
"xzr"
| RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
0 = forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"Invalid Zero Reg" (forall a. Outputable a => a -> SDoc
ppr Width
w forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => RegNo -> doc
int RegNo
i)
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
31, Width
w forall a. Eq a => a -> a -> Bool
== Width
W8 = forall doc. IsLine doc => String -> doc
text String
"w" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
31, Width
w forall a. Eq a => a -> a -> Bool
== Width
W16 = forall doc. IsLine doc => String -> doc
text String
"w" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
31, Width
w forall a. Eq a => a -> a -> Bool
== Width
W32 = forall doc. IsLine doc => String -> doc
text String
"w" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
31, Width
w forall a. Eq a => a -> a -> Bool
== Width
W64 = forall doc. IsLine doc => String -> doc
text String
"x" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
i
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
31 = forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"Invalid Reg" (forall a. Outputable a => a -> SDoc
ppr Width
w forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => RegNo -> doc
int RegNo
i)
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
63, Width
w forall a. Eq a => a -> a -> Bool
== Width
W8 = forall doc. IsLine doc => String -> doc
text String
"b" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (RegNo
iforall a. Num a => a -> a -> a
-RegNo
32)
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
63, Width
w forall a. Eq a => a -> a -> Bool
== Width
W16 = forall doc. IsLine doc => String -> doc
text String
"h" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (RegNo
iforall a. Num a => a -> a -> a
-RegNo
32)
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
63, Width
w forall a. Eq a => a -> a -> Bool
== Width
W32 = forall doc. IsLine doc => String -> doc
text String
"s" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (RegNo
iforall a. Num a => a -> a -> a
-RegNo
32)
| RegNo
i forall a. Ord a => a -> a -> Bool
<= RegNo
63, Width
w forall a. Eq a => a -> a -> Bool
== Width
W64 = forall doc. IsLine doc => String -> doc
text String
"d" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int (RegNo
iforall a. Num a => a -> a -> a
-RegNo
32)
| Bool
otherwise = forall doc. IsLine doc => String -> doc
text String
"very naughty powerpc register"
isFloatOp :: Operand -> Bool
isFloatOp :: Operand -> Bool
isFloatOp (OpReg Width
_ (RegReal (RealRegSingle RegNo
i))) | RegNo
i forall a. Ord a => a -> a -> Bool
> RegNo
31 = Bool
True
isFloatOp (OpReg Width
_ (RegVirtual (VirtualRegF Unique
_))) = Bool
True
isFloatOp (OpReg Width
_ (RegVirtual (VirtualRegD Unique
_))) = Bool
True
isFloatOp Operand
_ = Bool
False
pprInstr :: IsDoc doc => Platform -> Instr -> doc
pprInstr :: forall doc. IsDoc doc => Platform -> Instr -> doc
pprInstr Platform
platform Instr
instr = case Instr
instr of
COMMENT SDoc
s -> forall doc. IsDoc doc => SDoc -> HDoc -> doc
dualDoc (SDoc -> SDoc
asmComment SDoc
s) forall doc. IsOutput doc => doc
empty
MULTILINE_COMMENT SDoc
s -> forall doc. IsDoc doc => SDoc -> HDoc -> doc
dualDoc (SDoc -> SDoc
asmMultilineComment SDoc
s) forall doc. IsOutput doc => doc
empty
ANN SDoc
d Instr
i -> forall doc. IsDoc doc => SDoc -> HDoc -> doc
dualDoc (forall doc. IsDoc doc => Platform -> Instr -> doc
pprInstr Platform
platform Instr
i forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
asmDoubleslashComment SDoc
d) (forall doc. IsDoc doc => Platform -> Instr -> doc
pprInstr Platform
platform Instr
i)
LOCATION RegNo
file RegNo
line' RegNo
col String
_name
-> forall doc. IsDoc doc => Line doc -> doc
line (forall doc. IsLine doc => String -> doc
text String
"\t.loc" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => RegNo -> doc
int RegNo
file forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => RegNo -> doc
int RegNo
line' forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => RegNo -> doc
int RegNo
col)
DELTA RegNo
d -> forall doc. IsDoc doc => SDoc -> HDoc -> doc
dualDoc (SDoc -> SDoc
asmComment forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tdelta = " forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
d) forall doc. IsOutput doc => doc
empty
NEWBLOCK BlockId
_ -> forall a. HasCallStack => String -> a
panic String
"PprInstr: NEWBLOCK"
LDATA Section
_ RawCmmStatics
_ -> forall a. HasCallStack => String -> a
panic String
"pprInstr: LDATA"
Instr
PUSH_STACK_FRAME -> forall doc. IsDoc doc => [Line doc] -> doc
lines_ [forall doc. IsLine doc => String -> doc
text String
"\tstp x29, x30, [sp, #-16]!",
forall doc. IsLine doc => String -> doc
text String
"\tmov x29, sp"]
Instr
POP_STACK_FRAME -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tldp x29, x30, [sp], #16"
ADD Operand
o1 Operand
o2 Operand
o3
| Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o2 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tfadd") Operand
o1 Operand
o2 Operand
o3
| Bool
otherwise -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tadd") Operand
o1 Operand
o2 Operand
o3
CMN Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tcmn") Operand
o1 Operand
o2
CMP Operand
o1 Operand
o2
| Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tfcmp") Operand
o1 Operand
o2
| Bool
otherwise -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tcmp") Operand
o1 Operand
o2
MSUB Operand
o1 Operand
o2 Operand
o3 Operand
o4 -> Line doc -> Operand -> Operand -> Operand -> Operand -> doc
op4 (forall doc. IsLine doc => String -> doc
text String
"\tmsub") Operand
o1 Operand
o2 Operand
o3 Operand
o4
MUL Operand
o1 Operand
o2 Operand
o3
| Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o2 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tfmul") Operand
o1 Operand
o2 Operand
o3
| Bool
otherwise -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tmul") Operand
o1 Operand
o2 Operand
o3
SMULH Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tsmulh") Operand
o1 Operand
o2 Operand
o3
SMULL Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tsmull") Operand
o1 Operand
o2 Operand
o3
NEG Operand
o1 Operand
o2
| Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tfneg") Operand
o1 Operand
o2
| Bool
otherwise -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tneg") Operand
o1 Operand
o2
SDIV Operand
o1 Operand
o2 Operand
o3 | Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o2 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o3
-> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tfdiv") Operand
o1 Operand
o2 Operand
o3
SDIV Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tsdiv") Operand
o1 Operand
o2 Operand
o3
SUB Operand
o1 Operand
o2 Operand
o3
| Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o2 Bool -> Bool -> Bool
&& Operand -> Bool
isFloatOp Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tfsub") Operand
o1 Operand
o2 Operand
o3
| Bool
otherwise -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tsub") Operand
o1 Operand
o2 Operand
o3
UDIV Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tudiv") Operand
o1 Operand
o2 Operand
o3
SBFM Operand
o1 Operand
o2 Operand
o3 Operand
o4 -> Line doc -> Operand -> Operand -> Operand -> Operand -> doc
op4 (forall doc. IsLine doc => String -> doc
text String
"\tsbfm") Operand
o1 Operand
o2 Operand
o3 Operand
o4
UBFM Operand
o1 Operand
o2 Operand
o3 Operand
o4 -> Line doc -> Operand -> Operand -> Operand -> Operand -> doc
op4 (forall doc. IsLine doc => String -> doc
text String
"\tubfm") Operand
o1 Operand
o2 Operand
o3 Operand
o4
SBFX Operand
o1 Operand
o2 Operand
o3 Operand
o4 -> Line doc -> Operand -> Operand -> Operand -> Operand -> doc
op4 (forall doc. IsLine doc => String -> doc
text String
"\tsbfx") Operand
o1 Operand
o2 Operand
o3 Operand
o4
UBFX Operand
o1 Operand
o2 Operand
o3 Operand
o4 -> Line doc -> Operand -> Operand -> Operand -> Operand -> doc
op4 (forall doc. IsLine doc => String -> doc
text String
"\tubfx") Operand
o1 Operand
o2 Operand
o3 Operand
o4
SXTB Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tsxtb") Operand
o1 Operand
o2
UXTB Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tuxtb") Operand
o1 Operand
o2
SXTH Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tsxth") Operand
o1 Operand
o2
UXTH Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tuxth") Operand
o1 Operand
o2
AND Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tand") Operand
o1 Operand
o2 Operand
o3
ANDS Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tands") Operand
o1 Operand
o2 Operand
o3
ASR Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tasr") Operand
o1 Operand
o2 Operand
o3
BIC Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tbic") Operand
o1 Operand
o2 Operand
o3
BICS Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tbics") Operand
o1 Operand
o2 Operand
o3
EON Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\teon") Operand
o1 Operand
o2 Operand
o3
EOR Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\teor") Operand
o1 Operand
o2 Operand
o3
LSL Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tlsl") Operand
o1 Operand
o2 Operand
o3
LSR Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tlsr") Operand
o1 Operand
o2 Operand
o3
MOV Operand
o1 Operand
o2
| Operand -> Bool
isFloatOp Operand
o1 Bool -> Bool -> Bool
|| Operand -> Bool
isFloatOp Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tfmov") Operand
o1 Operand
o2
| Bool
otherwise -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tmov") Operand
o1 Operand
o2
MOVK Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tmovk") Operand
o1 Operand
o2
MVN Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tmvn") Operand
o1 Operand
o2
ORN Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\torn") Operand
o1 Operand
o2 Operand
o3
ORR Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\torr") Operand
o1 Operand
o2 Operand
o3
ROR Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tror") Operand
o1 Operand
o2 Operand
o3
TST Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\ttst") Operand
o1 Operand
o2
J Target
t -> forall doc. IsDoc doc => Platform -> Instr -> doc
pprInstr Platform
platform (Target -> Instr
B Target
t)
B (TBlock BlockId
bid) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tb" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (Unique -> CLabel
mkLocalBlockLabel (forall a. Uniquable a => a -> Unique
getUnique BlockId
bid))
B (TLabel CLabel
lbl) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tb" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl
B (TReg Reg
r) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tbr" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
W64 Reg
r
BL (TBlock BlockId
bid) [Reg]
_ [Reg]
_ -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tbl" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (Unique -> CLabel
mkLocalBlockLabel (forall a. Uniquable a => a -> Unique
getUnique BlockId
bid))
BL (TLabel CLabel
lbl) [Reg]
_ [Reg]
_ -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tbl" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl
BL (TReg Reg
r) [Reg]
_ [Reg]
_ -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tblr" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Width -> Reg -> doc
pprReg Width
W64 Reg
r
BCOND Cond
c (TBlock BlockId
bid) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Cond -> doc
pprBcond Cond
c forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (Unique -> CLabel
mkLocalBlockLabel (forall a. Uniquable a => a -> Unique
getUnique BlockId
bid))
BCOND Cond
c (TLabel CLabel
lbl) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\t" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Cond -> doc
pprBcond Cond
c forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl
BCOND Cond
_ (TReg Reg
_) -> forall a. HasCallStack => String -> a
panic String
"AArch64.ppr: No conditional branching to registers!"
CSET Operand
o Cond
c -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tcset" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Cond -> doc
pprCond Cond
c
CBZ Operand
o (TBlock BlockId
bid) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tcbz" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (Unique -> CLabel
mkLocalBlockLabel (forall a. Uniquable a => a -> Unique
getUnique BlockId
bid))
CBZ Operand
o (TLabel CLabel
lbl) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tcbz" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl
CBZ Operand
_ (TReg Reg
_) -> forall a. HasCallStack => String -> a
panic String
"AArch64.ppr: No conditional (cbz) branching to registers!"
CBNZ Operand
o (TBlock BlockId
bid) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tcbnz" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform (Unique -> CLabel
mkLocalBlockLabel (forall a. Uniquable a => a -> Unique
getUnique BlockId
bid))
CBNZ Operand
o (TLabel CLabel
lbl) -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tcbnz" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl
CBNZ Operand
_ (TReg Reg
_) -> forall a. HasCallStack => String -> a
panic String
"AArch64.ppr: No conditional (cbnz) branching to registers!"
STR Format
_f o1 :: Operand
o1@(OpReg Width
W8 (RegReal (RealRegSingle RegNo
i))) Operand
o2 | RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
32 ->
Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tstrb") Operand
o1 Operand
o2
STR Format
_f o1 :: Operand
o1@(OpReg Width
W16 (RegReal (RealRegSingle RegNo
i))) Operand
o2 | RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
32 ->
Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tstrh") Operand
o1 Operand
o2
STR Format
_f Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tstr") Operand
o1 Operand
o2
STLR Format
_f Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tstlr") Operand
o1 Operand
o2
#if defined(darwin_HOST_OS)
LDR _f o1 (OpImm (ImmIndex lbl' off)) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' ->
op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$
op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") $$
op_add o1 (char '#' <> int off)
LDR _f o1 (OpImm (ImmIndex lbl off)) | isForeignLabel lbl ->
op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$
op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") $$
op_add o1 (char '#' <> int off)
LDR _f o1 (OpImm (ImmIndex lbl off)) ->
op_adrp o1 (pprAsmLabel platform lbl <> text "@page") $$
op_add o1 (pprAsmLabel platform lbl <> text "@pageoff") $$
op_add o1 (char '#' <> int off)
LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' ->
op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$
op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff")
LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl ->
op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$
op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff")
LDR _f o1 (OpImm (ImmCLbl lbl)) ->
op_adrp o1 (pprAsmLabel platform lbl <> text "@page") $$
op_add o1 (pprAsmLabel platform lbl <> text "@pageoff")
#else
LDR Format
_f Operand
o1 (OpImm (ImmIndex CLabel
lbl' RegNo
off)) | Just (DynamicLinkerLabelInfo
_info, CLabel
lbl) <- CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
dynamicLinkerLabelInfo CLabel
lbl' ->
Operand -> Line doc -> doc
op_adrp Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_ldr Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got_lo12:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_add Operand
o1 (forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
off)
LDR Format
_f Operand
o1 (OpImm (ImmIndex CLabel
lbl RegNo
off)) | CLabel -> Bool
isForeignLabel CLabel
lbl ->
Operand -> Line doc -> doc
op_adrp Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_ldr Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got_lo12:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_add Operand
o1 (forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
off)
LDR Format
_f Operand
o1 (OpImm (ImmIndex CLabel
lbl RegNo
off)) ->
Operand -> Line doc -> doc
op_adrp Operand
o1 (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_add Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":lo12:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_add Operand
o1 (forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => RegNo -> doc
int RegNo
off)
LDR Format
_f Operand
o1 (OpImm (ImmCLbl CLabel
lbl')) | Just (DynamicLinkerLabelInfo
_info, CLabel
lbl) <- CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
dynamicLinkerLabelInfo CLabel
lbl' ->
Operand -> Line doc -> doc
op_adrp Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_ldr Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got_lo12:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl)
LDR Format
_f Operand
o1 (OpImm (ImmCLbl CLabel
lbl)) | CLabel -> Bool
isForeignLabel CLabel
lbl ->
Operand -> Line doc -> doc
op_adrp Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_ldr Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":got_lo12:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl)
LDR Format
_f Operand
o1 (OpImm (ImmCLbl CLabel
lbl)) ->
Operand -> Line doc -> doc
op_adrp Operand
o1 (forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl) forall doc. IsDoc doc => doc -> doc -> doc
$$
Operand -> Line doc -> doc
op_add Operand
o1 (forall doc. IsLine doc => String -> doc
text String
":lo12:" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> CLabel -> doc
pprAsmLabel Platform
platform CLabel
lbl)
#endif
LDR Format
_f o1 :: Operand
o1@(OpReg Width
W8 (RegReal (RealRegSingle RegNo
i))) Operand
o2 | RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
32 ->
Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tldrb") Operand
o1 Operand
o2
LDR Format
_f o1 :: Operand
o1@(OpReg Width
W16 (RegReal (RealRegSingle RegNo
i))) Operand
o2 | RegNo
i forall a. Ord a => a -> a -> Bool
< RegNo
32 ->
Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tldrh") Operand
o1 Operand
o2
LDR Format
_f Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tldr") Operand
o1 Operand
o2
LDAR Format
_f Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tldar") Operand
o1 Operand
o2
STP Format
_f Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tstp") Operand
o1 Operand
o2 Operand
o3
LDP Format
_f Operand
o1 Operand
o2 Operand
o3 -> Line doc -> Operand -> Operand -> Operand -> doc
op3 (forall doc. IsLine doc => String -> doc
text String
"\tldp") Operand
o1 Operand
o2 Operand
o3
Instr
DMBSY -> forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tdmb sy"
FCVT Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tfcvt") Operand
o1 Operand
o2
SCVTF Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tscvtf") Operand
o1 Operand
o2
FCVTZS Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tfcvtzs") Operand
o1 Operand
o2
FABS Operand
o1 Operand
o2 -> Line doc -> Operand -> Operand -> doc
op2 (forall doc. IsLine doc => String -> doc
text String
"\tfabs") Operand
o1 Operand
o2
where op2 :: Line doc -> Operand -> Operand -> doc
op2 Line doc
op Operand
o1 Operand
o2 = forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ Line doc
op forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o2
op3 :: Line doc -> Operand -> Operand -> Operand -> doc
op3 Line doc
op Operand
o1 Operand
o2 Operand
o3 = forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ Line doc
op forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o2 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o3
op4 :: Line doc -> Operand -> Operand -> Operand -> Operand -> doc
op4 Line doc
op Operand
o1 Operand
o2 Operand
o3 Operand
o4 = forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ Line doc
op forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o2 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o3 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o4
op_ldr :: Operand -> Line doc -> doc
op_ldr Operand
o1 Line doc
rest = forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tldr" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"[" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> Line doc
rest forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => String -> doc
text String
"]"
op_adrp :: Operand -> Line doc -> doc
op_adrp Operand
o1 Line doc
rest = forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tadrp" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> Line doc
rest
op_add :: Operand -> Line doc -> doc
op_add Operand
o1 Line doc
rest = forall doc. IsDoc doc => Line doc -> doc
line forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\tadd" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Platform -> Operand -> doc
pprOp Platform
platform Operand
o1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
comma forall doc. IsLine doc => doc -> doc -> doc
<+> Line doc
rest
pprBcond :: IsLine doc => Cond -> doc
pprBcond :: forall doc. IsLine doc => Cond -> doc
pprBcond Cond
c = forall doc. IsLine doc => String -> doc
text String
"b." forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Cond -> doc
pprCond Cond
c
pprCond :: IsLine doc => Cond -> doc
pprCond :: forall doc. IsLine doc => Cond -> doc
pprCond Cond
c = case Cond
c of
Cond
ALWAYS -> forall doc. IsLine doc => String -> doc
text String
"al"
Cond
EQ -> forall doc. IsLine doc => String -> doc
text String
"eq"
Cond
NE -> forall doc. IsLine doc => String -> doc
text String
"ne"
Cond
SLT -> forall doc. IsLine doc => String -> doc
text String
"lt"
Cond
SLE -> forall doc. IsLine doc => String -> doc
text String
"le"
Cond
SGE -> forall doc. IsLine doc => String -> doc
text String
"ge"
Cond
SGT -> forall doc. IsLine doc => String -> doc
text String
"gt"
Cond
ULT -> forall doc. IsLine doc => String -> doc
text String
"lo"
Cond
ULE -> forall doc. IsLine doc => String -> doc
text String
"ls"
Cond
UGE -> forall doc. IsLine doc => String -> doc
text String
"hs"
Cond
UGT -> forall doc. IsLine doc => String -> doc
text String
"hi"
Cond
NEVER -> forall doc. IsLine doc => String -> doc
text String
"nv"
Cond
VS -> forall doc. IsLine doc => String -> doc
text String
"vs"
Cond
VC -> forall doc. IsLine doc => String -> doc
text String
"vc"
Cond
OLT -> forall doc. IsLine doc => String -> doc
text String
"mi"
Cond
OLE -> forall doc. IsLine doc => String -> doc
text String
"ls"
Cond
OGE -> forall doc. IsLine doc => String -> doc
text String
"ge"
Cond
OGT -> forall doc. IsLine doc => String -> doc
text String
"gt"
Cond
UOLT -> forall doc. IsLine doc => String -> doc
text String
"lt"
Cond
UOLE -> forall doc. IsLine doc => String -> doc
text String
"le"
Cond
UOGE -> forall doc. IsLine doc => String -> doc
text String
"pl"
Cond
UOGT -> forall doc. IsLine doc => String -> doc
text String
"hi"