]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.*: merge of ##inc-r and ##inc-d into one instruction ##inc with a loc slot
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 3 Mar 2015 22:45:47 +0000 (22:45 +0000)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Apr 2015 16:31:53 +0000 (09:31 -0700)
this is nice because it leads to simpler code and matches how ##peek and ##replace instructions work

27 files changed:
basis/compiler/cfg/branch-splitting/branch-splitting.factor
basis/compiler/cfg/debugger/debugger.factor
basis/compiler/cfg/gc-checks/gc-checks-tests.factor
basis/compiler/cfg/instructions/instructions-docs.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/linear-scan/assignment/assignment-tests.factor
basis/compiler/cfg/liveness/liveness-tests.factor
basis/compiler/cfg/registers/registers-docs.factor
basis/compiler/cfg/registers/registers.factor
basis/compiler/cfg/save-contexts/save-contexts-tests.factor
basis/compiler/cfg/save-contexts/save-contexts.factor
basis/compiler/cfg/ssa/interference/interference-tests.factor
basis/compiler/cfg/stacks/clearing/clearing-docs.factor
basis/compiler/cfg/stacks/clearing/clearing-tests.factor
basis/compiler/cfg/stacks/local/local-docs.factor
basis/compiler/cfg/stacks/local/local-tests.factor
basis/compiler/cfg/stacks/local/local.factor
basis/compiler/cfg/stacks/map/map-tests.factor
basis/compiler/cfg/stacks/map/map.factor
basis/compiler/cfg/stacks/vacant/vacant-docs.factor
basis/compiler/codegen/codegen.factor
basis/compiler/tests/low-level-ir.factor
basis/cpu/architecture/architecture.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/64/64-tests.factor
basis/cpu/x86/x86.factor
extra/compiler/cfg/gvn/gvn-tests.factor

index 40826a921c1d2df02261a135b79b488dba4e6b97..90335d49c1d2a662df5dab11d5790866d2ff953c 100644 (file)
@@ -48,7 +48,7 @@ IN: compiler.cfg.branch-splitting
     [ update-successor-predecessors ]
     2bi ;
 
-UNION: irrelevant ##peek ##replace ##inc-d ##inc-r ;
+UNION: irrelevant ##peek ##replace ##inc ;
 
 : split-instructions? ( insns -- ? ) [ irrelevant? not ] count 5 <= ;
 
index 54958d1de256b65264589f51db6c0165931958e6..8e0ad95bb9d00fde2a371fd9df618e12017e0173 100644 (file)
@@ -7,7 +7,7 @@ compiler.cfg.instructions compiler.cfg.linearization
 compiler.cfg.optimizer compiler.cfg.registers
 compiler.cfg.representations
 compiler.cfg.representations.preferred compiler.cfg.rpo
-compiler.cfg.save-contexts compiler.cfg.scheduling
+compiler.cfg.save-contexts
 compiler.cfg.utilities compiler.tree.builder
 compiler.tree.optimizer compiler.units hashtables io kernel math
 namespaces prettyprint prettyprint.backend prettyprint.custom
@@ -126,8 +126,3 @@ M: rs-loc pprint* \ R pprint-loc ;
 
 : contains-insn? ( quot insn-check -- ? )
     count-insns 0 > ; inline
-
-! Random instruction scheduling exposes bugs in
-! compiler.cfg.dependencies
-: random-scheduling ( -- )
-    [ \ score [ drop 100 random ] define ] with-compilation-unit ;
index 92c7fcd16cdaa6e6dee409277af7bb7966400922..6fc749cde3d7d62a7944cd1a6fc81b430685b194 100644 (file)
@@ -9,7 +9,7 @@ IN: compiler.cfg.gc-checks.tests
 
 [ { } ] [
     V{
-        T{ ##inc-d }
+        T{ ##inc }
         T{ ##peek }
         T{ ##add }
         T{ ##branch }
@@ -18,7 +18,7 @@ IN: compiler.cfg.gc-checks.tests
 
 [ { } ] [
     V{
-        T{ ##inc-d }
+        T{ ##inc }
         T{ ##peek }
         T{ ##alien-invoke }
         T{ ##add }
@@ -28,7 +28,7 @@ IN: compiler.cfg.gc-checks.tests
 
 [ { 0 } ] [
     V{
-        T{ ##inc-d }
+        T{ ##inc }
         T{ ##peek }
         T{ ##allot }
         T{ ##alien-invoke }
@@ -39,7 +39,7 @@ IN: compiler.cfg.gc-checks.tests
 
 [ { 0 } ] [
     V{
-        T{ ##inc-d }
+        T{ ##inc }
         T{ ##peek }
         T{ ##allot }
         T{ ##allot }
@@ -50,7 +50,7 @@ IN: compiler.cfg.gc-checks.tests
 
 [ { 0 4 } ] [
     V{
-        T{ ##inc-d }
+        T{ ##inc }
         T{ ##peek }
         T{ ##allot }
         T{ ##alien-invoke }
@@ -63,7 +63,7 @@ IN: compiler.cfg.gc-checks.tests
 
 [ { 3 } ] [
     V{
-        T{ ##inc-d }
+        T{ ##inc }
         T{ ##peek }
         T{ ##alien-invoke }
         T{ ##allot }
@@ -87,7 +87,7 @@ IN: compiler.cfg.gc-checks.tests
     0 get block>cfg cfg set ;
 
 V{
-    T{ ##inc-d f 3 }
+    T{ ##inc f 3 }
     T{ ##replace f 0 D 1 }
 } 0 test-bb
 
@@ -132,7 +132,7 @@ V{
 
 V{
     T{ ##peek f 2 D 0 }
-    T{ ##inc-d f 3 }
+    T{ ##inc { loc D 3 } }
     T{ ##branch }
 } 1 test-bb
 
index d263bc293ca650844e47f105dad67ed3ceaa2f39..8879e48025c35ff9dd0a79275933cd2bd922ce37 100644 (file)
@@ -36,9 +36,9 @@ HELP: ##load-reference
   }
 } ;
 
-HELP: ##inc-d
+HELP: ##inc
 { $class-description
-  "An instruction that increases or decreases the data stacks height by n. For example, " { $link 2drop } " decreases it by two and pushing an item increases it by one."
+  "An instruction that increases or decreases a stacks height by n. For example, " { $link 2drop } " decreases the datastacks height by two and pushing an item increases it by one."
 } ;
 
 HELP: ##prologue
@@ -113,6 +113,17 @@ HELP: ##set-slot-imm
 { ##set-slot-imm %set-slot-imm } related-words
 { ##set-slot-imm ##set-slot } related-words
 
+HELP: ##slot-imm
+{ $class-description
+  "Instruction for reading a slot value from an object."
+  { $table
+    { { $slot "dst" } { "Register to read the slot value into." } }
+    { { $slot "obj" } { "Register containing the object with the slot." } }
+    { { $slot "slot" } { "Slot index." } }
+    { { $slot "tag" } { "Type tag for obj." } }
+  }
+} ;
+
 HELP: ##replace-imm
 { $class-description
   "An instruction that replaces an item on the data or register stack with an " { $link immediate } " value." } ;
@@ -129,10 +140,11 @@ HELP: ##box-alien
 
 HELP: ##write-barrier
 { $class-description
-  "An instruction for inserting a write barrier. This instruction is almost always inserted after a " { $link ##set-slot } " instruction. It has the following slots:"
+  "An instruction for inserting a write barrier. This instruction is almost always inserted after a " { $link ##set-slot } " instruction. If the container object is in an older generation than the item inserted, this instruction guarantees that the item will not be garbage collected. It has the following slots:"
   { $table
-    { { $slot "src" } { "Object which the writer barrier refers." } }
+    { { $slot "src" } { "Object to which the writer barrier refers." } }
     { { $slot "slot" } { "Slot index of the object." } }
+    { { $slot "scale" } { "No idea." } }
     { { $slot "tag" } { "Type tag for obj." } }
     { { $slot "temp1" } { "First temporary register to clobber." } }
     { { $slot "temp2" } { "Second temporary register to clobber." } }
@@ -290,11 +302,11 @@ $nl
   ##slot-imm
   ##set-slot
   ##set-slot-imm
+  ##write-barrier
 }
 "Stack height manipulation:"
 { $subsections
-  ##inc-d
-  ##inc-r
+  ##inc
 } ;
 
 ABOUT: "compiler.cfg.instructions"
index 4e928a7e3af905dd0be1f73c877635cb20e67784..9c86f473b1269bd61a057356ae89273cde05c439 100644 (file)
@@ -57,11 +57,8 @@ literal: loc ;
 INSN: ##replace-imm
 literal: src loc ;
 
-INSN: ##inc-d
-literal: n ;
-
-INSN: ##inc-r
-literal: n ;
+INSN: ##inc
+literal: loc ;
 
 ! Subroutine calls
 INSN: ##call
index be4792e371a849bc9fc9cb8e60972478dde15561..7f71bb45cd48a080fe01283b79d073843a548314 100644 (file)
@@ -1,7 +1,8 @@
 USING: accessors arrays compiler.cfg.instructions
 compiler.cfg.linear-scan.assignment compiler.cfg.linear-scan.live-intervals
-compiler.cfg.utilities cpu.architecture cpu.x86.assembler.operands grouping
-heaps kernel make namespaces random sequences sorting tools.test ;
+compiler.cfg.registers compiler.cfg.utilities cpu.architecture
+cpu.x86.assembler.operands grouping heaps kernel make namespaces random
+sequences sorting tools.test ;
 IN: compiler.cfg.linear-scan.assignment.tests
 
 { { T{ ##spill { src RAX } } } } [
@@ -12,7 +13,9 @@ IN: compiler.cfg.linear-scan.assignment.tests
 
 { } [
     { } init-assignment
-    V{ T{ ##inc-d { n 3 } { insn# 7 } } } 0 insns>block
+    V{
+        T{ ##inc { loc D 3 } { insn# 7 } }
+    } 0 insns>block
     assign-registers-in-block
 ] unit-test
 
index 5640910d45a0d6f2f872e8af2cd509ab077490bb..6555eb62b3004b7f4ad0da171e6a064e20545bdb 100644 (file)
@@ -68,8 +68,8 @@ V{
 } 0 test-bb
 
 V{
-    T{ ##inc-r f 2 }
-    T{ ##inc-d f -2 }
+    T{ ##inc { loc R 2 } }
+    T{ ##inc { loc D -2 } }
     T{ ##peek f 21 D -1 }
     T{ ##peek f 22 D -2 }
     T{ ##replace f 21 R 0 }
@@ -83,8 +83,8 @@ V{
 } 2 test-bb
 
 V{
-    T{ ##inc-r f -1 }
-    T{ ##inc-d f 1 }
+    T{ ##inc { loc R -1 } }
+    T{ ##inc { loc D 1 } }
     T{ ##peek f 25 R -1 }
     T{ ##replace f 25 D 0 }
     T{ ##branch }
@@ -96,8 +96,8 @@ V{
 } 4 test-bb
 
 V{
-    T{ ##inc-r f -1 }
-    T{ ##inc-d f 2 }
+    T{ ##inc f R -1 }
+    T{ ##inc f D 2 }
     T{ ##peek f 27 R -1 }
     T{ ##peek f 28 D 2 }
     T{ ##peek f 29 D 3 }
@@ -107,18 +107,18 @@ V{
 } 5 test-bb
 
 V{
-    T{ ##inc-d f -1 }
+    T{ ##inc f D -1 }
     T{ ##branch }
 } 6 test-bb
 
 V{
-    T{ ##inc-d f -1 }
+    T{ ##inc f D -1 }
     T{ ##branch }
 } 7 test-bb
 
 V{
     T{ ##phi f 36 H{ { 6 30 } { 7 31 } } }
-    T{ ##inc-d f -2 }
+    T{ ##inc f D -2 }
     T{ ##unbox f 37 29 "alien_offset" int-rep }
     T{ ##unbox f 38 28 "to_double" double-rep }
     T{ ##unbox f 39 36 "to_cell" int-rep }
index bf15b4e637c8c9a02449277b63181dcb64a12969..70116aef6a41c8f09442b802265ec938f0f076dc 100644 (file)
@@ -2,6 +2,9 @@ USING: compiler.cfg.instructions cpu.architecture help.markup help.syntax
 math ;
 IN: compiler.cfg.registers
 
+HELP: vreg-counter
+{ $var-description "Virtual registers, used by CFG and machine IRs, are just integers." } ;
+
 HELP: next-vreg
 { $values { "vreg" number } }
 { $description "Creates a new virtual register identifier." }
@@ -24,4 +27,7 @@ HELP: next-vreg-rep
 HELP: loc
 { $class-description "Represents a location on the stack. 'n' is an index starting from the top of the stack going down. So 0 is the top of the stack, 1 is what would be the top of the stack after a 'drop', and so on. It has two subclasses, " { $link ds-loc } " for data stack location and " { $link rs-loc } " for locations on the retain stack." } ;
 
+ARTICLE: "compiler.cfg.registers" "Virtual single-assignment registers"
+"Virtual register assignment." ;
+
 ABOUT: "compiler.cfg.registers"
index 23d866b271f73d5692fc5bf68a5f23a85b62cce4..ee7256a6f256081f8bf621636d4f69276a508a03 100644 (file)
@@ -3,7 +3,6 @@
 USING: assocs kernel math namespaces parser sequences ;
 IN: compiler.cfg.registers
 
-! Virtual registers, used by CFG and machine IRs, are just integers
 SYMBOL: vreg-counter
 
 : next-vreg ( -- vreg )
@@ -22,9 +21,7 @@ ERROR: bad-vreg vreg ;
 : next-vreg-rep ( rep -- vreg )
     next-vreg [ set-rep-of ] keep ;
 
-! ##inc-d and ##inc-r affect locations as follows. Location D 0 before
-! an ##inc-d 1 becomes D 1 after ##inc-d 1.
-TUPLE: loc { n integer read-only } ;
+TUPLE: loc { n integer } ;
 
 TUPLE: ds-loc < loc ;
 C: <ds-loc> ds-loc
index d6f1c4d9272f81d36020a39aa8ef13750f8b123a..bc7b71d684728d0e82425724245c444a5a736577 100644 (file)
@@ -25,7 +25,7 @@ V{
 4 vreg-counter set-global
 
 V{
-    T{ ##inc-d f 3 }
+    T{ ##inc f D 3 }
     T{ ##box f 4 3 "from_signed_4" int-rep
         T{ gc-map { scrub-d B{ 0 0 0 } } { scrub-r B{ } } { gc-roots { } } }
     }
@@ -35,7 +35,7 @@ V{
 
 [
     V{
-        T{ ##inc-d f 3 }
+        T{ ##inc f D 3 }
         T{ ##save-context f 5 6 }
         T{ ##box f 4 3 "from_signed_4" int-rep
             T{ gc-map { scrub-d B{ 0 0 0 } } { scrub-r B{ } } { gc-roots { } } }
index e1326c2f07d759265bcf26890bee6de92748b31f..17c2a289dbf8ddc8ca867e117bee10441e01133e 100644 (file)
@@ -4,7 +4,7 @@ USING: compiler.cfg.instructions compiler.cfg.registers compiler.cfg.rpo
 cpu.architecture kernel sequences ;
 IN: compiler.cfg.save-contexts
 
-UNION: context-modifier ##phi ##inc-d ##inc-r ##callback-inputs ;
+UNION: context-modifier ##phi ##inc ##callback-inputs ;
 UNION: context-save-needed gc-map-insn ;
 
 : save-context-offset ( insns -- n )
index 07ab07af7a9071db7d65dd822f14232661d0f88d..75cdf0958296c480a4e5af9d56accfd5e9b931b8 100644 (file)
@@ -75,7 +75,7 @@ V{
 
 
 V{
-    T{ ##inc-d f -3 }
+    T{ ##inc f D -3 }
     T{ ##peek f 12 D -2 }
     T{ ##peek f 23 D -1 }
     T{ ##sar-imm f 13 23 4 }
@@ -106,7 +106,7 @@ V{
 } 0 test-bb
 
 V{
-    T{ ##inc-d f 2 }
+    T{ ##inc f D 2 }
     T{ ##peek f 32 D 2 }
     T{ ##load-reference f 33 ##check-nursery-branch }
     T{ ##load-integer f 34 11 }
@@ -123,7 +123,7 @@ V{
 } 2 test-bb
 
 V{
-    T{ ##inc-d f -2 }
+    T{ ##inc f D -2 }
     T{ ##slot-imm f 57 48 11 2 }
     T{ ##compare f 58 33 57 cc= 20 }
     T{ ##replace f 58 D 0 }
@@ -136,7 +136,7 @@ V{
 } 4 test-bb
 
 V{
-    T{ ##inc-d f -2 }
+    T{ ##inc f D -2 }
     T{ ##replace-imm f f D 0 }
     T{ ##branch f }
 } 5 test-bb
@@ -147,7 +147,7 @@ V{
 } 6 test-bb
 
 V{
-    T{ ##inc-d f -2 }
+    T{ ##inc f D -2 }
     T{ ##replace-imm f f D 0 }
     T{ ##branch f }
 } 7 test-bb
@@ -188,7 +188,7 @@ V{
 } 2 test-bb
 
 V{
-    T{ ##inc-d f 1 }
+    T{ ##inc f D 1 }
     T{ ##load-reference f 37 T{ bab } }
     T{ ##load-reference f 38 { gfg 1 1 tuple 57438726 gfg 7785907 } }
     T{ ##allot f 40 12 tuple 4 }
@@ -204,8 +204,8 @@ V{
 } 4 test-bb
 
 V{
-    T{ ##inc-r f 1 }
-    T{ ##inc-d f 1 }
+    T{ ##inc f R 1 }
+    T{ ##inc f D 1 }
     T{ ##peek f 43 D 1 }
     T{ ##peek f 44 D 2 }
     T{ ##tagged>integer f 45 43 }
@@ -214,7 +214,7 @@ V{
 } 5 test-bb
 
 V{
-    T{ ##inc-d f -1 }
+    T{ ##inc f D 1 }
     T{ ##slot-imm f 58 43 1 7 }
     T{ ##slot-imm f 60 58 7 2 }
     T{ ##compare-imm-branch f 60 bab cc= }
@@ -225,8 +225,8 @@ V{
 } 7 test-bb
 
 V{
-    T{ ##inc-r f -1 }
-    T{ ##inc-d f -1 }
+    T{ ##inc f R -1 }
+    T{ ##inc f D -1 }
     T{ ##set-slot-imm f 43 44 2 7 }
     T{ ##write-barrier-imm f 44 2 7 34 35 }
     T{ ##branch }
@@ -238,7 +238,7 @@ V{
 } 9 test-bb
 
 V{
-    T{ ##inc-d f 1 }
+    T{ ##inc f D 1 }
     T{ ##replace f 44 R 0 }
     T{ ##replace-imm f bab D 0 }
     T{ ##branch }
@@ -254,12 +254,12 @@ V{
 } 12 test-bb
 
 V{
-    T{ ##inc-d f -1 }
+    T{ ##inc f D -1 }
     T{ ##branch }
 } 13 test-bb
 
 V{
-    T{ ##inc-d f 1 }
+    T{ ##inc f D 1 }
     T{ ##replace f 44 R 0 }
     T{ ##replace-imm f bab D 0 }
     T{ ##branch }
@@ -314,7 +314,8 @@ V{
 } 0 test-bb
 
 V{
-    T{ ##inc-d f 1 }
+
+    T{ ##inc f D 1 }
     T{ ##peek f 31 D 1 }
     T{ ##sar-imm f 16 31 4 }
     T{ ##load-integer f 17 0 }
@@ -334,7 +335,7 @@ V{
 } 3 test-bb
 
 V{
-    T{ ##inc-d f -2 }
+    T{ ##inc f D -2 }
     T{ ##branch f }
 } 4 test-bb
 
index bfda1f1296ae3dad69fe19a83d231019bb66aca5..fd648e862cf414181e4a6e42efbed4cba06fc54a 100644 (file)
@@ -5,12 +5,12 @@ IN: compiler.cfg.stacks.clearing
 ARTICLE: "compiler.cfg.stacks.clearing" "Uninitialized stack location clearing"
 "A compiler pass that inserts " { $link ##replace-imm } " instructions front of unsafe " { $link ##peek } " instructions in the " { $link cfg } ". Consider the following sequence of instructions."
 { $code
-  "##inc-d 2"
+  "##inc D 2"
   "##peek RCX D 2"
 }
 "The ##peek can cause a stack underflow and then there will be two uninitialized locations on the data stack that can't be traced. To counteract that, this pass modifies the instruction sequence so that it becomes:"
 { $code
-  "##inc-d 2"
+  "##inc D 2"
   "##replace-imm 17 D 0"
   "##replace-imm 17 D 1"
   "##peek RCX D 2"
index 4b1b36a5d5421ef1e21bda6fbe2e37eb71b436d2..bbac72815666b4fedf32e63037b7246beacd4f63 100644 (file)
@@ -24,12 +24,12 @@ IN: compiler.cfg.stacks.clearing.tests
 
 {
     V{
-        T{ ##inc-d { n 2 } { insn# 0 } }
+        T{ ##inc { loc D 2 } { insn# 0 } }
         T{ ##replace-imm { src 17 } { loc T{ ds-loc } } }
         T{ ##replace-imm { src 17 } { loc T{ ds-loc { n 1 } } } }
-        T{ ##peek { loc T{ ds-loc { n 2 } } } { insn# 1 } }
+        T{ ##peek { loc D 2 } { insn# 1 } }
     }
 } [
-    { T{ ##inc-d f 2 } T{ ##peek f f D 2 } } insns>cfg
+    { T{ ##inc f D 2 } T{ ##peek f f D 2 } } insns>cfg
     dup clear-uninitialized cfg>insns
 ] unit-test
index 6fc6c13d1d8c4fd19ca6d83febf61b1e6a8d8e30..a3c54a08bd79656c255a6895aa11cb6aa8de4135 100644 (file)
@@ -46,7 +46,7 @@ HELP: height-changes
   { $example
     "USING: compiler.cfg.stacks.local prettyprint ;"
     "T{ current-height { emit-d 4 } { emit-r -2 } } height-changes ."
-    "{ T{ ##inc-d { n 4 } } T{ ##inc-r { n -2 } } }"
+    "{ T{ ##inc { loc D 4 } } T{ ##inc { loc R -2 } } }"
   }
 } ;
 
index 760c18a86dc3a5e740f0ffc076f272e9e5256837..559816df92f01e7d08239d43ed054800585a0268 100644 (file)
@@ -1,5 +1,6 @@
-USING: accessors assocs biassocs combinators compiler.cfg.instructions
-compiler.cfg.registers compiler.cfg.stacks.local cpu.architecture kernel
+USING: accessors assocs biassocs combinators compiler.cfg
+compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks
+compiler.cfg.stacks.local compiler.cfg.utilities cpu.architecture kernel
 namespaces sequences tools.test ;
 IN: compiler.cfg.stacks.local.tests
 
@@ -10,7 +11,7 @@ IN: compiler.cfg.stacks.local.tests
 ] unit-test
 
 {
-    { T{ ##inc-d { n 4 } } T{ ##inc-r { n -2 } } }
+    { T{ ##inc { loc D 4 } } T{ ##inc { loc R -2 } } }
 } [
     T{ current-height { emit-d 4 } { emit-r -2 } } height-changes
 ] unit-test
@@ -34,3 +35,9 @@ IN: compiler.cfg.stacks.local.tests
     H{ } clone replace-mapping set 80
     D 77 replace-loc D 77 peek-loc
 ] unit-test
+
+{ 0 } [
+    V{ } 0 insns>block basic-block set
+    begin-stack-analysis begin-local-analysis
+    compute-local-kill-set assoc-size
+] unit-test
index c961817ad3631e39c891ef04500df2fc335f3ec1..92fe03fb234f2bf6fe741dc9cf15b8b30a5c8fac 100644 (file)
@@ -30,8 +30,8 @@ M: rs-loc translate-local-loc n>> current-height get r>> - <rs-loc> ;
     [ [ loc>vreg ] dip ] assoc-map parallel-copy ;
 
 : height-changes ( current-height -- insns )
-    [ emit-d>> ] [ emit-r>> ] bi 2array
-    { ##inc-d ##inc-r } [ new swap >>n ] 2map [ n>> 0 = not ] filter ;
+    [ emit-d>> <ds-loc> ] [ emit-r>> <rs-loc> ] bi 2array
+    [ n>> 0 = not ] filter [ ##inc new swap >>loc ] map ;
 
 : emit-changes ( -- )
     building get pop
@@ -39,7 +39,7 @@ M: rs-loc translate-local-loc n>> current-height get r>> - <rs-loc> ;
     current-height get height-changes %
     , ;
 
-! inc-d/inc-r: these emit ##inc-d/##inc-r to change the stack height later
+! inc-d/inc-r: these emit ##inc to change the stack height later
 : inc-d ( n -- )
     current-height get
     [ [ + ] change-emit-d drop ]
index 6c40254638e6e9f3f6bf7f56b050e0f1a465db63..19fe821508bdebbb51a1140b106c98ae2a0c5a43 100644 (file)
@@ -79,9 +79,9 @@ IN: compiler.cfg.stacks.map.tests
     }
 } [
     {
-        T{ ##inc-d f 2 }
+        T{ ##inc f D 2 }
         T{ ##peek f f D 2 }
-        T{ ##inc-d f 0 }
+        T{ ##inc f D 0 }
     } insns>cfg trace-stack-state
 ] unit-test
 
@@ -108,11 +108,11 @@ IN: compiler.cfg.stacks.map.tests
 
 {
     { { 1 { } } { 0 { } } }
-} [ V{ T{ ##inc-d f 1 } } following-stack-state ] unit-test
+} [ V{ T{ ##inc f D 1 } } following-stack-state ] unit-test
 
 {
     { { 0 { } } { 1 { } } }
-} [ V{ T{ ##inc-r f 1 } } following-stack-state ] unit-test
+} [ V{ T{ ##inc f R 1 } } following-stack-state ] unit-test
 
 ! Here the peek refers to a parameter of the word.
 {
@@ -132,7 +132,7 @@ IN: compiler.cfg.stacks.map.tests
     }
 } [
     V{
-        T{ ##inc-d f 3 }
+        T{ ##inc f D 3 }
         T{ ##peek { loc D 3 } }
         T{ ##branch }
     }
@@ -162,7 +162,7 @@ IN: compiler.cfg.stacks.map.tests
     V{
         T{ ##replace { src 10 } { loc D 0 } }
         T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
-        T{ ##inc-d f -1 }
+        T{ ##inc f D -1 }
         T{ ##peek { loc D -1 } }
     } following-stack-state
 ] unit-test
@@ -182,7 +182,7 @@ IN: compiler.cfg.stacks.map.tests
 } [
     V{
         T{ ##replace { src 10 } { loc D 0 } }
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##replace { src 10 } { loc D 0 } }
     } following-stack-state
 ] unit-test
@@ -192,9 +192,9 @@ IN: compiler.cfg.stacks.map.tests
 } [
     V{
         T{ ##replace { src 10 } { loc D 0 } }
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##replace { src 10 } { loc D 0 } }
-        T{ ##inc-d f -1 }
+        T{ ##inc f D -1 }
     } following-stack-state
 ] unit-test
 
@@ -202,9 +202,9 @@ IN: compiler.cfg.stacks.map.tests
     { { 0 { -1 } } { 0 { } } }
 } [
     V{
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##replace { src 10 } { loc D 0 } }
-        T{ ##inc-d f -1 }
+        T{ ##inc f D -1 }
     } following-stack-state
 ] unit-test
 
@@ -214,7 +214,7 @@ IN: compiler.cfg.stacks.map.tests
 } [
     V{
         T{ ##replace { src 10 } { loc D 0 } }
-        T{ ##inc-d f -1 }
+        T{ ##inc f D -1 }
         T{ ##call }
     } following-stack-state
 ] unit-test
@@ -222,7 +222,7 @@ IN: compiler.cfg.stacks.map.tests
 ! Should not be ok because the value wasn't initialized when gc ran.
 [
     V{
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
         T{ ##peek { loc D 0 } }
     } following-stack-state
@@ -230,26 +230,26 @@ IN: compiler.cfg.stacks.map.tests
 
 [
     V{
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##peek { loc D 0 } }
     } following-stack-state
 ] [ vacant-peek? ] must-fail-with
 
 [
     V{
-        T{ ##inc-r f 1 }
+        T{ ##inc f R 1 }
         T{ ##peek { loc R 0 } }
     } following-stack-state
 ] [ vacant-peek? ] must-fail-with
 
 : cfg1 ( -- cfg )
     V{
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##replace { src 10 } { loc D 0 } }
     } 0 insns>block
     V{
         T{ ##peek { dst 37 } { loc D 0 } }
-        T{ ##inc-d f -1 }
+        T{ ##inc f D -1 }
     } 1 insns>block
     1vector >>successors block>cfg ;
 
@@ -269,7 +269,7 @@ IN: compiler.cfg.stacks.map.tests
         { 0 V{ T{ ##safepoint } T{ ##prologue } T{ ##branch } } }
         {
             1 V{
-                T{ ##inc-d f 2 }
+                T{ ##inc f D 2 }
                 T{ ##replace { src 0 } { loc D 1 } }
                 T{ ##replace { src 0 } { loc D 0 } }
             }
@@ -281,7 +281,7 @@ IN: compiler.cfg.stacks.map.tests
         }
         {
             3 V{
-                T{ ##inc-d f 2 }
+                T{ ##inc f D 2 }
                 T{ ##peek { dst 0 } { loc D 2 } }
                 T{ ##peek { dst 0 } { loc D 3 } }
                 T{ ##replace { src 0 } { loc D 2 } }
@@ -291,7 +291,7 @@ IN: compiler.cfg.stacks.map.tests
         }
         {
             8 V{
-                T{ ##inc-d f 3 }
+                T{ ##inc f D 3 }
                 T{ ##peek { dst 0 } { loc D 5 } }
                 T{ ##replace { src 0 } { loc D 0 } }
                 T{ ##replace { src 0 } { loc D 3 } }
@@ -302,7 +302,7 @@ IN: compiler.cfg.stacks.map.tests
         }
         {
             10 V{
-                T{ ##inc-d f -3 }
+                T{ ##inc f D -3 }
                 T{ ##peek { dst 0 } { loc D -3 } }
                 T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
             }
index fb458431e82b9b8768230b9774954f4efcab99da..2d40d15439109d18905a860d9ce06ee7b9acc68b 100644 (file)
@@ -31,11 +31,9 @@ CONSTANT: initial-state { { 0 { } } { 0 { } } }
 
 GENERIC: visit-insn ( state insn -- state' )
 
-M: ##inc-d visit-insn ( state insn -- state' )
-    n>> swap first2 [ adjust-stack ] dip 2array ;
-
-M: ##inc-r visit-insn ( state insn -- state' )
-    n>> swap first2 swapd adjust-stack 2array ;
+M: ##inc visit-insn ( state insn -- state' )
+    [ first2 ] dip insn>location
+    [ rot adjust-stack swap ] [ swap adjust-stack ] if 2array ;
 
 M: ##replace-imm visit-insn mark-location ;
 M: ##replace visit-insn mark-location ;
index 4fb717357f69549a78c50844caf18acef1fcca67..94d222ad9f7b54f08ed1246356193815a03a2551 100644 (file)
@@ -5,7 +5,7 @@ IN: compiler.cfg.stacks.vacant
 ARTICLE: "compiler.cfg.stacks.vacant" "Uninitialized/overinitialized stack location analysis"
 "Consider the following sequence of instructions:"
 { $code
-  "##inc-d 2"
+  "##inc D 2"
   "..."
   "##allot"
   "##replace ... D 0"
index 87bf534fa5a53e1231a58f8619f5ec13eb53ea29..b7a14b7332454219068645e719a6d7a9d9d4db98 100755 (executable)
@@ -147,8 +147,7 @@ CODEGEN: ##load-vector %load-vector
 CODEGEN: ##peek %peek
 CODEGEN: ##replace %replace
 CODEGEN: ##replace-imm %replace-imm
-CODEGEN: ##inc-d %inc-d
-CODEGEN: ##inc-r %inc-r
+CODEGEN: ##inc %inc
 CODEGEN: ##call %call
 CODEGEN: ##jump %jump
 CODEGEN: ##return %return
index e75dbb29758ecfcb7197232114ed41248996849a..e679082474038d8102278517e06a812feedbc8d1 100644 (file)
@@ -24,7 +24,7 @@ IN: compiler.tests.low-level-ir
 : compile-test-bb ( insns -- result )
     V{ T{ ##prologue } T{ ##branch } } [ clone ] map 0 test-bb
     V{
-        T{ ##inc-d f 1 }
+        T{ ##inc f D 1 }
         T{ ##replace f 0 D 0 }
         T{ ##branch }
     } [ clone ] map append 1 test-bb
index f783de8bbd67089ca6df445c44125e047d0ad5f7..43f4c50464444fe23442a6111f5874374515fb56 100644 (file)
@@ -231,8 +231,7 @@ HOOK: %load-vector cpu ( reg val rep -- )
 HOOK: %peek cpu ( vreg loc -- )
 HOOK: %replace cpu ( vreg loc -- )
 HOOK: %replace-imm cpu ( src loc -- )
-HOOK: %inc-d cpu ( n -- )
-HOOK: %inc-r cpu ( n -- )
+HOOK: %inc cpu ( loc -- )
 
 HOOK: stack-frame-size cpu ( stack-frame -- n )
 HOOK: %call cpu ( word -- )
index f15072ff4f1f646c2fa8a2dd29fdf50118904458..5b126f0514e1310bb856a09f6dfceccf375f1578 100644 (file)
@@ -184,13 +184,9 @@ M:: ppc %replace-imm ( src loc -- )
     } cond
     scratch-reg reg offset %store-cell ;
 
-! Increment data stack pointer by n cells.
-M: ppc %inc-d ( n -- )
-    [ ds-reg ds-reg ] dip cells ADDI ;
-
-! Increment retain stack pointer by n cells.
-M: ppc %inc-r ( n -- )
-    [ rs-reg rs-reg ] dip cells ADDI ;
+! Increment stack pointer by n cells.
+M: ppc %inc ( loc -- )
+    [ ds-loc? [ ds-reg ds-reg ] [ rs-reg rs-reg ] if ] [ n>> ] bi cells ADDI ;
 
 M: ppc stack-frame-size ( stack-frame -- i )
     (stack-frame-size)
index 3ade9e9e7f4805b6bbe10a57a3a6513484959e03..da9a4cf88a85bfb2b9a1dd84ad754dcf3fbebfff 100644 (file)
@@ -1,6 +1,6 @@
-USING: alien alien.c-types cpu.architecture cpu.x86.64
-cpu.x86.assembler cpu.x86.assembler.operands tools.test
-assocs sequences ;
+USING: alien alien.c-types assocs compiler.cfg.registers
+cpu.architecture cpu.x86.64 cpu.x86.assembler cpu.x86.assembler.operands make
+sequences tools.test ;
 IN: cpu.x86.64.tests
 
 : assembly-test-1 ( -- x ) int { } cdecl [ RAX 3 MOV ] alien-assembly ;
@@ -14,3 +14,7 @@ IN: cpu.x86.64.tests
     ] alien-assembly ;
 
 [ 23 ] [ 17 6 assembly-test-2 ] unit-test
+
+{ B{ 73 131 198 24 } } [
+    [ T{ ds-loc { n 3 } } %inc ] B{ } make
+] unit-test
index f3c8195e4030aa5265a050e20213dade5778d5ff..d02a6078c749a99a79141d399a5ae12e7b6d476f 100644 (file)
@@ -91,8 +91,9 @@ M: x86 %replace-imm
     } cond ;
 
 : (%inc) ( n reg -- ) swap cells dup 0 > [ ADD ] [ neg SUB ] if ; inline
-M: x86 %inc-d ( n -- ) ds-reg (%inc) ;
-M: x86 %inc-r ( n -- ) rs-reg (%inc) ;
+
+M: x86 %inc ( loc -- )
+    [ n>> ] [ ds-loc? ds-reg rs-reg ? ] bi (%inc) ;
 
 M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
 
index 3f2bc2ce708e210b4c9973179a768317e3069064..01b11d07ed64d9dac16e7312d3dc67f41dd9ee50 100644 (file)
@@ -3155,19 +3155,19 @@ cpu x86? [
 V{ T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##inc-d { n -1 } }
+    T{ ##inc { loc D -1 } }
     T{ ##peek { dst 1 } { loc D -1 } }
     T{ ##compare-imm-branch { src1 1 } { src2 f } { cc cc/= } }
 } 1 test-bb
 
 V{
-    T{ ##inc-d { n 1 } }
+    T{ ##inc { loc D 1 } }
     T{ ##load-integer { dst 2 } { val 100 } }
     T{ ##branch }
 } 2 test-bb
 
 V{
-    T{ ##inc-d { n 1 } }
+    T{ ##inc { loc D 1 } }
     T{ ##load-integer { dst 3 } { val 200 } }
     T{ ##branch }
 } 3 test-bb
@@ -3192,7 +3192,7 @@ test-diamond
 V{ T{ ##prologue } T{ ##branch } } 0 test-bb
 
 V{
-    T{ ##inc-d f 3 }
+    T{ ##inc f D 3 }
     T{ ##load-integer f 21 0 }
     T{ ##load-integer f 22 100 }
     T{ ##load-integer f 23 0 }
@@ -3227,7 +3227,7 @@ V{
 } 2 test-bb
 
 V{
-    T{ ##inc-d f -2 }
+    T{ ##inc f D -2 }
     T{ ##replace f 29 D 0 }
     T{ ##branch }
 } 4 test-bb