Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
2df5b38f
Commit
2df5b38f
authored
20 years ago
by
rtoy
Browse files
Options
Downloads
Patches
Plain Diff
Add a deftransform for count for simple-bit-vectors.
parent
58b8f94b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/generic/vm-tran.lisp
+41
-1
41 additions, 1 deletion
compiler/generic/vm-tran.lisp
with
41 additions
and
1 deletion
compiler/generic/vm-tran.lisp
+
41
−
1
View file @
2df5b38f
...
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/vm-tran.lisp,v 1.5
5
2004/
09/08 02:10:55
rtoy Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/vm-tran.lisp,v 1.5
6
2004/
10/04 20:27:06
rtoy Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -379,6 +379,46 @@
(
setf
(
%raw-bits
result-bit-array
index
)
(
32bit-logical-not
(
%raw-bits
bit-array
index
))))))))
(
deftransform
count
((
item
sequence
)
(
bit
simple-bit-vector
)
*
:policy
(
>=
speed
space
))
`
(
let
((
length
(
length
sequence
)))
(
if
(
zerop
length
)
0
(
do
((
index
vm:vector-data-offset
(
1+
index
))
(
count
0
)
(
end-1
(
+
vm:vector-data-offset
(
truncate
(
truly-the
index
(
1-
length
))
vm:word-bits
))))
((
=
index
end-1
)
(
let*
((
extra
(
mod
length
vm:word-bits
))
(
mask
(
1-
(
ash
1
extra
)))
(
bits
(
logand
(
ash
mask
,
(
ecase
(
c:backend-byte-order
c:*target-backend*
)
(
:little-endian
0
)
(
:big-endian
'
(
-
vm:word-bits
extra
))))
(
%raw-bits
sequence
index
))))
(
declare
(
type
(
mod
#.
vm:word-bits
)
extra
))
(
declare
(
type
(
unsigned-byte
#.
vm:word-bits
)
mask
bits
))
;; could consider LOGNOT for the zero case instead of
;; doing the subtraction...
(
incf
count
,
(
if
(
constant-continuation-p
item
)
(
if
(
zerop
(
continuation-value
item
))
'
(
-
extra
(
logcount
bits
))
'
(
logcount
bits
))
'
(
if
(
zerop
item
)
(
-
extra
(
logcount
bits
))
(
logcount
bits
))))))
(
declare
(
type
index
index
count
end-1
)
(
optimize
(
speed
3
)
(
safety
0
)))
(
incf
count
,
(
if
(
constant-continuation-p
item
)
(
if
(
zerop
(
continuation-value
item
))
'
(
-
vm:word-bits
(
logcount
(
%raw-bits
sequence
index
)))
'
(
logcount
(
%raw-bits
sequence
index
)))
'
(
if
(
zerop
item
)
(
-
vm:word-bits
(
logcount
(
%raw-bits
sequence
index
)))
(
logcount
(
%raw-bits
sequence
index
)))))))))
;;;; Primitive translator for byte-blt
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment