@@ -26,7 +26,7 @@ index 1d489178673..a251370bfaf 100644
26
26
+++ b/compiler/GHC/CmmToAsm.hs
27
27
@@ -655,13 +655,14 @@ cmmNativeGen logger ncgImpl us fileIds dbgMap cmm count
28
28
text "cfg not in lockstep") ()
29
-
29
+
30
30
---- sequence blocks
31
31
- let sequenced :: [NatCmmDecl statics instr]
32
32
- sequenced =
@@ -43,20 +43,20 @@ index 1d489178673..a251370bfaf 100644
43
43
+ shorted
44
44
+
45
45
+ -- massert (checkLayout shorted sequenced)
46
-
46
+
47
47
let branchOpt :: [NatCmmDecl statics instr]
48
48
branchOpt =
49
49
@@ -684,7 +685,7 @@ cmmNativeGen logger ncgImpl us fileIds dbgMap cmm count
50
50
addUnwind acc proc =
51
51
acc `mapUnion` computeUnwinding config ncgImpl proc
52
-
52
+
53
53
- return ( usAlloc
54
54
+ return ( us_seq
55
55
, fileIds'
56
56
, branchOpt
57
57
, lastMinuteImports ++ imports
58
58
@@ -704,10 +705,10 @@ maybeDumpCfg logger (Just cfg) msg proc_name
59
-
59
+
60
60
-- | Make sure all blocks we want the layout algorithm to place have been placed.
61
61
checkLayout :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr]
62
62
- -> [NatCmmDecl statics instr]
@@ -94,7 +94,7 @@ index b77aa73e52b..2a1fa03b1bc 100644
94
94
, generateJumpTableForInstr
95
95
+ , makeFarBranches
96
96
)
97
-
97
+
98
98
where
99
99
@@ -43,9 +44,11 @@ import GHC.Cmm.Utils
100
100
import GHC.Cmm.Switch
@@ -105,7 +105,7 @@ index b77aa73e52b..2a1fa03b1bc 100644
105
105
import GHC.Types.Tickish ( GenTickish(..) )
106
106
import GHC.Types.SrcLoc ( srcSpanFile, srcSpanStartLine, srcSpanStartCol )
107
107
+ import GHC.Types.Unique.Supply
108
-
108
+
109
109
-- The rest:
110
110
import GHC.Data.OrdList
111
111
@@ -61,6 +64,9 @@ import GHC.Data.FastString
@@ -115,21 +115,21 @@ index b77aa73e52b..2a1fa03b1bc 100644
115
115
+ import GHC.Utils.Monad (mapAccumLM)
116
116
+
117
117
+ import GHC.Cmm.Dataflow.Collections
118
-
118
+
119
119
-- Note [General layout of an NCG]
120
120
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121
121
@@ -161,15 +167,17 @@ basicBlockCodeGen block = do
122
122
let
123
123
(top,other_blocks,statics) = foldrOL mkBlocks ([],[],[]) instrs
124
-
124
+
125
125
- mkBlocks (NEWBLOCK id) (instrs,blocks,statics)
126
126
- = ([], BasicBlock id instrs : blocks, statics)
127
127
- mkBlocks (LDATA sec dat) (instrs,blocks,statics)
128
128
- = (instrs, blocks, CmmData sec dat:statics)
129
129
- mkBlocks instr (instrs,blocks,statics)
130
130
- = (instr:instrs, blocks, statics)
131
131
return (BasicBlock id top : other_blocks, statics)
132
-
132
+
133
133
-
134
134
+ mkBlocks :: Instr
135
135
+ -> ([Instr], [GenBasicBlock Instr], [GenCmmDecl RawCmmStatics h g])
@@ -144,7 +144,7 @@ index b77aa73e52b..2a1fa03b1bc 100644
144
144
-- | Utilities
145
145
ann :: SDoc -> Instr -> Instr
146
146
@@ -1217,6 +1225,7 @@ assignReg_FltCode = assignReg_IntCode
147
-
147
+
148
148
-- -----------------------------------------------------------------------------
149
149
-- Jumps
150
150
+
@@ -154,7 +154,7 @@ index b77aa73e52b..2a1fa03b1bc 100644
154
154
@@ -1302,6 +1311,22 @@ genCondJump bid expr = do
155
155
_ -> pprPanic "AArch64.genCondJump:case mop: " (text $ show expr)
156
156
_ -> pprPanic "AArch64.genCondJump: " (text $ show expr)
157
-
157
+
158
158
+ -- A conditional jump with at least +/-128M jump range
159
159
+ genCondFarJump :: MonadUnique m => Cond -> Target -> m InstrBlock
160
160
+ genCondFarJump cond far_target = do
@@ -171,7 +171,7 @@ index b77aa73e52b..2a1fa03b1bc 100644
171
171
+ , NEWBLOCK jmp_lbl_id
172
172
+ , B far_target
173
173
+ , NEWBLOCK skip_lbl_id]
174
-
174
+
175
175
genCondBranch
176
176
:: BlockId -- the source of the jump
177
177
@@ -1816,3 +1841,163 @@ genCCall target dest_regs arg_regs bid = do
@@ -344,12 +344,12 @@ index 687daccfda1..7efbb9c70bf 100644
344
344
+++ b/compiler/GHC/CmmToAsm/AArch64/Cond.hs
345
345
@@ -1,6 +1,6 @@
346
346
module GHC.CmmToAsm.AArch64.Cond where
347
-
347
+
348
348
- import GHC.Prelude
349
349
+ import GHC.Prelude hiding (EQ)
350
-
350
+
351
351
-- https://developer.arm.com/documentation/den0024/a/the-a64-instruction-set/data-processing-instructions/conditional-instructions
352
-
352
+
353
353
@@ -60,7 +60,13 @@ data Cond
354
354
| UOGE -- b.pl
355
355
| UOGT -- b.hi
@@ -374,8 +374,8 @@ index d8dd1a4dc0c..1fb8193612f 100644
374
374
| TLabel CLabel
375
375
| TReg Reg
376
376
+ deriving (Eq, Ord)
377
-
378
-
377
+
378
+
379
379
-- Extension
380
380
diff --git a/compiler/GHC/CmmToAsm/AArch64/Ppr.hs b/compiler/GHC/CmmToAsm/AArch64/Ppr.hs
381
381
index fd56d37cd39..c672c342376 100644
@@ -384,12 +384,12 @@ index fd56d37cd39..c672c342376 100644
384
384
@@ -1,7 +1,7 @@
385
385
{-# OPTIONS_GHC -fno-warn-orphans #-}
386
386
{-# LANGUAGE CPP #-}
387
-
387
+
388
388
- module GHC.CmmToAsm.AArch64.Ppr (pprNatCmmDecl, pprInstr) where
389
389
+ module GHC.CmmToAsm.AArch64.Ppr (pprNatCmmDecl, pprInstr, pprBasicBlock) where
390
-
390
+
391
391
import GHC.Prelude hiding (EQ)
392
-
392
+
393
393
@@ -353,7 +353,10 @@ pprInstr platform instr = case instr of
394
394
-> line (text "\t.loc" <+> int file <+> int line' <+> int col)
395
395
DELTA d -> dualDoc (asmComment $ text "\tdelta = " <> int d) empty
@@ -400,17 +400,17 @@ index fd56d37cd39..c672c342376 100644
400
400
+ -- print it for debugging purposes.
401
401
+ line (text "BLOCK " <> pprAsmLabel platform (blockLbl blockid))
402
402
LDATA _ _ -> panic "pprInstr: LDATA"
403
-
403
+
404
404
-- Pseudo Instructions -------------------------------------------------------
405
405
@@ -567,7 +570,7 @@ pprCond c = case c of
406
406
UGE -> text "hs" -- Carry set/unsigned higher or same ; Greater than or equal, or unordered
407
407
UGT -> text "hi" -- Unsigned higher ; Greater than, or unordered
408
-
408
+
409
409
- NEVER -> text "nv" -- Never
410
410
+ -- NEVER -> text "nv" -- Never
411
411
VS -> text "vs" -- Overflow ; Unordered (at least one NaN operand)
412
412
VC -> text "vc" -- No overflow ; Not unordered
413
-
413
+
414
414
diff --git a/compiler/GHC/CmmToAsm/BlockLayout.hs b/compiler/GHC/CmmToAsm/BlockLayout.hs
415
415
index fa0929348ce..e2096c90209 100644
416
416
--- a/compiler/GHC/CmmToAsm/BlockLayout.hs
@@ -420,7 +420,7 @@ index fa0929348ce..e2096c90209 100644
420
420
import Control.Monad (foldM, unless)
421
421
import GHC.Data.UnionFind
422
422
+ import GHC.Types.Unique.Supply (UniqSM)
423
-
423
+
424
424
{-
425
425
Note [CFG based code layout]
426
426
@@ -794,29 +795,32 @@ sequenceTop
@@ -476,7 +476,7 @@ index fa0929348ce..e2096c90209 100644
476
476
+ far_blocks <- (ncgMakeFarBranches ncgImpl) platform info seq_blocks
477
477
+ pure $ CmmProc info lbl live $ ListGraph far_blocks
478
478
+
479
-
479
+
480
480
-- The old algorithm:
481
481
-- It is very simple (and stupid): We make a graph out of
482
482
diff --git a/compiler/GHC/CmmToAsm/Monad.hs b/compiler/GHC/CmmToAsm/Monad.hs
@@ -508,7 +508,7 @@ index 3fedcc1fc40..8682d1db9d8 100644
508
508
+++ b/compiler/GHC/CmmToAsm/PPC/Instr.hs
509
509
@@ -688,12 +688,13 @@ takeRegRegMoveInstr _ = Nothing
510
510
-- big, we have to work around this limitation.
511
-
511
+
512
512
makeFarBranches
513
513
- :: LabelMap RawCmmStatics
514
514
+ :: Platform
@@ -538,6 +538,6 @@ index a82674afe8f..a13fa2e4656 100644
538
538
, extractUnwindPoints = X86.extractUnwindPoints
539
539
, invertCondBranches = X86.invertCondBranches
540
540
}
541
- - -
541
+ - -
542
542
GitLab
543
543
0 commit comments