Add wasm tacle-bench targets

This commit is contained in:
2026-06-12 20:06:22 +02:00
parent 30daa8a00c
commit 08c2e9c13d
1122 changed files with 520422 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# ~~~
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2026, Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU)
# ~~~
cmake_minimum_required(VERSION 3.20)
project(fac)
set(TACLEBENCH_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}/../../..")
set(REPOSITORY_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../..")
set(APP_TARGET_NAME "${CMAKE_PROJECT_NAME}")
if(DEFINED TACLEBENCH_VARIANT AND "${TACLEBENCH_VARIANT}" STREQUAL "inline")
set(APP_SOURCE_FILE_PATH
"generated/modified_sources/inline/fac.c")
else()
set(APP_SOURCE_FILE_PATH
"generated/modified_sources/default/fac.c")
endif()
include(${REPOSITORY_ROOT_PATH}/cmake/taclebench_wasm.cmake)

View File

@ -0,0 +1,23 @@
File: fac.c
Original provenience: MDH WCET BENCHMARK SUITE
2016-02-26:
- Added TACLeBench header to line 1
- Removed unused functions
- Removed unused variables
- Declared s a global variable and renamed it to fac_s
- Declared n a global variable and renamed it to fac_n
- Renamed function fac to fac_fac
- Renamed function main to fac_main
- Created new function main, calling fac_init, fac_main and
returning fac_return
- Changed return type of fac_main to void
- Move initialization code into new function fac_init
- Reordered functions in source code: initialization- and
return-value-related functions first, followed by algorithm core
functions, followed by main functions
- Applied code formatting with astyle as in the example
2016-03-09:
- Subtract expected result from return value, such that the return code of the
program is 0 if success.

View File

@ -0,0 +1,97 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: fac
Author: unknown
Function: fac is a program to calculate factorials.
This program computes the sum of the factorials
from zero to five.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/fac/fac.c
Changes: CS 2006/05/19: Changed loop bound from constant to variable.
License: public domain
*/
/*
Forward declaration of functions
*/
int fac_fac( int n );
void fac_init();
int fac_return();
void fac_main();
int main( void );
/*
Declaration of global variables
*/
int fac_s;
volatile int fac_n;
/*
Initialization- and return-value-related functions
*/
void fac_init()
{
fac_s = 0;
fac_n = 5;
}
int fac_return()
{
int expected_result = 154;
return fac_s - expected_result;
}
/*
Arithmetic math functions
*/
int fac_fac ( int n )
{
if ( n == 0 )
return 1;
else
return ( n * fac_fac ( n - 1 ) );
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) fac_main ()
{
int i;
_Pragma( "loopbound min 6 max 6" )
for ( i = 0; i <= fac_n; i++ ) {
_Pragma( "marker recursivecall" )
fac_s += fac_fac ( i );
_Pragma( "flowrestriction 1*fac_fac <= 6*recursivecall" )
}
}
int main ( void )
{
fac_init();
fac_main();
return ( fac_return() );
}

Binary file not shown.

View File

@ -0,0 +1,170 @@
(module $fac.wasm
(type (;0;) (func (param i32 i32)))
(type (;1;) (func))
(type (;2;) (func (result i32)))
(import "__pragma" "loopbound" (func $__pragma_loopbound (type 0)))
(func $__wasm_apply_data_relocs (type 1))
(func $fac_main (type 1)
(local i32 i32 i32 i32 i32 i32 i32)
i32.const 6
i32.const 6
call $__pragma_loopbound
block ;; label = @1
i32.const 0
i32.load offset=1028
i32.const 0
i32.lt_s
br_if 0 (;@1;)
i32.const 0
i32.load offset=1024
local.set 0
i32.const 0
local.set 1
i32.const 0
local.set 2
loop ;; label = @2
i32.const 1
local.set 3
block ;; label = @3
local.get 2
local.tee 4
i32.eqz
br_if 0 (;@3;)
i32.const 1
local.set 3
local.get 4
local.set 2
block ;; label = @4
local.get 4
i32.const 8
i32.lt_u
br_if 0 (;@4;)
i32.const 0
local.get 4
i32.const -8
i32.and
i32.sub
local.set 5
i32.const 1
local.set 3
i32.const 0
local.set 6
loop ;; label = @5
local.get 3
local.get 4
local.get 6
i32.add
local.tee 2
i32.mul
local.get 2
i32.const -1
i32.add
i32.mul
local.get 2
i32.const -2
i32.add
i32.mul
local.get 2
i32.const -3
i32.add
i32.mul
local.get 2
i32.const -4
i32.add
i32.mul
local.get 2
i32.const -5
i32.add
i32.mul
local.get 2
i32.const -6
i32.add
i32.mul
local.get 2
i32.const -7
i32.add
i32.mul
local.set 3
local.get 5
local.get 6
i32.const -8
i32.add
local.tee 6
i32.ne
br_if 0 (;@5;)
end
local.get 4
local.get 6
i32.add
local.set 2
end
local.get 4
i32.const 7
i32.and
i32.eqz
br_if 0 (;@3;)
local.get 1
i32.const 7
i32.and
local.set 6
loop ;; label = @4
local.get 3
local.get 2
i32.mul
local.set 3
local.get 2
i32.const -1
i32.add
local.set 2
local.get 6
i32.const -1
i32.add
local.tee 6
br_if 0 (;@4;)
end
end
local.get 1
i32.const 1
i32.add
local.set 1
local.get 4
i32.const 1
i32.add
local.set 2
local.get 0
local.get 3
i32.add
local.set 0
local.get 4
i32.const 0
i32.load offset=1028
i32.lt_s
br_if 0 (;@2;)
end
i32.const 0
local.get 0
i32.store offset=1024
end)
(func $__original_main (type 2) (result i32)
i32.const 0
i32.const 5
i32.store offset=1028
i32.const 0
i32.const 0
i32.store offset=1024
call $fac_main
i32.const 0
i32.load offset=1024
i32.const -154
i32.add)
(table (;0;) 1 1 funcref)
(memory (;0;) 1)
(global $__stack_pointer (mut i32) (i32.const 5136))
(global (;1;) i32 (i32.const 1032))
(global (;2;) i32 (i32.const 5136))
(export "memory" (memory 0))
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
(export "entrypoint" (func $fac_main))
(export "main" (func $__original_main))
(export "__data_end" (global 1))
(export "__heap_base" (global 2)))

View File

@ -0,0 +1,94 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: fac
Author: unknown
Function: fac is a program to calculate factorials.
This program computes the sum of the factorials
from zero to five.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/fac/fac.c
Changes: CS 2006/05/19: Changed loop bound from constant to variable.
License: public domain
*/
/*
Forward declaration of functions
*/
// Wasm loop bounds
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
int fac_fac(int n);
void fac_init();
int fac_return();
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
fac_main();
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
/*
Declaration of global variables
*/
int fac_s;
volatile int fac_n;
/*
Initialization- and return-value-related functions
*/
void
fac_init() {
fac_s = 0;
fac_n = 5;
}
int
fac_return() {
int expected_result = 154;
return fac_s - expected_result;
}
/*
Arithmetic math functions
*/
int
fac_fac(int n) {
if (n == 0)
return 1;
else
return (n * fac_fac(n - 1));
}
/*
Main functions
*/
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
fac_main() {
int i;
__pragma_loopbound(6, 6);
for (i = 0; i <= fac_n; i++) {
_Pragma("marker recursivecall") fac_s += fac_fac(i);
_Pragma("flowrestriction 1*fac_fac <= 6*recursivecall")
}
}
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
fac_init();
fac_main();
return (fac_return());
}

View File

@ -0,0 +1,102 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 1.x
Name: fac
Author: unknown
Function: fac is a program to calculate factorials.
This program computes the sum of the factorials
from zero to five.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/fac/fac.c
Changes: CS 2006/05/19: Changed loop bound from constant to variable.
License: public domain
*/
/*
Forward declaration of functions
*/
// Wasm loop bounds
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
__attribute__((always_inline)) static inline int fac_fac(int n);
__attribute__((always_inline)) static inline void fac_init();
__attribute__((always_inline)) static inline int fac_return();
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
fac_main();
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void);
/*
Declaration of global variables
*/
int fac_s;
volatile int fac_n;
/*
Initialization- and return-value-related functions
*/
__attribute__((always_inline)) static inline void
fac_init() {
fac_s = 0;
fac_n = 5;
}
__attribute__((always_inline)) static inline int
fac_return() {
int expected_result = 154;
return fac_s - expected_result;
}
/*
Arithmetic math functions
*/
__attribute__((always_inline)) static inline int
fac_fac(int n) {
if (n == 0)
return 1;
else
return (n * fac_fac(n - 1));
}
/*
Main functions
*/
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
fac_main() {
int i;
__pragma_loopbound(6, 6);
for (i = 0; i <= fac_n; i++) {
_Pragma("marker recursivecall") fac_s += fac_fac(i);
_Pragma("flowrestriction 1*fac_fac <= 6*recursivecall")
}
}
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
fac_init();
fac_main();
return (fac_return());
}