[MLton-commit] r6870
Matthew Fluet
fluet at mlton.org
Thu Sep 18 13:54:36 PDT 2008
Follow-up to r6868.
Regularize the treatment of jump tables between x86 and amd64
codegens.
Move all saveregalloc directives to immediately after their transfer.
Use default_live in the saveregalloc for the range check; only
locations live in the default block need to be recorded.
Move the pushCompensationBlock for the range check after all the jump
table entry blocks; this processes the default block before any jump
table entry blocks.
----------------------------------------------------------------------
U mlton/trunk/mlton/codegen/amd64-codegen/amd64-generate-transfers.fun
U mlton/trunk/mlton/codegen/x86-codegen/x86-generate-transfers.fun
----------------------------------------------------------------------
Modified: mlton/trunk/mlton/codegen/amd64-codegen/amd64-generate-transfers.fun
===================================================================
--- mlton/trunk/mlton/codegen/amd64-codegen/amd64-generate-transfers.fun 2008-09-18 04:37:39 UTC (rev 6869)
+++ mlton/trunk/mlton/codegen/amd64-codegen/amd64-generate-transfers.fun 2008-09-18 20:54:33 UTC (rev 6870)
@@ -843,16 +843,16 @@
remove_classes = ClassSet.empty,
dead_memlocs = MemLocSet.empty,
dead_classes = ClassSet.empty},
+ Assembly.instruction_jcc
+ {condition = condition_neg,
+ target = Operand.label falsee'},
Assembly.directive_saveregalloc
{live = MemLocSet.add
(MemLocSet.add
(LiveSet.toMemLocSet falsee_live,
stackTop ()),
frontier ()),
- id = id},
- Assembly.instruction_jcc
- {condition = condition_neg,
- target = Operand.label falsee'}],
+ id = id}],
(fall gef
{label = truee,
live = truee_live}))
@@ -873,16 +873,16 @@
remove_classes = ClassSet.empty,
dead_memlocs = MemLocSet.empty,
dead_classes = ClassSet.empty},
+ Assembly.instruction_jcc
+ {condition = condition,
+ target = Operand.label truee'},
Assembly.directive_saveregalloc
{live = MemLocSet.add
(MemLocSet.add
(LiveSet.toMemLocSet truee_live,
stackTop ()),
frontier ()),
- id = id},
- Assembly.instruction_jcc
- {condition = condition,
- target = Operand.label truee'}],
+ id = id}],
(fall gef
{label = falsee,
live = falsee_live}))
@@ -950,16 +950,16 @@
{src1 = test,
src2 = Operand.immediate_word k,
size = size},
+ Assembly.instruction_jcc
+ {condition = Instruction.E,
+ target = Operand.label target'},
Assembly.directive_saveregalloc
{live = MemLocSet.add
(MemLocSet.add
(LiveSet.toMemLocSet target_live,
stackTop ()),
frontier ()),
- id = id},
- Assembly.instruction_jcc
- {condition = Instruction.E,
- target = Operand.label target'}]
+ id = id}]
end)
in
AppendList.appends
@@ -1758,10 +1758,6 @@
val jump_table_label
= Label.newString "jumpTable"
- val idD = Directive.Id.new ()
- val defaultD = pushCompensationBlock
- {label = default,
- id = idD}
val idT = Directive.Id.new ()
val defaultT =
Promise.delay
@@ -1793,6 +1789,11 @@
val jump_table = filler (cases, minK)
+ val idD = Directive.Id.new ()
+ val defaultD = pushCompensationBlock
+ {label = default,
+ id = idD}
+
val default_live = getLive(liveInfo, default)
val live
= List.fold
@@ -1941,7 +1942,7 @@
{id = idD,
live = MemLocSet.add
(MemLocSet.add
- (LiveSet.toMemLocSet live,
+ (LiveSet.toMemLocSet default_live,
stackTop ()),
frontier ())},
Assembly.instruction_jmp
Modified: mlton/trunk/mlton/codegen/x86-codegen/x86-generate-transfers.fun
===================================================================
--- mlton/trunk/mlton/codegen/x86-codegen/x86-generate-transfers.fun 2008-09-18 04:37:39 UTC (rev 6869)
+++ mlton/trunk/mlton/codegen/x86-codegen/x86-generate-transfers.fun 2008-09-18 20:54:33 UTC (rev 6870)
@@ -830,16 +830,16 @@
remove_classes = ClassSet.empty,
dead_memlocs = MemLocSet.empty,
dead_classes = ClassSet.empty},
+ Assembly.instruction_jcc
+ {condition = condition_neg,
+ target = Operand.label falsee'},
Assembly.directive_saveregalloc
{live = MemLocSet.add
(MemLocSet.add
(LiveSet.toMemLocSet falsee_live,
stackTop ()),
frontier ()),
- id = id},
- Assembly.instruction_jcc
- {condition = condition_neg,
- target = Operand.label falsee'}],
+ id = id}],
(fall gef
{label = truee,
live = truee_live}))
@@ -860,16 +860,16 @@
remove_classes = ClassSet.empty,
dead_memlocs = MemLocSet.empty,
dead_classes = ClassSet.empty},
+ Assembly.instruction_jcc
+ {condition = condition,
+ target = Operand.label truee'},
Assembly.directive_saveregalloc
{live = MemLocSet.add
(MemLocSet.add
(LiveSet.toMemLocSet truee_live,
stackTop ()),
frontier ()),
- id = id},
- Assembly.instruction_jcc
- {condition = condition,
- target = Operand.label truee'}],
+ id = id}],
(fall gef
{label = falsee,
live = falsee_live}))
@@ -937,16 +937,16 @@
{src1 = test,
src2 = Operand.immediate_word k,
size = size},
+ Assembly.instruction_jcc
+ {condition = Instruction.E,
+ target = Operand.label target'},
Assembly.directive_saveregalloc
{live = MemLocSet.add
(MemLocSet.add
(LiveSet.toMemLocSet target_live,
stackTop ()),
frontier ()),
- id = id},
- Assembly.instruction_jcc
- {condition = Instruction.E,
- target = Operand.label target'}]
+ id = id}]
end)
in
AppendList.appends
@@ -1627,9 +1627,16 @@
= Label.newString "jumpTable"
val idT = Directive.Id.new ()
- val defaultT = pushCompensationBlock
- {label = default,
- id = idT}
+ val defaultT =
+ Promise.delay
+ (fn () =>
+ let
+ val _ = incNear(jumpInfo, default)
+ in
+ pushCompensationBlock
+ {label = default,
+ id = idT}
+ end)
val rec filler
= fn ([],_) => []
@@ -1644,11 +1651,17 @@
(Immediate.label target')::
(filler(cases', incFn j))
end
- else (Immediate.label defaultT)::
+ else (Immediate.label
+ (Promise.force defaultT))::
(filler(cases, incFn j))
val jump_table = filler (cases, minK)
+ val idD = Directive.Id.new ()
+ val defaultD = pushCompensationBlock
+ {label = default,
+ id = idD}
+
val default_live = getLive(liveInfo, default)
val live
= List.fold
@@ -1749,6 +1762,9 @@
remove_classes = ClassSet.empty,
dead_memlocs = MemLocSet.singleton checkTemp',
dead_classes = ClassSet.empty},
+ Assembly.instruction_jcc
+ {condition = Instruction.NZ,
+ target = Operand.label defaultC},
Assembly.directive_saveregalloc
{id = idC,
live = MemLocSet.add
@@ -1756,9 +1772,6 @@
(LiveSet.toMemLocSet default_live,
stackTop ()),
frontier ())},
- Assembly.instruction_jcc
- {condition = Instruction.NZ,
- target = Operand.label defaultC},
Assembly.instruction_sral
{oper = Instruction.SAR,
count = Operand.immediate_int shift,
@@ -1790,19 +1803,26 @@
{src1 = indexTemp,
src2 = Operand.immediate_word rangeK,
size = Size.LONG},
+ Assembly.instruction_jcc
+ {condition = Instruction.A,
+ target = Operand.label defaultD},
Assembly.directive_saveregalloc
- {id = idT,
+ {id = idD,
live = MemLocSet.add
(MemLocSet.add
- (LiveSet.toMemLocSet live,
+ (LiveSet.toMemLocSet default_live,
stackTop ()),
frontier ())},
- Assembly.instruction_jcc
- {condition = Instruction.A,
- target = Operand.label defaultT},
Assembly.instruction_jmp
{target = address,
absolute = true},
+ Assembly.directive_saveregalloc
+ {id = idT,
+ live = MemLocSet.add
+ (MemLocSet.add
+ (LiveSet.toMemLocSet live,
+ stackTop ()),
+ frontier ())},
Assembly.directive_force
{commit_memlocs = MemLocSet.empty,
commit_classes = ClassSet.empty,
More information about the MLton-commit
mailing list