]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.codegen: we don't need the init-fixup word
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 25 Nov 2016 14:59:46 +0000 (15:59 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Mon, 28 Nov 2016 01:04:28 +0000 (02:04 +0100)
basis/compiler/codegen/codegen-docs.factor
basis/compiler/codegen/codegen.factor
basis/cpu/architecture/architecture-docs.factor

index 50f627db4e12266ab5844e48d9a05db325b71d07..f2815191af7e82858257d1e985a26cd44339c7ad 100644 (file)
@@ -1,6 +1,7 @@
 USING: alien byte-arrays compiler.cfg compiler.cfg.instructions
-compiler.codegen.labels compiler.codegen.relocation cpu.architecture hashtables
-help.markup help.syntax literals make multiline sequences ;
+compiler.codegen.labels compiler.codegen.relocation cpu.architecture
+hashtables help.markup help.syntax literals make multiline quotations
+sequences ;
 IN: compiler.codegen
 
 <<
@@ -100,13 +101,21 @@ HELP: useless-branch?
 }
 { $description "If successor immediately follows bb in the linearization order, then a branch is is not needed." } ;
 
-HELP: init-fixup
-{ $description "Initializes variables needed for fixup." } ;
-
 HELP: check-fixup
 { $values { "seq" "a " { $link sequence } " of generated machine code." } }
 { $description "Used by " { $link with-fixup } " to ensure that the generated machine code is properly aligned." } ;
 
-ARTICLE: "compiler.codegen" "Code generation from MR (machine representation)" "Code generators for cfg instructions." ;
+HELP: with-fixup
+{ $values
+  { "quot" quotation }
+  { "code" sequence }
+}
+{ $description "Runs the quotation to emit compiled code. The output is a six-tuple with the same format as the one outputted by " { $link generate } "." } ;
+
+ARTICLE: "compiler.codegen" "Code generation from MR (machine representation)"
+"Code generators for cfg instructions."
+$nl
+"Combinators:"
+{ $subsections with-fixup } ;
 
 ABOUT: "compiler.codegen"
index e5b7b18ca41da0035a8611b3ed8156899e38aea6..247898a9b54a3b8bfc3fdd6b94d08053e069d83f 100755 (executable)
@@ -62,10 +62,6 @@ M: ##dispatch generate-insn
         instructions>> [ generate-insn ] each
     ] tri ;
 
-: init-fixup ( -- )
-    V{ } clone label-table set
-    V{ } clone binary-literal-table set ;
-
 : check-fixup ( seq -- )
     length data-alignment get mod 0 assert= ;
 
@@ -74,7 +70,8 @@ M: ##dispatch generate-insn
         init-relocation
         V{ } clone return-addresses set
         V{ } clone gc-maps set
-        init-fixup
+        V{ } clone label-table set
+        V{ } clone binary-literal-table set
         [
             @
             emit-binary-literals
index c19133cdf8196edc6b69266dbb2edf73e6dc9734..604662c32ccfb630bf10d1531a69c65cb9552e5c 100644 (file)
@@ -17,8 +17,8 @@ USING: cpu.architecture make ;
 
 STRING: ex-%box-alien
 USING: compiler.codegen compiler.codegen.relocation cpu.architecture make ;
-init-fixup init-relocation [ RAX RBX RCX %box-alien ] B{ } make disassemble
-000000e9fcc720a0: 48b80100000000000000  mov rax, 0x1
+[ RAX RBX RCX %box-alien ] with-fixup 4 swap nth disassemble
+000000e9fcc720a0: 48b80100000000000000  mov eax, 0x1
 000000e9fcc720aa: 4885db                test rbx, rbx
 000000e9fcc720ad: 0f8400000000          jz dword 0xe9fcc720b3
 000000e9fcc720b3: 498d4d10              lea rcx, [r13+0x10]