Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
cameron
parabix-devel
Commits
b9c41a90
Commit
b9c41a90
authored
6 days ago
by
Rob Cameron
Browse files
Options
Download
Email Patches
Plain Diff
Bixnum masked create method
parent
951c5f6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
include/pablo/bixnum/bixnum.h
include/pablo/bixnum/bixnum.h
+2
-0
lib/pablo/bixnum/bixnum.cpp
lib/pablo/bixnum/bixnum.cpp
+16
-1
No files found.
include/pablo/bixnum/bixnum.h
View file @
b9c41a90
...
...
@@ -26,6 +26,8 @@ class BixNumCompiler {
public:
BixNumCompiler
(
PabloBuilder
&
pb
)
:
mPB
(
pb
)
{}
BixNum
Create
(
unsigned
val
);
// Create a bixnum of the given value at mask positions, 0 elsewhere.
BixNum
Create
(
PabloAST
*
mask
,
unsigned
val
);
PabloAST
*
EQ
(
BixNum
value
,
unsigned
test
,
const
llvm
::
StringRef
&
Name
=
""
);
PabloAST
*
EQ
(
BixNum
value
,
BixNum
test
,
const
llvm
::
StringRef
&
Name
=
""
);
PabloAST
*
NEQ
(
BixNum
value
,
unsigned
test
,
const
llvm
::
StringRef
&
Name
=
""
);
...
...
This diff is collapsed.
Click to expand it.
lib/pablo/bixnum/bixnum.cpp
View file @
b9c41a90
...
...
@@ -186,7 +186,8 @@ BixNum BixNumCompiler::HighBits(BixNum value, unsigned highBitCount) {
}
BixNum
BixNumCompiler
::
Create
(
unsigned
value
)
{
unsigned
value_bits
=
floor_log2
(
value
)
+
1
;
unsigned
value_bits
=
1
;
if
(
value
>
0
)
value_bits
=
floor_log2
(
value
)
+
1
;
BixNum
v
(
value_bits
);
for
(
unsigned
i
=
0
;
i
<
value_bits
;
i
++
)
{
if
((
value
&
(
1
<<
i
))
==
0
)
{
...
...
@@ -198,6 +199,20 @@ BixNum BixNumCompiler::Create(unsigned value) {
return
v
;
}
BixNum
BixNumCompiler
::
Create
(
PabloAST
*
mask
,
unsigned
value
)
{
unsigned
value_bits
=
1
;
if
(
value
>
0
)
value_bits
=
floor_log2
(
value
)
+
1
;
BixNum
v
(
value_bits
);
for
(
unsigned
i
=
0
;
i
<
value_bits
;
i
++
)
{
if
((
value
&
(
1
<<
i
))
==
0
)
{
v
[
i
]
=
mPB
.
createZeroes
();
}
else
{
v
[
i
]
=
mask
;
}
}
return
v
;
}
BixNum
BixNumCompiler
::
AddModular
(
BixNum
augend
,
unsigned
addend
)
{
addend
=
addend
&
((
1
<<
augend
.
size
())
-
1
);
if
(
addend
==
0
)
return
augend
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment