[llvm-branch-commits] [libc] ffb2549 - [libc][NFC][Obvious] Add a missing dep.

2021-01-18 Thread Siva Chandra via llvm-branch-commits

Author: Siva Chandra
Date: 2021-01-18T22:04:20-08:00
New Revision: ffb254978cf4e7a9cdbb4cbb51bfc589072353c1

URL: 
https://github.com/llvm/llvm-project/commit/ffb254978cf4e7a9cdbb4cbb51bfc589072353c1
DIFF: 
https://github.com/llvm/llvm-project/commit/ffb254978cf4e7a9cdbb4cbb51bfc589072353c1.diff

LOG: [libc][NFC][Obvious] Add a missing dep.

Added: 


Modified: 
libc/include/CMakeLists.txt

Removed: 




diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 4c52a7615c91..d11dd464c10b 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -119,6 +119,7 @@ add_gen_header(
   DEF_FILE unistd.h.def
   GEN_HDR unistd.h
   DEPENDS
+.libc_posix_types
 .llvm_libc_common_h
 )
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] 7bd3702 - [libc] Extend the current fenv functions to aarch64.

2021-01-19 Thread Siva Chandra via llvm-branch-commits

Author: Siva Chandra
Date: 2021-01-19T12:47:54-08:00
New Revision: 7bd3702b64043fb623bf82c1d1a8a2d168142219

URL: 
https://github.com/llvm/llvm-project/commit/7bd3702b64043fb623bf82c1d1a8a2d168142219
DIFF: 
https://github.com/llvm/llvm-project/commit/7bd3702b64043fb623bf82c1d1a8a2d168142219.diff

LOG: [libc] Extend the current fenv functions to aarch64.

This change does not try to move the common parts of x86 and aarch64 and
build few abstractions over them. While this is possible, x86 story
needs a bit of cleanup, especially around manipulation of the mxcsr
register. Moreover, on x86 one can raise exceptions without performing
exception raising operations. So, all of this can be done in follow up
patches.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D94947

Added: 
libc/utils/FPUtil/aarch64/FEnv.h

Modified: 
libc/config/linux/aarch64/entrypoints.txt
libc/utils/FPUtil/FEnv.h

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 4e20903ad260..ca7252b17e64 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -20,6 +20,13 @@ set(TARGET_LIBC_ENTRYPOINTS
 # errno.h entrypoints
 libc.src.errno.__errno_location
 
+# fenv.h entrypoints
+libc.src.fenv.feclearexcept
+libc.src.fenv.fegetround
+libc.src.fenv.fesetround
+libc.src.fenv.feraiseexcept
+libc.src.fenv.fetestexcept
+
 # stdlib.h entrypoints
 libc.src.stdlib.abs
 libc.src.stdlib.labs

diff  --git a/libc/utils/FPUtil/FEnv.h b/libc/utils/FPUtil/FEnv.h
index bf520672161e..1634f5f10125 100644
--- a/libc/utils/FPUtil/FEnv.h
+++ b/libc/utils/FPUtil/FEnv.h
@@ -11,6 +11,8 @@
 
 #ifdef __x86_64__
 #include "x86_64/FEnv.h"
+#elif defined(__aarch64__)
+#include "aarch64/FEnv.h"
 #else
 #include "DummyFEnv.h"
 #endif

diff  --git a/libc/utils/FPUtil/aarch64/FEnv.h 
b/libc/utils/FPUtil/aarch64/FEnv.h
new file mode 100644
index ..ac0ef70b522d
--- /dev/null
+++ b/libc/utils/FPUtil/aarch64/FEnv.h
@@ -0,0 +1,204 @@
+//===-- aarch64 floating point env manipulation functions ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_LIBC_UTILS_FPUTIL_AARCH64_FENV_H
+#define LLVM_LIBC_UTILS_FPUTIL_AARCH64_FENV_H
+
+#include 
+#include 
+#include 
+
+#include "utils/FPUtil/FPBits.h"
+
+namespace __llvm_libc {
+namespace fputil {
+
+struct FEnv {
+  static constexpr uint32_t ToNearest = 0x0;
+  static constexpr uint32_t Upward = 0x1;
+  static constexpr uint32_t Downward = 0x2;
+  static constexpr uint32_t TowardZero = 0x3;
+
+  static constexpr uint32_t Invalid = 0x1;
+  static constexpr uint32_t DivByZero = 0x2;
+  static constexpr uint32_t Overflow = 0x4;
+  static constexpr uint32_t Underflow = 0x8;
+  static constexpr uint32_t Inexact = 0x10;
+
+  // Zero-th bit is the first bit.
+  static constexpr uint32_t RoundingControlBitPosition = 22;
+  static constexpr uint32_t ExceptionStatusFlagsBitPosition = 0;
+  static constexpr uint32_t ExceptionControlFlagsBitPosition = 8;
+
+  static inline uint32_t getStatusValueForExcept(int excepts) {
+return (excepts & FE_INVALID ? Invalid : 0) |
+   (excepts & FE_DIVBYZERO ? DivByZero : 0) |
+   (excepts & FE_OVERFLOW ? Overflow : 0) |
+   (excepts & FE_UNDERFLOW ? Underflow : 0) |
+   (excepts & FE_INEXACT ? Inexact : 0);
+  }
+
+  static inline int exceptionStatusToMacro(uint32_t status) {
+return (status & Invalid ? FE_INVALID : 0) |
+   (status & DivByZero ? FE_DIVBYZERO : 0) |
+   (status & Overflow ? FE_OVERFLOW : 0) |
+   (status & Underflow ? FE_UNDERFLOW : 0) |
+   (status & Inexact ? FE_INEXACT : 0);
+  }
+
+  static uint32_t getControlWord() { return __arm_rsr("fpcr"); }
+
+  static void writeControlWord(uint32_t fpcr) { __arm_wsr("fpcr", fpcr); }
+
+  static uint32_t getStatusWord() { return __arm_rsr("fpsr"); }
+
+  static void writeStatusWord(uint32_t fpsr) { __arm_wsr("fpsr", fpsr); }
+};
+
+static inline int enableExcept(int excepts) {
+  uint32_t newExcepts = FEnv::getStatusValueForExcept(excepts);
+  uint32_t controlWord = FEnv::getControlWord();
+  int oldExcepts =
+  (controlWord >> FEnv::ExceptionControlFlagsBitPosition) & 0x1F;
+  controlWord |= (newExcepts << FEnv::ExceptionControlFlagsBitPosition);
+  FEnv::writeControlWord(controlWord);
+  return FEnv::exceptionStatusToMacro(oldExcepts);
+}
+
+static inline int disableExcept(int excepts) {
+  uint32_t disabledExcepts = FEnv::getStatusValueForExcept(excepts);
+  uint32_t controlWord = FEnv::getControlWord();
+  int oldExcepts

[llvm-branch-commits] [libc] b1067a9 - [libc][NFC] Skip adding dummy targets for skipped unit tests.

2020-12-14 Thread Siva Chandra via llvm-branch-commits

Author: Siva Chandra
Date: 2020-12-14T17:52:47-08:00
New Revision: b1067a9b3c8e2c692c31598bf8f399e31f486d4e

URL: 
https://github.com/llvm/llvm-project/commit/b1067a9b3c8e2c692c31598bf8f399e31f486d4e
DIFF: 
https://github.com/llvm/llvm-project/commit/b1067a9b3c8e2c692c31598bf8f399e31f486d4e.diff

LOG: [libc][NFC] Skip adding dummy targets for skipped unit tests.

Added: 


Modified: 
libc/cmake/modules/LLVMLibCTestRules.cmake
libc/test/src/math/CMakeLists.txt

Removed: 




diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake 
b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 33dc2cc7ca74..421e1a16b700 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -111,14 +111,6 @@ function(add_libc_unittest target_name)
 set(msg "Skipping unittest ${fq_target_name} as it has missing deps: "
 "${skipped_entrypoints_list}.")
 message(STATUS ${msg})
-add_custom_target(${fq_target_name})
-
-# A post build custom command is used to avoid running the command always.
-add_custom_command(
-  TARGET ${fq_target_name}
-  POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E echo ${msg}
-)
 return()
   endif()
 

diff  --git a/libc/test/src/math/CMakeLists.txt 
b/libc/test/src/math/CMakeLists.txt
index 44abc401da44..7475be150900 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -18,6 +18,9 @@ function(add_fp_unittest name)
 
   add_libc_unittest(${name} ${MATH_UNITTEST_UNPARSED_ARGUMENTS})
   get_fq_target_name(${name} fq_target_name)
+  if (NOT TARGET ${fq_target_name})
+return()
+  endif()
   if(MATH_UNITTEST_NEED_MPFR)
 target_link_libraries(${fq_target_name} PRIVATE libcMPFRWrapper -lmpfr 
-lgmp)
   endif()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] f0cd6aa - [libc] Add remainder[f|l] and remquo[f|l] to the list of aarch64 entrypoints.

2020-12-14 Thread Siva Chandra via llvm-branch-commits

Author: Siva Chandra
Date: 2020-12-14T18:06:05-08:00
New Revision: f0cd6aa614f49bb0c66e65fdf6637222c982efe4

URL: 
https://github.com/llvm/llvm-project/commit/f0cd6aa614f49bb0c66e65fdf6637222c982efe4
DIFF: 
https://github.com/llvm/llvm-project/commit/f0cd6aa614f49bb0c66e65fdf6637222c982efe4.diff

LOG: [libc] Add remainder[f|l] and remquo[f|l] to the list of aarch64 
entrypoints.

Added: 


Modified: 
libc/config/linux/aarch64/entrypoints.txt

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 89f910b5766c..67e2b72aa1af 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -88,6 +88,12 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.modf
 libc.src.math.modff
 libc.src.math.modfl
+libc.src.math.remainderf
+libc.src.math.remainder
+libc.src.math.remainderl
+libc.src.math.remquof
+libc.src.math.remquo
+libc.src.math.remquol
 libc.src.math.round
 libc.src.math.roundf
 libc.src.math.roundl



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits