Package: ghc / 8.0.1-17

fix-ppc-lwa-generation Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From ce3370e06165690e79a8eb22e5229b515157e00f Mon Sep 17 00:00:00 2001
From: Peter Trommler <ptrommler@acm.org>
Date: Sat, 1 Oct 2016 17:56:31 -0400
Subject: [PATCH] PPC/CodeGen: fix lwa instruction generation

Opcode lwa is a 64-bit opcode and allows a DS-form only.  This patch
generates lwa opcodes only when the offset is a multiple of 4.

Fixes #12621

Test Plan: validate

Reviewers: erikd, hvr, simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2547

GHC Trac Issues: #12621
---
 compiler/nativeGen/PPC/CodeGen.hs | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

--- a/compiler/nativeGen/PPC/CodeGen.hs
+++ b/compiler/nativeGen/PPC/CodeGen.hs
@@ -9,9 +9,8 @@
 -----------------------------------------------------------------------------
 
 -- This is a big module, but, if you pay attention to
--- (a) the sectioning, (b) the type signatures, and
--- (c) the #if blah_TARGET_ARCH} things, the
--- structure should not be too overwhelming.
+-- (a) the sectioning, and (b) the type signatures,
+-- the structure should not be too overwhelming.
 
 module PPC.CodeGen (
         cmmTopCodeGen,
@@ -471,7 +470,8 @@
     return (Any II64 (\dst -> addr_code `snocOL` LD II32 dst addr))
 
 getRegister' _ (CmmMachOp (MO_SS_Conv W32 W64) [CmmLoad mem _]) = do
-    Amode addr addr_code <- getAmode D mem
+    -- lwa is DS-form. See Note [Power instruction format]
+    Amode addr addr_code <- getAmode DS mem
     return (Any II64 (\dst -> addr_code `snocOL` LA II32 dst addr))
 
 getRegister' dflags (CmmMachOp mop [x]) -- unary MachOps
@@ -733,6 +733,14 @@
     ... (tmp) ...
 -}
 
+{- Note [Power instruction format]
+In some instructions the 16 bit offset must be a multiple of 4, i.e.
+the two least significant bits mus be zero. The "Power ISA" specification
+calls these instruction formats "DS-FORM" and the instructions with
+arbitrary 16 bit offsets are "D-FORM".
+
+The Power ISA specification document can be obtained from www.power.org.
+-}
 data InstrForm = D | DS
 
 getAmode :: InstrForm -> CmmExpr -> NatM Amode