[all-commits] [llvm/llvm-project] b8a159: [clang] Add __builtin_convert_to_arbitrary_fp

Chinmay Deshpande via All-commits all-commits at lists.llvm.org
Mon Jul 27 12:08:12 PDT 2026


  Branch: refs/heads/users/chinmaydd/builtin-convert-to-arbitrary-fp
  Home:   https://github.com/llvm/llvm-project
  Commit: b8a1592b613e61e8f91059c5909bcb3b944a1b32
      https://github.com/llvm/llvm-project/commit/b8a1592b613e61e8f91059c5909bcb3b944a1b32
  Author: Chinmay Deshpande <chdeshpa at amd.com>
  Date:   2026-07-27 (Mon, 27 Jul 2026)

  Changed paths:
    M clang/docs/LanguageExtensions.md
    M clang/docs/ReleaseNotes.md
    M clang/include/clang/Basic/Builtins.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Sema/SemaChecking.cpp
    A clang/test/CodeGen/builtins-convert-to-arbitrary-fp.c
    A clang/test/Sema/builtins-convert-to-arbitrary-fp.c

  Log Message:
  -----------
  [clang] Add __builtin_convert_to_arbitrary_fp

Expose the llvm.convert.to.arbitrary.fp intrinsic as a target-independent
builtin, the inverse of __builtin_convert_from_arbitrary_fp:

  unsigned _BitInt(8) b =
      __builtin_convert_to_arbitrary_fp(f, "Float8E4M3FN", "round.tonearest", 1);

The result type is derived from the format, so unlike the "from" direction this
is an ordinary CustomTypeChecking builtin with no parser or AST support needed.
It is unsigned _BitInt(N) for a scalar operand and an ext_vector_type of that
for a vector operand.

The rounding mode is a string literal validated with convertStrToRoundingMode,
matching what the IR verifier accepts, and the saturation flag must be an
integer constant expression equal to 0 or 1 since the intrinsic marks it ImmArg.

Clang only permits _BitInt vector elements of power-of-two width, so vector
operands are rejected for the 6-bit formats.

Change-Id: Ibb5ce6922e73042b00df27d5d2bce3cd2c1c1f51
Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list