-- string argument is the name of a symbol. This literal
-- refers to the *address* of the label.
| MachLabel FastString -- always an Addr#
+ (Maybe Int) -- the size (in bytes) of the arguments
+ -- the label expects. Only applicable with
+ -- 'stdcall' labels.
+ -- Just x => "@<x>" will be appended to label
+ -- name when emitting asm.
-- lit-lits only work for via-C compilation, hence they
-- are deprecated. The string is emitted verbatim into
put_ bh (MachWord64 ag) = do putByte bh 6; put_ bh ag
put_ bh (MachFloat ah) = do putByte bh 7; put_ bh ah
put_ bh (MachDouble ai) = do putByte bh 8; put_ bh ai
- put_ bh (MachLabel aj) = do putByte bh 9; put_ bh aj
+ put_ bh (MachLabel aj mb) = do putByte bh 9; put_ bh aj ; put_ bh mb
put_ bh (MachLitLit ak _) = do putByte bh 10; put_ bh ak
get bh = do
h <- getByte bh
return (MachDouble ai)
9 -> do
aj <- get bh
- return (MachLabel aj)
+ mb <- get bh
+ return (MachLabel aj mb)
10 -> do
ak <- get bh
return (MachLitLit ak (error "MachLitLit: no type"))
literalType (MachWord64 _) = word64PrimTy
literalType (MachFloat _) = floatPrimTy
literalType (MachDouble _) = doublePrimTy
-literalType (MachLabel _) = addrPrimTy
+literalType (MachLabel _ _) = addrPrimTy
literalType (MachLitLit _ ty) = ty
\end{code}
literalPrimRep (MachWord64 _) = Word64Rep
literalPrimRep (MachFloat _) = FloatRep
literalPrimRep (MachDouble _) = DoubleRep
-literalPrimRep (MachLabel _) = AddrRep
+literalPrimRep (MachLabel _ _) = AddrRep
literalPrimRep (MachLitLit _ ty) = typePrimRep ty
\end{code}
cmpLit (MachWord64 a) (MachWord64 b) = a `compare` b
cmpLit (MachFloat a) (MachFloat b) = a `compare` b
cmpLit (MachDouble a) (MachDouble b) = a `compare` b
-cmpLit (MachLabel a) (MachLabel b) = a `compare` b
+cmpLit (MachLabel a _) (MachLabel b _) = a `compare` b
cmpLit (MachLitLit a b) (MachLitLit c d) = (a `compare` c) `thenCmp` (b `tcCmpType` d)
cmpLit lit1 lit2 | litTag lit1 <# litTag lit2 = LT
| otherwise = GT
litTag (MachWord64 _) = _ILIT(7)
litTag (MachFloat _) = _ILIT(8)
litTag (MachDouble _) = _ILIT(9)
-litTag (MachLabel _) = _ILIT(10)
-litTag (MachLitLit _ _) = _ILIT(11)
+litTag (MachLabel _ _) = _ILIT(10)
+litTag (MachLitLit _ _) = _ILIT(11)
\end{code}
Printing
MachAddr p | code_style -> ptext SLIT("(void*)") <> integer p
| otherwise -> ptext SLIT("__addr") <+> integer p
- MachLabel l | code_style -> ptext SLIT("(&") <> ftext l <> char ')'
- | otherwise -> ptext SLIT("__label") <+> pprHsString l
+ MachLabel l mb
+ | code_style -> ptext SLIT("(&") <> ftext l <> char ')'
+ | otherwise -> ptext SLIT("__label") <+>
+ case mb of
+ Nothing -> pprHsString l
+ Just x -> doubleQuotes (text (unpackFS l ++ '@':show x))
MachLitLit s ty | code_style -> ftext s
| otherwise -> parens (hsep [ptext SLIT("__litlit"),
hashLiteral (MachWord64 i) = hashInteger i
hashLiteral (MachFloat r) = hashRational r
hashLiteral (MachDouble r) = hashRational r
-hashLiteral (MachLabel s) = hashFS s
+hashLiteral (MachLabel s _) = hashFS s
hashLiteral (MachLitLit s _) = hashFS s
hashRational :: Rational -> Int