-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support lookahead in ebpf backend (#1602)
- Loading branch information
Mihai Budiu
authored
Nov 28, 2018
1 parent
355499a
commit 975c15b
Showing
13 changed files
with
854 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "singleArgumentSelect.h" | ||
|
||
namespace P4 { | ||
|
||
static const IR::Expression* convertList(const IR::Expression* expression) { | ||
auto list = expression->to<IR::ListExpression>(); | ||
if (list == nullptr) | ||
return expression; | ||
BUG_CHECK(list->components.size() > 0, "%1%: No components", list); | ||
auto expr = list->components.at(0); | ||
for (size_t i = 1; i < list->components.size(); i++) | ||
expr = new IR::Concat(expr, list->components.at(i)); | ||
return expr; | ||
} | ||
|
||
bool SingleArgumentSelect::preorder(IR::SelectExpression* expression) { | ||
if (expression->select->size() <= 1) | ||
return false; | ||
auto conv = convertList(expression->select); | ||
auto list = new IR::ListExpression(IR::Vector<IR::Expression>()); | ||
list->push_back(conv); | ||
expression->select = list; | ||
return true; | ||
} | ||
|
||
bool SingleArgumentSelect::preorder(IR::SelectCase* selCase) { | ||
selCase->keyset = convertList(selCase->keyset); | ||
return false; | ||
} | ||
|
||
} // namespace P4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright 2018 VMware, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#ifndef _MIDEND_SINGLEARGUMENTSELECT_H_ | ||
#define _MIDEND_SINGLEARGUMENTSELECT_H_ | ||
|
||
#include "ir/ir.h" | ||
|
||
namespace P4 { | ||
|
||
/** | ||
Converts select(a, b, c) into select(a ++ b ++ c). | ||
A similar transformation is done for the labels. | ||
@pre | ||
This should be run after SimplifySelectList and RemoveSelectBooleans. | ||
It assumes that all select arguments are scalar values. | ||
*/ | ||
class SingleArgumentSelect : public Modifier { | ||
public: | ||
SingleArgumentSelect() { | ||
setName("SingleArgumentSelect"); | ||
} | ||
|
||
bool preorder(IR::SelectCase* selCase) override; | ||
bool preorder(IR::SelectExpression* expression) override; | ||
}; | ||
|
||
} // namespace P4 | ||
|
||
#endif /* _MIDEND_SINGLEARGUMENTSELECT_H_ */ |
Oops, something went wrong.