Skip to content

Commit

Permalink
Added README.md in 'pna_nic' and 'portable_common' directories
Browse files Browse the repository at this point in the history
Signed-off-by: Rupesh Chiluka <rchiluka@marvell.com>
  • Loading branch information
rupesh-chiluka-marvell committed Jul 30, 2024
1 parent 367100d commit fb4497d
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 11 deletions.
29 changes: 29 additions & 0 deletions backends/bmv2/pna_nic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# BMv2 `pna_nic` Backend

This directory contains components specific to the BMv2's PNA NIC (Portable NIC Architecture) backend in the P4C compiler. The files in this folder depend on each other, on the files in the `bmv2/common` and `portable_common` directories. Most of the classes are inherited from the classes in the `portable_common` directory.

Output Binary: `p4c-bm2-pna`

#### pnaProgramStructure.h, pnaProgramStructure.cpp

Defines and implements the program structure (metadata, parsers, controls, and deparsers) and parsing logic specific to the BMv2's PNA NIC backend.

##### midend.h, midend.cpp

Defines the mid-end processing of the PNA NIC compiler. Performs various transformations and optimizations on the program's Intermediate Representation (IR).

##### options.h, options.cpp

Manages the command-line options for the PNA NIC compiler.

##### pnaNic.h, pnaNic.cpp

Provides backend implementation to the BMv2's PNA NIC compiler.

##### main.cpp

Sets up compilation environment, integrates various components, and executes the PNA NIC compiler.

##### version.h.cmake

Defines macros containing version information for the PNA NIC compiler.
23 changes: 23 additions & 0 deletions backends/bmv2/portable_common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# `portable_common`

This directory contains reusable components common to both the `psa_switch` and `pna_nic` backends.

##### midend.h, midend.cpp

Defines the common mid-end processing of both the `psa_switch` and `pna_nic` backends.

##### options.h, options.cpp

Defines the common command-line options of both the `psa_switch` and `pna_nic` backends.

##### portable.h, portable.cpp

Defines common functionalities that generate representations of P4 programs.

----

The files `portableProgramStructure.h` and `portableProgramStructure.cpp` are in the `backends/common` directory.

#### portableProgramStructure.h, portableProgramStructure.cpp

Defines and implements the common program structure of both the `psa_switch` and `pna_nic` backends.
1 change: 0 additions & 1 deletion backends/bmv2/portable_common/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace BMV2 {

class PortableMidEnd : public MidEnd {
public:
// If p4c is run with option '--listMidendPasses', outStream is used for printing passes names
explicit PortableMidEnd(CompilerOptions &options) : MidEnd(options) {}
};

Expand Down
2 changes: 0 additions & 2 deletions backends/bmv2/portable_common/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class PortableOptions : public BMV2Options {
std::vector<const char *> *process(int argc, char *const argv[]) override;
};

// using PortableContext = P4CContextWithOptions<PortableOptions>;

} // namespace BMV2

#endif /* BACKENDS_BMV2_PORTABLE_COMMON_OPTIONS_H_ */
3 changes: 0 additions & 3 deletions backends/bmv2/portable_common/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ namespace BMV2 {

class PortableCodeGenerator {
public:
// PortableCodeGenerator() {}
// : PortableProgramStructure(refMap, typeMap) {}

unsigned error_width = 32;

void createStructLike(ConversionContext *ctxt, const IR::Type_StructLike *st,
Expand Down
1 change: 0 additions & 1 deletion backends/common/portableProgramStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class PortableProgramStructure : public P4::ProgramStructure {
/// in the scalars map.
ordered_map<cstring, const IR::Declaration_Variable *> scalars;
unsigned scalars_width = 0;
// unsigned error_width = 32;
unsigned bool_width = 1;

ordered_map<cstring, const IR::Type_Header *> header_types;
Expand Down
8 changes: 4 additions & 4 deletions cmake/FindBMV2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ find_package_handle_standard_args ("BMV2"
"Program 'psa_switch_CLI' (https://github.com/p4lang/behavioral-model.git) not found;\nSearched ${BMV2_PSA_SWITCH_SEARCH_PATHS}.\nWill not run PSA BMv2 tests."
PSA_SWITCH PSA_SWITCH_CLI)

set(BMV2_PNA_NIC_SEARCH_PATHS
${CMAKE_INSTALL_PREFIX}/bin
${P4C_SOURCE_DIR}/../behavioral-model/build/targets/pna_nic
${P4C_SOURCE_DIR}/../../behavioral-model/build/targets/pna_nic)
set(BMV2_PNA_NIC_SEARCH_PATHS
${CMAKE_INSTALL_PREFIX}/bin
${P4C_SOURCE_DIR}/../behavioral-model/build/targets/pna_nic
${P4C_SOURCE_DIR}/../../behavioral-model/build/targets/pna_nic)

# check for pna_nic
find_program (PNA_NIC_CLI pna_nic_CLI
Expand Down

0 comments on commit fb4497d

Please sign in to comment.