projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
abaa832
)
SPARC NCG: Keep track of destinations when doing a tabled jump
author
Ben.Lippmeier@anu.edu.au
<unknown>
Fri, 23 Jan 2009 05:22:47 +0000
(
05:22
+0000)
committer
Ben.Lippmeier@anu.edu.au
<unknown>
Fri, 23 Jan 2009 05:22:47 +0000
(
05:22
+0000)
compiler/nativeGen/MachCodeGen.hs
patch
|
blob
|
history
compiler/nativeGen/MachInstrs.hs
patch
|
blob
|
history
compiler/nativeGen/PprMach.hs
patch
|
blob
|
history
compiler/nativeGen/RegAllocInfo.hs
patch
|
blob
|
history
diff --git
a/compiler/nativeGen/MachCodeGen.hs
b/compiler/nativeGen/MachCodeGen.hs
index
da2b0ea
..
cac9f17
100644
(file)
--- a/
compiler/nativeGen/MachCodeGen.hs
+++ b/
compiler/nativeGen/MachCodeGen.hs
@@
-4309,8
+4309,8
@@
genSwitch expr ids
, SLL e_reg (RIImm $ ImmInt 2) offset_reg
-- load and jump to the destination
, SLL e_reg (RIImm $ ImmInt 2) offset_reg
-- load and jump to the destination
- , LD II32 (AddrRegReg base_reg offset_reg) dst
- , JMP (AddrRegImm dst (ImmInt 0))
+ , LD II32 (AddrRegReg base_reg offset_reg) dst
+ , JMP_TBL (AddrRegImm dst (ImmInt 0)) [i | Just i <- ids]
, NOP ]
#else
, NOP ]
#else
diff --git
a/compiler/nativeGen/MachInstrs.hs
b/compiler/nativeGen/MachInstrs.hs
index
e16dbf3
..
529da0d
100644
(file)
--- a/
compiler/nativeGen/MachInstrs.hs
+++ b/
compiler/nativeGen/MachInstrs.hs
@@
-609,6
+609,13
@@
is_G_instr instr
| BF Cond Bool BlockId -- cond, annul?, target
| JMP AddrMode -- target
| BF Cond Bool BlockId -- cond, annul?, target
| JMP AddrMode -- target
+
+ -- With a tabled jump we know all the possible destinations. Tabled
+ -- jump includes its list of destinations so we can work out what regs
+ -- are live across the jump.
+ --
+ | JMP_TBL AddrMode [BlockId]
+
| CALL (Either Imm Reg) Int Bool -- target, args, terminal
riZero :: RI -> Bool
| CALL (Either Imm Reg) Int Bool -- target, args, terminal
riZero :: RI -> Bool
diff --git
a/compiler/nativeGen/PprMach.hs
b/compiler/nativeGen/PprMach.hs
index
8fc9e3d
..
9e85198
100644
(file)
--- a/
compiler/nativeGen/PprMach.hs
+++ b/
compiler/nativeGen/PprMach.hs
@@
-2110,6
+2110,7
@@
pprInstr (BF cond b (BlockId id))
]
pprInstr (JMP addr) = (<>) (ptext (sLit "\tjmp\t")) (pprAddr addr)
]
pprInstr (JMP addr) = (<>) (ptext (sLit "\tjmp\t")) (pprAddr addr)
+pprInstr (JMP_TBL op ids) = pprInstr (JMP op)
pprInstr (CALL (Left imm) n _)
= hcat [ ptext (sLit "\tcall\t"), pprImm imm, comma, int n ]
pprInstr (CALL (Left imm) n _)
= hcat [ ptext (sLit "\tcall\t"), pprImm imm, comma, int n ]
diff --git
a/compiler/nativeGen/RegAllocInfo.hs
b/compiler/nativeGen/RegAllocInfo.hs
index
deb5f34
..
bab6c2f
100644
(file)
--- a/
compiler/nativeGen/RegAllocInfo.hs
+++ b/
compiler/nativeGen/RegAllocInfo.hs
@@
-320,8
+320,8
@@
regUsage instr = case instr of
FSUB s r1 r2 r3 -> usage ([r1, r2], [r3])
FxTOy s1 s2 r1 r2 -> usage ([r1], [r2])
FSUB s r1 r2 r3 -> usage ([r1, r2], [r3])
FxTOy s1 s2 r1 r2 -> usage ([r1], [r2])
- -- We assume that all local jumps will be BI/BF. JMP must be out-of-line.
- JMP addr -> usage (regAddr addr, [])
+ JMP addr -> usage (regAddr addr, [])
+ JMP_TBL addr ids -> usage (regAddr addr, [])
CALL (Left imm) n True -> noUsage
CALL (Left imm) n False -> usage (argRegs n, callClobberedRegs)
CALL (Left imm) n True -> noUsage
CALL (Left imm) n False -> usage (argRegs n, callClobberedRegs)
@@
-427,6
+427,7
@@
jumpDests insn acc
#elif sparc_TARGET_ARCH
BI _ _ id -> id : acc
BF _ _ id -> id : acc
#elif sparc_TARGET_ARCH
BI _ _ id -> id : acc
BF _ _ id -> id : acc
+ JMP_TBL _ ids -> ids ++ acc
#else
#error "RegAllocInfo.jumpDests not finished"
#endif
#else
#error "RegAllocInfo.jumpDests not finished"
#endif
@@
-696,7
+697,10
@@
patchRegs instr env = case instr of
FSQRT s r1 r2 -> FSQRT s (env r1) (env r2)
FSUB s r1 r2 r3 -> FSUB s (env r1) (env r2) (env r3)
FxTOy s1 s2 r1 r2 -> FxTOy s1 s2 (env r1) (env r2)
FSQRT s r1 r2 -> FSQRT s (env r1) (env r2)
FSUB s r1 r2 r3 -> FSUB s (env r1) (env r2) (env r3)
FxTOy s1 s2 r1 r2 -> FxTOy s1 s2 (env r1) (env r2)
- JMP addr -> JMP (fixAddr addr)
+
+ JMP addr -> JMP (fixAddr addr)
+ JMP_TBL addr ids -> JMP_TBL (fixAddr addr) ids
+
CALL (Left i) n t -> CALL (Left i) n t
CALL (Right r) n t -> CALL (Right (env r)) n t
_ -> instr
CALL (Left i) n t -> CALL (Left i) n t
CALL (Right r) n t -> CALL (Right (env r)) n t
_ -> instr