X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FPprC.hs;h=d1536bff9c63aeac6d25d6126f93e28b81a892a3;hb=3548802de235eca280982270463db84910ee3748;hp=62bdb314046ef2fcb0021bae8b1fb4592dd6d204;hpb=58546748b9659f59dfdc3a917b1b64ceacc5496d;p=ghc-hetmet.git diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index 62bdb31..d1536bf 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -60,6 +60,10 @@ import Control.Monad.ST import StaticFlags ( opt_Unregisterised ) #endif +#if defined(alpha_TARGET_ARCH) || defined(mips_TARGET_ARCH) || defined(mipsel_TARGET_ARCH) || defined(arm_TARGET_ARCH) +#define BEWARE_LOAD_STORE_ALIGNMENT +#endif + -- -------------------------------------------------------------------------- -- Top level @@ -325,7 +329,7 @@ pprExpr e = case e of CmmLoad expr rep -> -- the general case: - char '*' <> parens (cCast (machRepPtrCType rep) expr) + cLoad expr rep CmmReg reg -> pprCastReg reg CmmRegOff reg 0 -> pprCastReg reg @@ -879,6 +883,18 @@ te_Reg _ = return () cCast :: SDoc -> CmmExpr -> SDoc cCast ty expr = parens ty <> pprExpr1 expr +cLoad :: CmmExpr -> MachRep -> SDoc +#ifdef BEWARE_LOAD_STORE_ALIGNMENT +cLoad expr rep = + let decl = machRepCType rep <+> ptext SLIT("x") <> semi + struct = ptext SLIT("struct") <+> braces (decl) + packed_attr = ptext SLIT("__attribute__((packed))") + cast = parens (struct <+> packed_attr <> char '*') + in parens (cast <+> pprExpr1 expr) <> ptext SLIT("->x") +#else +cLoad expr rep = char '*' <> parens (cCast (machRepPtrCType rep) expr) +#endif + -- This is for finding the types of foreign call arguments. For a pointer -- argument, we always cast the argument to (void *), to avoid warnings from -- the C compiler.