From 3177e7851c2cd4a9b36803a187c316624956314b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Fri, 22 Apr 2016 13:00:46 +0200 Subject: [PATCH] cpu.*: more docs --- .../cpu/architecture/architecture-docs.factor | 45 +++++++++++++++++-- basis/cpu/x86/assembler/assembler-docs.factor | 15 ++++++- basis/cpu/x86/assembler/assembler.factor | 1 - 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/basis/cpu/architecture/architecture-docs.factor b/basis/cpu/architecture/architecture-docs.factor index 135cf90e5e..b3117afe40 100644 --- a/basis/cpu/architecture/architecture-docs.factor +++ b/basis/cpu/architecture/architecture-docs.factor @@ -1,8 +1,7 @@ USING: alien assocs classes compiler.cfg.instructions -compiler.cfg.registers compiler.cfg.stack-frame -cpu.x86.assembler cpu.x86.assembler.operands help.markup -help.syntax kernel layouts literals math multiline system vm -words ; +compiler.cfg.registers compiler.cfg.stack-frame cpu.x86.assembler +cpu.x86.assembler.operands help.markup help.syntax kernel layouts +literals math multiline sequences strings system vm words ; IN: cpu.architecture << @@ -108,6 +107,21 @@ HELP: param-regs { $values { "abi" "a calling convention symbol" } { "regs" assoc } } { $description "Retrieves the order in which machine registers are used for parameters for the given calling convention." } ; +HELP: %alien-invoke +{ $values + { "reg-inputs" sequence } + { "stack-inputs" sequence } + { "reg-outputs" sequence } + { "dead-outputs" sequence } + { "cleanup" integer } + { "stack-size" integer } + { "symbols" string } + { "dll" { $maybe dll } } + { "gc-map" gc-map } +} +{ $description "Machine code emitter for the " { $link ##alien-invoke } " instruction." } ; + + HELP: %allot { $values { "dst" "destination register symbol" } @@ -176,6 +190,13 @@ HELP: %horizontal-add-vector } } ; +HELP: %load-double +{ $values + { "reg" "destination register symbol" } + { "val" float } +} { $description "Loads a literal floating point value into a register. On x86, this corresponds to the " { $link MOVSD } " instruction." } +{ $see-also ##load-double } ; + HELP: %load-immediate { $values { "reg" "a register symbol" } { "val" "a value" } } { $description "Emits code for loading an immediate value into a register. On " { $link x86 } ", if val is 0, then an " { $link XOR } " instruction is emitted instead of " { $link MOV } " because the former is shorter." } @@ -231,6 +252,22 @@ HELP: %save-context { $description "Emits machine code for saving pointers to the callstack, datastack and retainstack in the current context field struct." } { $examples { $unchecked-example $[ ex-%save-context ] } } ; +HELP: %set-slot +{ $values + { "src" "register containing the element" } + { "obj" "register containing the object" } + { "slot" "register containing the slot index" } + { "scale" fixnum } + { "tag" "type tag for the builtin" } +} { $description "Emits machine code for " { $link ##set-slot } " instructions." } +{ $examples + { $unchecked-example + "USING: cpu.architecture prettyprint ;" + "[ RAX RBX RCX 3 2 %set-slot ] B{ } make disassemble" + "0000000000f1fda0: 488944cbfe mov [rbx+rcx*8-0x2], rax" + } +} ; + HELP: %store-memory-imm { $values { "value" "source register" } diff --git a/basis/cpu/x86/assembler/assembler-docs.factor b/basis/cpu/x86/assembler/assembler-docs.factor index e922e8e4f4..0c2fa3e292 100644 --- a/basis/cpu/x86/assembler/assembler-docs.factor +++ b/basis/cpu/x86/assembler/assembler-docs.factor @@ -1,4 +1,5 @@ -USING: compiler.codegen.labels cpu.x86.assembler help.markup help.syntax ; +USING: compiler.codegen.labels cpu.x86.assembler.private help.markup +help.syntax ; IN: cpu.x86.assembler HELP: JE @@ -11,3 +12,15 @@ HELP: JE "000000e9fcc71fe0: 0f8400000000 jz dword 0xe9fcc71fe6" } } ; + +HELP: MOV +{ $values { "dst" "destination" "src" "source" } } +{ $description "Moves a value from one place to another." } ; + +HELP: (MOV-I) +{ $values { "dst" "destination" "src" "immediate value" } } +{ $description "MOV where the src is immediate." } ; + +ARTICLE: "cpu.x86.assembler" "x86 assembler" "This vocab implements an assembler for x86 architectures." ; + +ABOUT: "cpu.x86.assembler" diff --git a/basis/cpu/x86/assembler/assembler.factor b/basis/cpu/x86/assembler/assembler.factor index b452b48f7f..643306013b 100644 --- a/basis/cpu/x86/assembler/assembler.factor +++ b/basis/cpu/x86/assembler/assembler.factor @@ -210,7 +210,6 @@ GENERIC: POP ( op -- ) M: register POP f 0x58 short-operand ; M: operand POP { 0b000 f 0x8f } 1-operand ; -! MOV where the src is immediate.