Commit 7ddcb8bc authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

update regexes to strip LC3plus memory instrumentation

parent e8517d5e
Loading
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -157,9 +157,14 @@ if [ "$PROJECT" = "FLOAT" ]; then

    # Clean out memory tool which breaks wmc_tool instrumentation
    perl -i -0777 -pe 's/Dyn_Mem_Deluxe_In\(((.|\s)*?)\);/$1/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/Dyn_Mem_Deluxe_Out\s*\([^)]*\)\s*;//sg' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/Dyn_Mem_Deluxe_Out\s*\([^)]*\)\s*;/;/sg' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/\sDyn_Mem_In\((.|\s)*?\);//g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/Dyn_Mem_Out\s*\([^)]*\)\s*;/;/sg' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/cplxMpy32_32_32_2\(\s*([^,]+?),\s*([^,]+?),\s*([^,]+?),\s*([^,]+?),\s*([^,]+?),\s*([^,]+?)\s*\);/do { $1 = L_sub(Mpy_32_32_0($3, $5), Mpy_32_32_0($4, $6)); $2 = L_add(Mpy_32_32_0($3, $6), Mpy_32_32_0($4, $5)); } while (0);/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/cplxMpy32_32_16_2\(\s*([^,]+?),\s*([^,]+?),\s*([^,]+?),\s*([^,]+?),\s*([^,]+?),\s*([^,]+?)\s*\);/do { $1 = L_sub(L_shr_pos(Mpy_32_16_lc3plus($3, $5), 1), L_shr_pos(Mpy_32_16_lc3plus($4, $6), 1)); $2 = L_add(L_shr_pos(Mpy_32_16_lc3plus($3, $6), 1), L_shr_pos(Mpy_32_16_lc3plus($4, $5), 1)); } while (0);/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/extractW16/extract_h/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/(UL_l|l|L_|)(sh[lr](_r)?)(?:_pos){1,2}/$1$2/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/scratchAlign\(\s*((?:.|\s)*?)\s*,\s*((?:.|\s)*?)\s*\);/(void *)(((uintptr_t)($1) + ($2) + 0x3) & ~0x3);/g' $targetdir/lib_lc3plus/*.c

fi

@@ -209,20 +214,20 @@ shopt -u extglob
find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(unsigned long\)\1\)/" \{\} \;

# run wmc_tool
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c"  >> output.txt 2>&1
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> output.txt 2>&1
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c"  >> wmc_tool_output.txt 2>&1
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> wmc_tool_output.txt 2>&1
# ISAR post-renderer and lc3plus sources only need to be instrumented in float code
if [ "$PROJECT" = "FLOAT" ]; then
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$fftdir" >> output.txt 2>&1
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$fftdir" >> wmc_tool_output.txt 2>&1
    for bak_file in $targetdir/lib_lc3plus/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    if [ -n "$fftdir" ]; then
        for bak_file in $targetdir/lib_lc3plus/fft/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    fi
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$fftdir" >> output.txt 2>&1
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$fftdir" >> wmc_tool_output.txt 2>&1
else
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> output.txt 2>&1
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> wmc_tool_output.txt 2>&1
fi

# automatically enable #define WMOPS in options.h