]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.registers: minor optimization
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 21 Jul 2009 22:49:44 +0000 (17:49 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 21 Jul 2009 22:49:44 +0000 (17:49 -0500)
basis/compiler/cfg/registers/registers.factor

index 71f313be5a0b53736ebab5f83468a7dda4fab217..c5b39071534d303cffa7f16455e9b9ba78e1d64b 100644 (file)
@@ -1,11 +1,17 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors namespaces kernel arrays parser ;
+USING: accessors namespaces kernel arrays parser math math.order ;
 IN: compiler.cfg.registers
 
 ! Virtual registers, used by CFG and machine IRs
-TUPLE: vreg { reg-class read-only } { n read-only } ;
+TUPLE: vreg { reg-class read-only } { n fixnum read-only } ;
+
+M: vreg equal? over vreg? [ [ n>> ] bi@ eq? ] [ 2drop f ] if ;
+
+M: vreg hashcode* nip n>> ;
+
 SYMBOL: vreg-counter
+
 : next-vreg ( reg-class -- vreg ) \ vreg-counter counter vreg boa ;
 
 ! Stack locations -- 'n' is an index starting from the top of the stack