Comments (3)
@kfcripps This behavior has existed in p4c for quite some time. I will send links to some other p4c issues that I am aware of from years back with some discussion on the topic, but if I am recalling correctly, the reason that p4c internally takes one action and makes multiple copies of it, one for each table it is used within, has its motivation in allowing each of those copies to be optimized independently of each other, based upon the context in which the table invoking it is applied.
Here is the oldest issue I could find with the most discussion on it:
Here are some later issues, where either other people rediscovered this, or a similar thing, or in some case I probably forgot about the old one and filed another. As one of my comments in the first issue linked below says, I would love it if we could get all the stakeholders involved into a discussion with the goal of coming up with an answer to this.
There is also a PR that started with one potential change, and I believe the discussion on it led to a proposal for a different approach, one which would be a small p4c change, but I haven't thought about the details in a while to have a good evaluation of either of those proposed changes at this moment:
from p4c.
Similarly, the following P4 program:
header h_t {
bit<8> f;
}
control C() {
action bar() {
}
table t {
actions = { bar; }
default_action = bar;
}
table t2 {
actions = { bar; }
default_action = bar;
}
apply {
t.apply();
t2.apply();
}
}
control proto();
package top(proto p);
top(C()) main;
gets transformed into:
header h_t {
bit<8> f;
}
control C() {
@name("C.bar") action bar() {
}
@name("C.bar") action bar_1() {
}
@name("C.t") table t_0 {
actions = {
bar();
}
default_action = bar();
}
@name("C.t2") table t2_0 {
actions = {
bar_1();
}
default_action = bar_1();
}
apply {
t_0.apply();
t2_0.apply();
}
}
control proto();
package top(proto p);
top(C()) main;
so we end up with two actions defined in the same scope that have the same local name (C.bar
). Is this a bug per the spec?
from p4c.
@jphurl @oleg-ran-amd @rsmith-pensando
from p4c.
Related Issues (20)
- Wrong error message when arbitrary-precision int is shifted by runtime value
- Consider a centralized repository for dependency management? HOT 8
- Constant folding of bit width expressions is no longer complete
- Fix broken Ubuntu 18.04 test by pinning Boost dependencies using FetchContent
- Result of extern function call used in switch expression is incorrectly marked as a compile-time constant
- Emit the initial default action of a table in the P4Info file.
- Question about Static Analyzer HOT 2
- idea: IR validator, programatic pass pre/post conditions HOT 1
- Reduce p4c compile time HOT 15
- Spurious Bazel failures when compiling the graphs back end HOT 12
- [RFC] Make cstring constructor from `char*` explicit and `string_view` conversion implicit HOT 6
- Fix invalid format strings HOT 1
- Informing downstream compilers about sigificant code changes and how to migrate? HOT 4
- Improve json library internals HOT 2
- BDWGC and Z3 interact badly
- Unify debug / user-side node stringification HOT 1
- Build errors with gcc 14 HOT 9
- Clean up P4C namespaces
- Compiler does not reject assignment of `int` to header / runtime use of `int`
- Invalid include in p4fmt.cpp HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p4c.