Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bpftrace
Commits
6f4a2a9c
Commit
6f4a2a9c
authored
May 17, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codegen: Implement count()
parent
fe6a7209
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
src/codegen_llvm.cpp
src/codegen_llvm.cpp
+17
-1
No files found.
src/codegen_llvm.cpp
View file @
6f4a2a9c
...
@@ -54,7 +54,7 @@ void CodegenLLVM::visit(Builtin &builtin)
...
@@ -54,7 +54,7 @@ void CodegenLLVM::visit(Builtin &builtin)
void
CodegenLLVM
::
visit
(
Call
&
call
)
void
CodegenLLVM
::
visit
(
Call
&
call
)
{
{
expr_
=
b_
.
getInt64
(
0
);
abort
(
);
}
}
void
CodegenLLVM
::
visit
(
Map
&
map
)
void
CodegenLLVM
::
visit
(
Map
&
map
)
...
@@ -124,6 +124,22 @@ void CodegenLLVM::visit(AssignMapStatement &assignment)
...
@@ -124,6 +124,22 @@ void CodegenLLVM::visit(AssignMapStatement &assignment)
void
CodegenLLVM
::
visit
(
AssignMapCallStatement
&
assignment
)
void
CodegenLLVM
::
visit
(
AssignMapCallStatement
&
assignment
)
{
{
Map
&
map
=
*
assignment
.
map
;
Call
&
call
=
*
assignment
.
call
;
if
(
call
.
func
==
"count"
)
{
AllocaInst
*
key
=
b_
.
CreateAllocaBPF
(
b_
.
getInt64Ty
());
b_
.
CreateStore
(
b_
.
getInt64
(
0
),
key
);
// TODO variable key
Value
*
oldval
=
b_
.
CreateMapLookupElem
(
map
,
key
);
AllocaInst
*
newval
=
b_
.
CreateAllocaBPF
(
b_
.
getInt64Ty
());
b_
.
CreateStore
(
b_
.
CreateAdd
(
oldval
,
b_
.
getInt64
(
1
)),
newval
);
b_
.
CreateMapUpdateElem
(
map
,
key
,
newval
);
}
else
{
abort
();
}
}
}
void
CodegenLLVM
::
visit
(
Predicate
&
pred
)
void
CodegenLLVM
::
visit
(
Predicate
&
pred
)
...
...
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