Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions backends/ebpf/psa/examples/bng.p4info.txtpb
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/ebpf/psa/examples/l2l3-acl.p4info.txtpb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/ebpf/psa/examples/upf.p4info.txtpb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/ebpf/tests/p4testdata/counters.p4info.txtpb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/ebpf/tests/p4testdata/meters-direct.p4info.txtpb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ actions {
id: 21257015
name: "NoAction"
alias: "NoAction"
annotations: "@corelib"
annotations: "@noWarn(\"unused\")"
}
}
Expand Down
1 change: 1 addition & 0 deletions frontends/p4/parseAnnotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ParseAnnotations::HandlerMap ParseAnnotations::standardHandlers() {
PARSE_EMPTY("disable_optimization"_cs),
PARSE_EMPTY("unroll"_cs),
PARSE_EMPTY("nounroll"_cs),
PARSE_EMPTY(IR::Annotation::corelibAnnotation),

// String arguments. These are allowed to contain concatenation which will be
// constant-folded, so just parse them as expressions.
Expand Down
1 change: 1 addition & 0 deletions ir/annotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const cstring IR::Annotation::disableOptimizationAnnotation = "disable_optimizat
const cstring IR::Annotation::inlinedFromAnnotation = "inlinedFrom"_cs;
const cstring IR::Annotation::likelyAnnotation = "likely"_cs;
const cstring IR::Annotation::unlikelyAnnotation = "unlikely"_cs;
const cstring IR::Annotation::corelibAnnotation = "corelib"_cs;

namespace Annotations {
void addIfNew(Vector<Annotation> &annotations, cstring name, const Expression *expr,
Expand Down
1 change: 1 addition & 0 deletions ir/base.def
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class Annotation {
static const cstring inlinedFromAnnotation; /// annotation to mark block of inlined function
static const cstring likelyAnnotation; /// annotation for likely taken blocks/branchs
static const cstring unlikelyAnnotation; /// annotation for likely not taken blocks/branchs
static const cstring corelibAnnotation; // annotation marking P4-16 corelib methods / externs
toString{ return absl::StrCat("@", name); }
validate{
BUG_CHECK(!name.name.isNullOrEmpty(), "empty annotation name");
Expand Down
7 changes: 6 additions & 1 deletion p4include/core.p4
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ error {
/// not supported by the implementation.
}

@corelib
extern packet_in {
/// Read a header from the packet into a fixed-sized header @hdr and advance the cursor.
/// May trigger error PacketTooShort or StackOutOfBounds.
Expand All @@ -53,6 +54,7 @@ extern packet_in {
bit<32> length();
}

@corelib
extern packet_out {
/// Write @hdr into the output packet, advancing cursor.
/// @T can be a header type, a header stack, a header_union, or a struct
Expand All @@ -63,10 +65,11 @@ extern packet_out {
// TODO: remove from this file, convert to built-in
/// Check a predicate @check in the parser; if the predicate is true do nothing,
/// otherwise set the parser error to @toSignal, and transition to the `reject` state.
@corelib
extern void verify(in bool check, in error toSignal);

/// Built-in action that does nothing.
@noWarn("unused")
@corelib @noWarn("unused")
action NoAction() {}

/// Standard match kinds for table key fields.
Expand All @@ -87,9 +90,11 @@ match_kind {
/// The function returns a boolean, so that it can be used
/// as a global constant value in a program, e.g.:
/// const bool _check = static_assert(V1MODEL_VERSION > 20180000, "Expected a v1 model version >= 20180000");
@corelib
extern bool static_assert(bool check, string message);

/// Like the above but using a default message.
@corelib
extern bool static_assert(bool check);

#endif /* _CORE_P4_ */
10 changes: 5 additions & 5 deletions testdata/p4_14_samples_outputs/01-BigMatch-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -64,13 +64,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@noWarn("unused") @name(".NoAction") action NoAction_4() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_4() {
}
@noWarn("unused") @name(".NoAction") action NoAction_5() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_5() {
}
@noWarn("unused") @name(".NoAction") action NoAction_6() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_6() {
}
@name(".nop") action nop_2() {
}
Expand Down
10 changes: 5 additions & 5 deletions testdata/p4_14_samples_outputs/01-BigMatch-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -68,13 +68,13 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@noWarn("unused") @name(".NoAction") action NoAction_4() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_4() {
}
@noWarn("unused") @name(".NoAction") action NoAction_5() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_5() {
}
@noWarn("unused") @name(".NoAction") action NoAction_6() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_6() {
}
@name(".nop") action nop_2() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@name(".a1") action a1() {
meta.m.f1 = 32w1;
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_14_samples_outputs/01-DeadMetadata1-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@name(".a1") action a1() {
meta._m_f10 = 32w1;
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_14_samples_outputs/01-FullPHV-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@name(".a1") action a1() {
meta.m.field_8_01 = 8w1;
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_14_samples_outputs/01-FullPHV-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@name(".a1") action a1() {
meta._m_field_8_010 = 8w1;
Expand Down
6 changes: 3 additions & 3 deletions testdata/p4_14_samples_outputs/01-NoDeps-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -51,9 +51,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@noWarn("unused") @name(".NoAction") action NoAction_4() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_4() {
}
@name(".nop") action nop_2() {
}
Expand Down
6 changes: 3 additions & 3 deletions testdata/p4_14_samples_outputs/01-NoDeps-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -51,9 +51,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@noWarn("unused") @name(".NoAction") action NoAction_4() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_4() {
}
@name(".nop") action nop_2() {
}
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_14_samples_outputs/02-BadSizeField-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -59,7 +59,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@name(".nop") action nop_2() {
}
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_14_samples_outputs/02-BadSizeField-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -59,7 +59,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@name(".nop") action nop_2() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@name(".a1") action a1() {
meta.m.f1 = 32w1;
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_14_samples_outputs/02-DeadMetadata2-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@name(".a1") action a1() {
meta._m_f10 = 32w1;
Expand Down
10 changes: 5 additions & 5 deletions testdata/p4_14_samples_outputs/02-FullPHV1-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@noWarn("unused") @name(".NoAction") action NoAction_4() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_4() {
}
@noWarn("unused") @name(".NoAction") action NoAction_5() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_5() {
}
@name(".a1") action a1() {
meta.m.field_8_01 = 8w1;
Expand Down
10 changes: 5 additions & 5 deletions testdata/p4_14_samples_outputs/02-FullPHV1-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,15 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@noWarn("unused") @name(".NoAction") action NoAction_4() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_4() {
}
@noWarn("unused") @name(".NoAction") action NoAction_5() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_5() {
}
@name(".a1") action a1() {
meta._m_field_8_010 = 8w1;
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_14_samples_outputs/02-SplitEthernet-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -65,7 +65,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@name(".nop") action nop_2() {
}
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_14_samples_outputs/02-SplitEthernet-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".nop") action nop() {
}
Expand All @@ -65,7 +65,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_3() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_3() {
}
@name(".nop") action nop_2() {
}
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_14_samples_outputs/03-DeadMetadata3-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@noWarn("unused") @name(".NoAction") action NoAction_1() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_1() {
}
@noWarn("unused") @name(".NoAction") action NoAction_2() {
@corelib @noWarn("unused") @name(".NoAction") action NoAction_2() {
}
@name(".a1") action a1() {
meta.m.f1 = 32w1;
Expand Down
Loading
Loading