-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support table.apply().miss * Convert table.apply().miss to not table.apply.hit()
- Loading branch information
Mihai Budiu
authored
Nov 6, 2019
1 parent
df500ee
commit bd0308a
Showing
31 changed files
with
497 additions
and
16 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
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
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,29 @@ | ||
/* | ||
Copyright 2019 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. | ||
*/ | ||
|
||
#include "removeMiss.h" | ||
#include "frontends/p4/tableApply.h" | ||
|
||
namespace P4 { | ||
|
||
const IR::Node* DoRemoveMiss::preorder(IR::Member* expression) { | ||
if (!TableApplySolver::isMiss(expression, refMap, typeMap)) | ||
return expression; | ||
auto hit = new IR::Member(expression->expr, IR::Type_Table::hit); | ||
return new IR::LNot(hit); | ||
} | ||
|
||
} // 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,54 @@ | ||
/* | ||
Copyright 2019 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_REMOVEMISS_H_ | ||
#define _MIDEND_REMOVEMISS_H_ | ||
|
||
#include "ir/ir.h" | ||
#include "frontends/p4/typeChecking/typeChecker.h" | ||
#include "frontends/common/resolveReferences/referenceMap.h" | ||
#include "frontends/p4/typeMap.h" | ||
|
||
namespace P4 { | ||
|
||
/** | ||
* This visitor converts table.apply().miss into !table.apply().hit. | ||
*/ | ||
class DoRemoveMiss : public Transform { | ||
ReferenceMap* refMap; | ||
TypeMap* typeMap; | ||
public: | ||
DoRemoveMiss(ReferenceMap* refMap, TypeMap* typeMap) : | ||
refMap(refMap), typeMap(typeMap) | ||
{ visitDagOnce = false; CHECK_NULL(typeMap); setName("DoRemoveMiss"); } | ||
const IR::Node* preorder(IR::Member* expression) override; | ||
}; | ||
|
||
class RemoveMiss : public PassManager { | ||
public: | ||
RemoveMiss(ReferenceMap* refMap, TypeMap* typeMap, | ||
TypeChecking* typeChecking = nullptr) { | ||
if (!typeChecking) | ||
typeChecking = new TypeChecking(refMap, typeMap); | ||
passes.push_back(typeChecking); | ||
passes.push_back(new DoRemoveMiss(refMap, typeMap)); | ||
setName("RemoveMiss"); | ||
} | ||
}; | ||
|
||
} // namespace P4 | ||
|
||
#endif /* _MIDEND_REMOVEMISS_H_ */ |
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
File renamed without changes.
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,42 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header hdr { | ||
bit<32> b; | ||
} | ||
|
||
struct Headers { | ||
hdr h; | ||
} | ||
|
||
struct Meta {} | ||
|
||
parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
control vrfy(inout Headers h, inout Meta m) { apply {} } | ||
control update(inout Headers h, inout Meta m) { apply {} } | ||
|
||
control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply {} } | ||
|
||
control deparser(packet_out b, in Headers h) { | ||
apply { b.emit(h); } | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
table t { | ||
key = { h.h.b : exact; } | ||
actions = { NoAction; } | ||
default_action = NoAction; | ||
} | ||
apply { | ||
if (t.apply().miss) { | ||
h.h.setInvalid(); | ||
} | ||
} | ||
} | ||
|
||
V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.