From 7fec53b509543a42454457ae26e6a957db0af20d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 15 May 2010 13:57:35 -0700 Subject: [PATCH] compiler.cfg.instructions: ##bit-count insn --- basis/compiler/cfg/instructions/instructions.factor | 4 ++++ basis/compiler/codegen/codegen.factor | 1 + basis/cpu/architecture/architecture.factor | 1 + basis/cpu/x86/x86.factor | 1 + 4 files changed, 7 insertions(+) diff --git a/basis/compiler/cfg/instructions/instructions.factor b/basis/compiler/cfg/instructions/instructions.factor index f2ba0fefbb..38ca3a93b0 100644 --- a/basis/compiler/cfg/instructions/instructions.factor +++ b/basis/compiler/cfg/instructions/instructions.factor @@ -219,6 +219,10 @@ PURE-INSN: ##log2 def: dst/int-rep use: src/int-rep ; +PURE-INSN: ##bit-count +def: dst/int-rep +use: src/int-rep ; + ! Float arithmetic PURE-INSN: ##add-float def: dst/double-rep diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 9d3e76d25b..d5ab84bf45 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -162,6 +162,7 @@ CODEGEN: ##max %max CODEGEN: ##not %not CODEGEN: ##neg %neg CODEGEN: ##log2 %log2 +CODEGEN: ##bit-count %bit-count CODEGEN: ##copy %copy CODEGEN: ##tagged>integer %tagged>integer CODEGEN: ##add-float %add-float diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 5dff607abd..d3638dd377 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -270,6 +270,7 @@ HOOK: %max cpu ( dst src1 src2 -- ) HOOK: %not cpu ( dst src -- ) HOOK: %neg cpu ( dst src -- ) HOOK: %log2 cpu ( dst src -- ) +HOOK: %bit-count cpu ( dst src -- ) HOOK: %copy cpu ( dst src rep -- ) diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index f4738b990b..66610c9349 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -164,6 +164,7 @@ M: x86 %max int-rep two-operand [ CMP ] [ CMOVL ] 2bi ; M: x86 %not int-rep one-operand NOT ; M: x86 %neg int-rep one-operand NEG ; M: x86 %log2 BSR ; +M: x86 %bit-count POPCNT ; ! A bit of logic to avoid using MOVSS/MOVSD for reg-reg moves ! since this induces partial register stalls