Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
libc.src.complex.conj
libc.src.complex.conjf
libc.src.complex.conjl

# fenv.h entrypoints
libc.src.fenv.feclearexcept
Expand Down Expand Up @@ -617,6 +620,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
# complex.h C23 _Complex _Float16 entrypoints
# libc.src.complex.crealf16
# libc.src.complex.cimagf16
# libc.src.complex.conjf16

# math.h C23 _Float16 entrypoints
libc.src.math.canonicalizef16
Expand Down Expand Up @@ -722,6 +726,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
# complex.h C23 _Complex _Float128 entrypoints
libc.src.complex.crealf128
libc.src.complex.cimagf128
libc.src.complex.conjf128

# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
Expand Down
3 changes: 3 additions & 0 deletions libc/config/linux/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
libc.src.complex.conj
libc.src.complex.conjf
libc.src.complex.conjl

# fenv.h entrypoints
libc.src.fenv.feclearexcept
Expand Down
4 changes: 4 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
libc.src.complex.conj
libc.src.complex.conjf
libc.src.complex.conjl

# fenv.h entrypoints
libc.src.fenv.feclearexcept
Expand Down Expand Up @@ -620,6 +623,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
# complex.h C23 _Complex _Float128 entrypoints
libc.src.complex.crealf128
libc.src.complex.cimagf128
libc.src.complex.conjf128

# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
Expand Down
5 changes: 5 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
libc.src.complex.conj
libc.src.complex.conjf
libc.src.complex.conjl

# fenv.h entrypoints
libc.src.fenv.feclearexcept
Expand Down Expand Up @@ -622,6 +625,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
# complex.h C23 _Complex _Float16 entrypoints
libc.src.complex.crealf16
libc.src.complex.cimagf16
libc.src.complex.conjf16

# math.h C23 _Float16 entrypoints
libc.src.math.canonicalizef16
Expand Down Expand Up @@ -731,6 +735,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
# complex.h C23 _Complex _Float128 entrypoints
# libc.src.complex.crealf128
# libc.src.complex.cimagf128
# libc.src.complex.conjf128

# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
Expand Down
2 changes: 1 addition & 1 deletion libc/docs/complex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Functions
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| cimag | |check| | |check| | |check| | |check| | |check| | 7.3.9.2 | N/A |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| conj | | | | | | 7.3.9.4 | N/A |
| conj | |check| | |check| | |check| | |check| | |check| | 7.3.9.4 | N/A |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| cproj | | | | | | 7.3.9.5 | N/A |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
Expand Down
6 changes: 6 additions & 0 deletions libc/src/complex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ add_complex_entrypoint_object(cimagf)
add_complex_entrypoint_object(cimagl)
add_complex_entrypoint_object(cimagf16)
add_complex_entrypoint_object(cimagf128)

add_complex_entrypoint_object(conj)
add_complex_entrypoint_object(conjf)
add_complex_entrypoint_object(conjl)
add_complex_entrypoint_object(conjf16)
add_complex_entrypoint_object(conjf128)
20 changes: 20 additions & 0 deletions libc/src/complex/conj.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for conj --------------------------*- 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_SRC_COMPLEX_CONJ_H
#define LLVM_LIBC_SRC_COMPLEX_CONJ_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

_Complex double conj(_Complex double x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJ_H
20 changes: 20 additions & 0 deletions libc/src/complex/conjf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for conjf -------------------------*- 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_SRC_COMPLEX_CONJF_H
#define LLVM_LIBC_SRC_COMPLEX_CONJF_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

_Complex float conjf(_Complex float x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJF_H
27 changes: 27 additions & 0 deletions libc/src/complex/conjf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===-- Implementation header for conjf128 ----------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "src/__support/macros/properties/complex_types.h"
#include "src/__support/macros/properties/types.h"

#if defined(LIBC_TYPES_HAS_CFLOAT128)

#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF128_H
#define LLVM_LIBC_SRC_COMPLEX_CONJF128_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

cfloat128 conjf128(cfloat128 x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJF128_H

#endif // LIBC_TYPES_HAS_CFLOAT128
27 changes: 27 additions & 0 deletions libc/src/complex/conjf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===-- Implementation header for conjf16 -----------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "src/__support/macros/properties/complex_types.h"
#include "src/__support/macros/properties/types.h"

#if defined(LIBC_TYPES_HAS_CFLOAT16)

#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF16_H
#define LLVM_LIBC_SRC_COMPLEX_CONJF16_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

cfloat16 conjf16(cfloat16 x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJF16_H

#endif // LIBC_TYPES_HAS_CFLOAT16
20 changes: 20 additions & 0 deletions libc/src/complex/conjl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for conjl -------------------------*- 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_SRC_COMPLEX_CONJL_H
#define LLVM_LIBC_SRC_COMPLEX_CONJL_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

_Complex long double conjl(_Complex long double x);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_COMPLEX_CONJL_H
69 changes: 69 additions & 0 deletions libc/src/complex/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
add_entrypoint_object(
conj
SRCS
conj.cpp
HDRS
../conj.h
COMPILE_OPTIONS
${libc_opt_high_flag}
DEPENDS
libc.src.__support.CPP.bit
libc.src.__support.complex_type
)

add_entrypoint_object(
conjf
SRCS
conjf.cpp
HDRS
../conjf.h
COMPILE_OPTIONS
${libc_opt_high_flag}
DEPENDS
libc.src.__support.CPP.bit
libc.src.__support.complex_type
)

add_entrypoint_object(
conjl
SRCS
conjl.cpp
HDRS
../conjl.h
COMPILE_OPTIONS
${libc_opt_high_flag}
DEPENDS
libc.src.__support.CPP.bit
libc.src.__support.complex_type
)

add_entrypoint_object(
conjf16
SRCS
conjf16.cpp
HDRS
../conjf16.h
COMPILE_OPTIONS
${libc_opt_high_flag}
DEPENDS
libc.src.__support.CPP.bit
libc.src.__support.complex_type
libc.src.__support.macros.properties.types
libc.src.__support.macros.properties.complex_types
)

add_entrypoint_object(
conjf128
SRCS
conjf128.cpp
HDRS
../conjf128.h
COMPILE_OPTIONS
${libc_opt_high_flag}
DEPENDS
libc.src.__support.CPP.bit
libc.src.__support.complex_type
libc.src.__support.macros.properties.types
libc.src.__support.macros.properties.complex_types
)

add_entrypoint_object(
creal
SRCS
Expand Down
21 changes: 21 additions & 0 deletions libc/src/complex/generic/conj.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of conj function -----------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "src/complex/conj.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/complex_type.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(_Complex double, conj, (_Complex double x)) {
Complex<double> x_c = cpp::bit_cast<Complex<double>>(x);
return (x_c.real - x_c.imag * 1.0i);
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/complex/generic/conjf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of conjf function ----------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "src/complex/conjf.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/complex_type.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(_Complex float, conjf, (_Complex float x)) {
Complex<float> x_c = cpp::bit_cast<Complex<float>>(x);
return (x_c.real - x_c.imag * (_Complex float)1.0i);
}

} // namespace LIBC_NAMESPACE_DECL
25 changes: 25 additions & 0 deletions libc/src/complex/generic/conjf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- Implementation of conjf128 function -------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "src/complex/conjf128.h"
#if defined(LIBC_TYPES_HAS_CFLOAT128)

#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/complex_type.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(cfloat128, conjf128, (cfloat128 x)) {
Complex<float128> x_c = cpp::bit_cast<Complex<float128>>(x);
return (x_c.real - x_c.imag * (cfloat128)1.0i);
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT128
25 changes: 25 additions & 0 deletions libc/src/complex/generic/conjf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- Implementation of conjf16 function --------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "src/complex/conjf16.h"
#if defined(LIBC_TYPES_HAS_CFLOAT16)

#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/complex_type.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(cfloat16, conjf16, (cfloat16 x)) {
Complex<float16> x_c = cpp::bit_cast<Complex<float16>>(x);
return (x_c.real - x_c.imag * (cfloat16)1.0i);
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_CFLOAT16
Loading
Loading