From: simonmar Date: Fri, 19 May 2000 09:29:08 +0000 (+0000) Subject: [project @ 2000-05-19 09:29:08 by simonmar] X-Git-Tag: Approximately_9120_patches~4427 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=41f24fe983e9c10b8e900c97e6f61e44c5d572d8;p=ghc-hetmet.git [project @ 2000-05-19 09:29:08 by simonmar] Fix type casts w/ CIndex assignments. Should eliminate some warnings in via-C compilations. --- diff --git a/ghc/compiler/absCSyn/PprAbsC.lhs b/ghc/compiler/absCSyn/PprAbsC.lhs index c90b9b4..57135be 100644 --- a/ghc/compiler/absCSyn/PprAbsC.lhs +++ b/ghc/compiler/absCSyn/PprAbsC.lhs @@ -1108,6 +1108,29 @@ pprAmode amode = ppr_amode amode \end{code} +When we have an indirection through a CIndex, we have to be careful to +get the type casts right. + +this amode: + + CVal (CIndex kind1 base offset) kind2 + +means (in C speak): + + *(kind2 *)((kind1 *)base + offset) + +That is, the indexing is done in units of kind1, but the resulting +amode has kind2. + +\begin{code} +ppr_amode (CVal reg_rel@(CIndex _ _ _) kind) + = case (pprRegRelative False{-no sign wanted-} reg_rel) of + (pp_reg, Nothing) -> panic "ppr_amode: CIndex" + (pp_reg, Just offset) -> + hcat [ char '*', parens (pprPrimKind kind <> char '*'), + parens (pp_reg <> char '+' <> offset) ] +\end{code} + Now the rest of the cases for ``workhorse'' @ppr_amode@: \begin{code}