Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the assembler to P4C. #70

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Run tests
run: |
# FIXME: Move these into a separate test suite.
ENABLE_BF_ASM=TRUE make -C build tna_counter install
make -C build tna_counter install
export SDE=`pwd`
export SDE_INSTALL="`pwd`/install"

Expand Down
4 changes: 2 additions & 2 deletions cmake/P4Build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function(P4_BUILD_TARGET t arch target p4program)
separate_arguments(COMPUTED_P4PPFLAGS UNIX_COMMAND ${P4PPFLAGS})
# compile the p4 program
add_custom_command(OUTPUT ${output_files}
COMMAND ${P4C} --std ${P4_LANG} --target ${target} --arch ${arch} --enable-bf-asm ${rt_commands} -o ${CMAKE_CURRENT_BINARY_DIR}/${t}/${target} ${COMPUTED_P4PPFLAGS} ${COMPUTED_P4FLAGS} ${P4FLAGS_INTERNAL} -g ${p4program}
COMMAND ${P4C} --std ${P4_LANG} --target ${target} --arch ${arch} ${rt_commands} -o ${CMAKE_CURRENT_BINARY_DIR}/${t}/${target} ${COMPUTED_P4PPFLAGS} ${COMPUTED_P4FLAGS} ${P4FLAGS_INTERNAL} -g ${p4program}
COMMAND ${P4C-GEN-BFRT-CONF} --name ${t} --device ${chiptype} --testdir ./${t}/${target}
--installdir share/${target}pd/${t} --pipe `${P4C-MANIFEST-CONFIG} --pipe ./${t}/${target}/manifest.json`
DEPENDS ${p4program} bf-p4c
Expand Down Expand Up @@ -159,7 +159,7 @@ function(P4_BUILD_PD_TARGET t arch target p4program)
separate_arguments(COMPUTED_PDFLAGS UNIX_COMMAND ${PDFLAGS})
# compile the p4 program
add_custom_command(OUTPUT ${t}/${target}/manifest.json
COMMAND ${P4C} --std ${P4_LANG} --target ${target} --arch ${arch} --enable-bf-asm --no-bf-rt-schema -o ${CMAKE_CURRENT_BINARY_DIR}/${t}/${target} ${COMPUTED_P4PPFLAGS} ${COMPUTED_P4FLAGS} ${P4FLAGS_INTERNAL} -g ${p4program}
COMMAND ${P4C} --std ${P4_LANG} --target ${target} --arch ${arch} --no-bf-rt-schema -o ${CMAKE_CURRENT_BINARY_DIR}/${t}/${target} ${COMPUTED_P4PPFLAGS} ${COMPUTED_P4FLAGS} ${P4FLAGS_INTERNAL} -g ${p4program}
DEPENDS ${p4program} bf-p4c
)

Expand Down
2 changes: 1 addition & 1 deletion p4studio/utils/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def try_execute(command: Union[str, Sequence[str]], working_dir: Optional[PathLi
while process.poll() is None:
while True:
stdout = process.stdout
line = stdout.readline().decode().rstrip() if stdout else ""
line = stdout.readline().decode('latin-1').rstrip() if stdout else ""
if line:
compact_log().log(line)
else:
Expand Down
13 changes: 3 additions & 10 deletions pkgsrc/p4-compilers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# First, check whether the repository needs to be initialized.

# Check if the submodule directory exists.
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/p4c/CMakeLists.txt")
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/p4c/CMakeLists.txt")
message(STATUS "Initializing P4C submodule...")
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMODULE_RESULT
)

Expand All @@ -17,10 +16,6 @@ else()
endif()


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(ENABLE_BF_ASM TRUE)
add_definitions("-DBAREFOOT_INTERNAL=1")
add_definitions("-DHAVE_JBAY=1")
set (P4C_USE_PREINSTALLED_ABSEIL ON CACHE BOOL "")
Expand All @@ -42,12 +37,10 @@ set (ENABLE_P4FMT OFF CACHE BOOL "")
set (ENABLE_P4TEST OFF CACHE BOOL "")
set (ENABLE_P4C_GRAPHS OFF CACHE BOOL "")
# set (ENABLE_LTO ON CACHE BOOL "")
# Enable Unity builds for the compiler and bf-asm to speed up compilation.
# Enable Unity builds for the compiler to speed up compilation.
set(CMAKE_UNITY_BUILD_PREV ${CMAKE_UNITY_BUILD})
set(CMAKE_UNITY_BUILD ON)
add_subdirectory(p4c)

add_subdirectory(bf-asm)
set(CMAKE_UNITY_BUILD ${CMAKE_UNITY_BUILD_PREV})


Expand Down
Loading