Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ endif()
if( ${TARGET_OS} STREQUAL "Linux" )
set(OS "LINUX")
set(OSNAME "Linux")
elseif( ${TARGET_OS} STREQUAL "Darwin" )
set(OS "OSX")
set(OSNAME "macOS")
else()
message("Unsupported OS: ${TARGET_OS}" )
return()
Expand Down
12 changes: 9 additions & 3 deletions runtime/flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ endif ()
# flang* executables
SET(CMAKE_Fortran_FLAGS "-B ${LLVM_RUNTIME_OUTPUT_INTDIR} ${CMAKE_Fortran_FLAGS}")

include(CheckSymbolExists)
check_symbol_exists(clock_settime "time.h" HAVE_CLOCK_SETTIME)
configure_file(libflang_config.h.in libflang_config.h)

SET(FTN_INTRINSICS_DESC_INDEP
abort3f.c
access3f.c
Expand Down Expand Up @@ -508,10 +512,12 @@ add_dependencies(flang_shared flang_static)

target_link_libraries(flang_shared flangrti_shared)
# Resolve symbols against libm and librt
if (NOT MSVC)
target_link_libraries(flang_shared m rt)
else()
if (MSVC)
set_target_properties(flang_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
elseif (APPLE)
target_link_libraries(flang_shared m)
else()
target_link_libraries(flang_shared m rt)
endif()

set(SHARED_LIBRARY FALSE)
Expand Down
1 change: 0 additions & 1 deletion runtime/flang/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ typedef char sbool; /* short boolean (for use in large structs) */
#define assert(ex)
#endif

extern char *strcpy();
#define STASH(str) (strcpy((char *)malloc(strlen(str) + 1), str))

/* defs used by __fortio_error */
Expand Down
4 changes: 4 additions & 0 deletions runtime/flang/libflang_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef LIBFLANG_CONFIG_H
#define LIBFLANG_CONFIG_H
#cmakedefine HAVE_CLOCK_SETTIME
#endif
7 changes: 4 additions & 3 deletions runtime/flang/stime3f.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

/* stime3f.c - Implements LIB3F stime subprogram. */

#ifndef WINNT

#include "libflang_config.h"
#include <time.h>
#include "io3f.h"
#include "ent3f.h"

#ifdef HAVE_CLOCK_SETTIME

int ENT3F(STIME, stime)(int *tp)
{
int i;
Expand All @@ -27,4 +28,4 @@ int ENT3F(STIME, stime)(int *tp)
return i;
}

#endif /* !WINNT */
#endif /* HAVE_CLOCK_SETTIME */
4 changes: 4 additions & 0 deletions runtime/flangrti/ktrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ __ktrap(void)
excepts |= FE_UNDERFLOW;
if (bv & 0x100)
excepts |= FE_INEXACT;
#ifdef TARGET_OSX
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this on my mac. Neither of __fenv_feenableexcept() or feenableexcept() could be found...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the function was moved from flangrti to libpgmath. https://github.com/flang-compiler/flang/blob/master/runtime/libpgmath/lib/common/fltfenv.c

__fenv_feenableexcept(excepts);
#else
feenableexcept(excepts); /* glibc 2.2 extension to fenv.h */
#endif
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/flangrti/trace_lin.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#else
#include <execinfo.h>
#include <unistd.h>
#include <linux/limits.h>
#include <limits.h>
#include <sys/types.h>
#endif
#include <stdioInterf.h>
Expand Down
6 changes: 3 additions & 3 deletions runtime/libpgmath/lib/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ elseif(${LIBPGMATH_SYSTEM_PROCESSOR} MATCHES "ppc64le")
mth_128defs_init.c
mth_128defs_stats.c)
libmath_add_object_library("${MTH_INTRINSICS_SRCS}" "${FLAGS}" "${DEFINITIONS}" "mth_intrinsics")

set(SRCS
kidnnt.c
sincos.c
Expand Down Expand Up @@ -454,7 +454,7 @@ else()
libmath_add_object_library("${TARGET_NAME}.c" "${FLAGS}" "${DEFINITIONS}" "${TARGET_NAME}_build")
add_dependencies("${TARGET_NAME}_build" ${TARGET_NAME})
endif()

# Generate tmp-mth_statsdefs.h
set(TARGET_NAME "tmp-mth_statsdefs")
add_custom_command(OUTPUT ${TARGET_NAME}.h PRE_BUILD
Expand All @@ -466,6 +466,6 @@ add_dependencies(dispatch ${TARGET_NAME} tmp-mth_alldefs)
add_dependencies(dispatch ${TARGET_NAME} tmp-mth_statsdefs)
target_include_directories(dispatch
BEFORE
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../${PROCESSOR}/math_tables
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../generic/math_tables)
40 changes: 29 additions & 11 deletions runtime/libpgmath/lib/common/dceil.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,44 @@
*/

#include "mthdecls.h"
#if defined(__SSE4_1__) || defined(__AVX__)
#include <immintrin.h>
#endif

#if defined(__AVX__)
#if defined(TARGET_X8664)
/*
* For X8664, implement both SSE and AVX versions of __mth_i_ceil using ISA
* instruction extensions.
*
* Using inline assembly allows both the SSE and AVX versions of the routine
* to be compiled in a single unit.
*
* The following asm statements is equivalent to:
* return _mm_cvtss_f32(_mm_ceil_ss(_mm_set1_ps(x), _mm_set1_ps(x)));
* But without the need for separate compiliations for SSE4.1 and AVX ISA
* extensions.
*/

double
__mth_i_dceil_avx(double x)
__mth_i_dceil_sse(double x)
{
return _mm_cvtsd_f64(_mm_ceil_sd(_mm_set1_pd(x), _mm_set1_pd(x)));
__asm__(
"roundsd $0x2,%0,%0"
:"+x"(x)
);
return x;
}
#elif defined(__SSE4_1__)

double
__mth_i_dceil_sse(double x)
__mth_i_dceil_avx(double x)
{
return _mm_cvtsd_f64(_mm_ceil_sd(_mm_set1_pd(x), _mm_set1_pd(x)));
__asm__(
"vroundsd $0x2,%0,%0,%0"
:"+x"(x)
);
return x;
}
#else
#endif

double
__mth_i_dceil(double x)
{
return ceil(x);
}
#endif
40 changes: 29 additions & 11 deletions runtime/libpgmath/lib/common/dfloor.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,44 @@
*/

#include "mthdecls.h"
#if defined(__SSE4_1__) || defined(__AVX__)
#include <immintrin.h>
#endif

#if defined(__AVX__)
#if defined(TARGET_X8664)
/*
* For X8664, implement both SSE and AVX versions of __mth_i_dfloor using ISA
* instruction extensions.
*
* Using inline assembly allows both the SSE and AVX versions of the routine
* to be compiled in a single unit.
*
* The following asm statements is equivalent to:
* return _mm_cvtss_f32(_mm_floor_sd(_mm_set1_ps(x), _mm_set1_ps(x)));
* But without the need for separate compiliations for SSE4.1 and AVX ISA
* extensions.
*/

double
__mth_i_dfloor_avx(double x)
__mth_i_dfloor_sse(double x)
{
return _mm_cvtsd_f64(_mm_floor_sd(_mm_set1_pd(x), _mm_set1_pd(x)));
__asm__(
"roundsd $0x1,%0,%0"
:"+x"(x)
);
return x;
}
#elif defined(__SSE4_1__)

double
__mth_i_dfloor_sse(double x)
__mth_i_dfloor_avx(double x)
{
return _mm_cvtsd_f64(_mm_floor_sd(_mm_set1_pd(x), _mm_set1_pd(x)));
__asm__(
"vroundsd $0x1,%0,%0,%0"
:"+x"(x)
);
return x;
}
#else
#endif

double
__mth_i_dfloor(double x)
{
return floor(x);
}
#endif
40 changes: 29 additions & 11 deletions runtime/libpgmath/lib/common/floor.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,44 @@
*/

#include "mthdecls.h"
#if defined(__SSE4_1__) || defined(__AVX__)
#include <immintrin.h>
#endif

#if defined(__AVX__)
#if defined(TARGET_X8664)
/*
* For X8664, implement both SSE and AVX versions of __mth_i_floor using ISA
* instruction extensions.
*
* Using inline assembly allows both the SSE and AVX versions of the routine
* to be compiled in a single unit.
*
* The following asm statements is equivalent to:
* return _mm_cvtss_f32(_mm_floor_ss(_mm_set1_ps(x), _mm_set1_ps(x)));
* But without the need for separate compiliations for SSE4.1 and AVX ISA
* extensions.
*/

float
__mth_i_floor_avx(float x)
__mth_i_floor_sse(float x)
{
return _mm_cvtss_f32(_mm_floor_ss(_mm_set1_ps(x), _mm_set1_ps(x)));
__asm__(
"roundss $0x1,%0,%0"
:"+x"(x)
);
return x;
}
#elif defined(__SSE4_1__)

float
__mth_i_floor_sse(float x)
__mth_i_floor_avx(float x)
{
return _mm_cvtss_f32(_mm_floor_ss(_mm_set1_ps(x), _mm_set1_ps(x)));
__asm__(
"vroundss $0x1,%0,%0,%0"
:"+x"(x)
);
return x;
}
#else
#endif

float
__mth_i_floor(float x)
{
return floorf(x);
}
#endif
10 changes: 8 additions & 2 deletions runtime/libpgmath/lib/x86_64/math_tables/mth_ceildefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
*
*/

MTHINTRIN(ceil , ss , any , __mth_i_ceil , __mth_i_ceil , __mth_i_ceil ,__math_dispatch_error)
MTHINTRIN(ceil , ds , any , __mth_i_dceil , __mth_i_dceil , __mth_i_dceil ,__math_dispatch_error)
MTHINTRIN(ceil , ss , any , __mth_i_ceil , __mth_i_ceil , __mth_i_ceil ,__math_dispatch_error)
MTHINTRIN(ceil , ds , em64t , __mth_i_dceil , __mth_i_dceil , __mth_i_dceil ,__math_dispatch_error)
MTHINTRIN(ceil , ds , sse4 , __mth_i_dceil_sse , __mth_i_dceil_sse , __mth_i_dceil_sse ,__math_dispatch_error)
MTHINTRIN(ceil , ds , avx , __mth_i_dceil_avx , __mth_i_dceil_avx , __mth_i_dceil_avx ,__math_dispatch_error)
MTHINTRIN(ceil , ds , avxfma4 , __mth_i_dceil_avx , __mth_i_dceil_avx , __mth_i_dceil_avx ,__math_dispatch_error)
MTHINTRIN(ceil , ds , avx2 , __mth_i_dceil_avx , __mth_i_dceil_avx , __mth_i_dceil_avx ,__math_dispatch_error)
MTHINTRIN(ceil , ds , avx512knl , __mth_i_dceil_avx , __mth_i_dceil_avx , __mth_i_dceil_avx ,__math_dispatch_error)
MTHINTRIN(ceil , ds , avx512 , __mth_i_dceil_avx , __mth_i_dceil_avx , __mth_i_dceil_avx ,__math_dispatch_error)
MTHINTRIN(ceil , sv4 , any , __gs_ceil_4_f , __gs_ceil_4_r , __gs_ceil_4_p ,__math_dispatch_error)
MTHINTRIN(ceil , dv2 , any , __gd_ceil_2_f , __gd_ceil_2_r , __gd_ceil_2_p ,__math_dispatch_error)
MTHINTRIN(ceil , sv8 , any , __gs_ceil_8_f , __gs_ceil_8_r , __gs_ceil_8_p ,__math_dispatch_error)
Expand Down
16 changes: 14 additions & 2 deletions runtime/libpgmath/lib/x86_64/math_tables/mth_floordefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@
*
*/

MTHINTRIN(floor , ss , any , __mth_i_floor , __mth_i_floor , __mth_i_floor ,__math_dispatch_error)
MTHINTRIN(floor , ds , any , __mth_i_dfloor , __mth_i_dfloor , __mth_i_dfloor ,__math_dispatch_error)
MTHINTRIN(floor , ss , em64t , __mth_i_floor , __mth_i_floor , __mth_i_floor ,__math_dispatch_error)
MTHINTRIN(floor , ds , em64t , __mth_i_dfloor , __mth_i_dfloor , __mth_i_dfloor ,__math_dispatch_error)
MTHINTRIN(floor , ss , sse4 , __mth_i_floor_sse , __mth_i_floor_sse , __mth_i_floor_sse ,__math_dispatch_error)
MTHINTRIN(floor , ds , sse4 , __mth_i_dfloor_sse , __mth_i_dfloor_sse , __mth_i_dfloor_sse ,__math_dispatch_error)
MTHINTRIN(floor , ss , avx , __mth_i_floor_avx , __mth_i_floor_avx , __mth_i_floor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ds , avx , __mth_i_dfloor_avx , __mth_i_dfloor_avx , __mth_i_dfloor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ss , avxfma4 , __mth_i_floor_avx , __mth_i_floor_avx , __mth_i_floor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ds , avxfma4 , __mth_i_dfloor_avx , __mth_i_dfloor_avx , __mth_i_dfloor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ss , avx2 , __mth_i_floor_avx , __mth_i_floor_avx , __mth_i_floor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ds , avx2 , __mth_i_dfloor_avx , __mth_i_dfloor_avx , __mth_i_dfloor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ss , avx512knl , __mth_i_floor_avx , __mth_i_floor_avx , __mth_i_floor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ds , avx512knl , __mth_i_dfloor_avx , __mth_i_dfloor_avx , __mth_i_dfloor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ss , avx512 , __mth_i_floor_avx , __mth_i_floor_avx , __mth_i_floor_avx ,__math_dispatch_error)
MTHINTRIN(floor , ds , avx512 , __mth_i_dfloor_avx , __mth_i_dfloor_avx , __mth_i_dfloor_avx ,__math_dispatch_error)
MTHINTRIN(floor , sv4 , any , __gs_floor_4_f , __gs_floor_4_r , __gs_floor_4_p ,__math_dispatch_error)
MTHINTRIN(floor , dv2 , any , __gd_floor_2_f , __gd_floor_2_r , __gd_floor_2_p ,__math_dispatch_error)
MTHINTRIN(floor , sv8 , any , __gs_floor_8_f , __gs_floor_8_r , __gs_floor_8_p ,__math_dispatch_error)
Expand Down
1 change: 0 additions & 1 deletion tools/flang1/flang1exe/gbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ char *mkfname(const char *, const char *, const char *); /* from miscutil.c: */
bool is_xflag_bit(int);
void set_xflag(int, INT);
void set_yflag(int, INT);
void bzero(void *, size_t);
void list_init(FILE *); /* listing.c: */
void list_line(const char *); /* listing.c */
void list_page(void); /* listing.c */
Expand Down