98 lines
2.0 KiB
C
98 lines
2.0 KiB
C
/*
|
|
|
|
This program is part of the TACLeBench benchmark suite.
|
|
Version V 1.9
|
|
|
|
Name: rad2deg
|
|
|
|
Author: unknown
|
|
|
|
Function: rad2deg performs conversion of radiant to degree
|
|
|
|
Source: MiBench
|
|
http://wwweb.eecs.umich.edu/mibench
|
|
|
|
Original name: basicmath_small
|
|
|
|
Changes: no major functional changes
|
|
|
|
License: this code is FREE with no restrictions
|
|
|
|
*/
|
|
|
|
#include "pi.h"
|
|
|
|
// Wasm loop bounds
|
|
|
|
|
|
|
|
|
|
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
|
|
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
|
|
|
|
#define rad2deg(r) ((r) * 180 / PI)
|
|
|
|
/*
|
|
Forward declaration of functions
|
|
*/
|
|
|
|
__attribute__((always_inline)) static inline void rad2deg_init(void);
|
|
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
|
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
|
rad2deg_main(void);
|
|
__attribute__((always_inline)) static inline int rad2deg_return(void);
|
|
__attribute__((noinline)) __attribute__((export_name("main")))
|
|
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
|
main(void);
|
|
|
|
/*
|
|
Declaration of global variables
|
|
*/
|
|
|
|
float rad2deg_X, rad2deg_Y;
|
|
|
|
/*
|
|
Initialization function
|
|
*/
|
|
|
|
__attribute__((always_inline)) static inline void
|
|
rad2deg_init(void) {
|
|
rad2deg_X = 0;
|
|
rad2deg_Y = 0;
|
|
}
|
|
|
|
/*
|
|
Return function
|
|
*/
|
|
|
|
__attribute__((always_inline)) static inline int
|
|
rad2deg_return(void) {
|
|
int temp = rad2deg_Y;
|
|
|
|
if (temp == 64620)
|
|
return 0;
|
|
else
|
|
return -1;
|
|
}
|
|
|
|
/*
|
|
Main functions
|
|
*/
|
|
|
|
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
|
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
|
rad2deg_main(void) {
|
|
__pragma_loopbound(360, 360);
|
|
for (rad2deg_X = 0.0f; rad2deg_X <= (2 * PI + 1e-6f);
|
|
rad2deg_X += (PI / 180))
|
|
rad2deg_Y += rad2deg(rad2deg_X);
|
|
}
|
|
|
|
__attribute__((noinline)) __attribute__((export_name("main")))
|
|
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
|
main(void) {
|
|
rad2deg_init();
|
|
rad2deg_main();
|
|
return rad2deg_return();
|
|
}
|