Unverified Commit 17764d2c authored by Nikita Popov's avatar Nikita Popov Committed by GitHub
Browse files

[IR] Remove FP cast constant expressions (#71408)

Remove support for the fptrunc, fpext, fptoui, fptosi, uitofp and sitofp
constant expressions. All places creating them have been removed
beforehand, so this just removes the APIs and uses of these constant
expressions in tests.

With this, the only remaining FP operation that still has constant
expression support is fcmp.

This is part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
parent a5c1ecad
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -661,12 +661,6 @@ external const_gep : lltype -> llvalue -> llvalue array -> llvalue
external const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue
                             = "llvm_const_in_bounds_gep"
external const_trunc : llvalue -> lltype -> llvalue = "llvm_const_trunc"
external const_fptrunc : llvalue -> lltype -> llvalue = "llvm_const_fptrunc"
external const_fpext : llvalue -> lltype -> llvalue = "llvm_const_fpext"
external const_uitofp : llvalue -> lltype -> llvalue = "llvm_const_uitofp"
external const_sitofp : llvalue -> lltype -> llvalue = "llvm_const_sitofp"
external const_fptoui : llvalue -> lltype -> llvalue = "llvm_const_fptoui"
external const_fptosi : llvalue -> lltype -> llvalue = "llvm_const_fptosi"
external const_ptrtoint : llvalue -> lltype -> llvalue = "llvm_const_ptrtoint"
external const_inttoptr : llvalue -> lltype -> llvalue = "llvm_const_inttoptr"
external const_bitcast : llvalue -> lltype -> llvalue = "llvm_const_bitcast"
@@ -674,7 +668,6 @@ external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
                                = "llvm_const_trunc_or_bitcast"
external const_pointercast : llvalue -> lltype -> llvalue
                           = "llvm_const_pointercast"
external const_fpcast : llvalue -> lltype -> llvalue = "llvm_const_fpcast"
external const_extractelement : llvalue -> llvalue -> llvalue
                              = "llvm_const_extractelement"
external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
+0 −35
Original line number Diff line number Diff line
@@ -1171,36 +1171,6 @@ val const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue
    See the method [llvm::ConstantExpr::getTrunc]. *)
val const_trunc : llvalue -> lltype -> llvalue

(** [const_fptrunc c ty] returns the constant truncation of floating point
    constant [c] to the smaller floating point type [ty].
    See the method [llvm::ConstantExpr::getFPTrunc]. *)
val const_fptrunc : llvalue -> lltype -> llvalue

(** [const_fpext c ty] returns the constant extension of floating point constant
    [c] to the larger floating point type [ty].
    See the method [llvm::ConstantExpr::getFPExt]. *)
val const_fpext : llvalue -> lltype -> llvalue

(** [const_uitofp c ty] returns the constant floating point conversion of
    unsigned integer constant [c] to the floating point type [ty].
    See the method [llvm::ConstantExpr::getUIToFP]. *)
val const_uitofp : llvalue -> lltype -> llvalue

(** [const_sitofp c ty] returns the constant floating point conversion of
    signed integer constant [c] to the floating point type [ty].
    See the method [llvm::ConstantExpr::getSIToFP]. *)
val const_sitofp : llvalue -> lltype -> llvalue

(** [const_fptoui c ty] returns the constant unsigned integer conversion of
    floating point constant [c] to integer type [ty].
    See the method [llvm::ConstantExpr::getFPToUI]. *)
val const_fptoui : llvalue -> lltype -> llvalue

(** [const_fptoui c ty] returns the constant unsigned integer conversion of
    floating point constant [c] to integer type [ty].
    See the method [llvm::ConstantExpr::getFPToSI]. *)
val const_fptosi : llvalue -> lltype -> llvalue

(** [const_ptrtoint c ty] returns the constant integer conversion of
    pointer constant [c] to integer type [ty].
    See the method [llvm::ConstantExpr::getPtrToInt]. *)
@@ -1226,11 +1196,6 @@ val const_trunc_or_bitcast : llvalue -> lltype -> llvalue
    See the method [llvm::ConstantExpr::getPointerCast]. *)
val const_pointercast : llvalue -> lltype -> llvalue

(** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
    fp casts of constant [c] to type [ty].
    See the method [llvm::ConstantExpr::getFPCast]. *)
val const_fpcast : llvalue -> lltype -> llvalue

(** [const_extractelement vec i] returns the constant [i]th element of
    constant vector [vec]. [i] must be a constant [i32] value unsigned less than
    the size of the vector.
+0 −42
Original line number Diff line number Diff line
@@ -1271,42 +1271,6 @@ value llvm_const_trunc(value CV, value T) {
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_fptrunc(value CV, value T) {
  LLVMValueRef Value = LLVMConstFPTrunc(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_fpext(value CV, value T) {
  LLVMValueRef Value = LLVMConstFPExt(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_uitofp(value CV, value T) {
  LLVMValueRef Value = LLVMConstUIToFP(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_sitofp(value CV, value T) {
  LLVMValueRef Value = LLVMConstSIToFP(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_fptoui(value CV, value T) {
  LLVMValueRef Value = LLVMConstFPToUI(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_fptosi(value CV, value T) {
  LLVMValueRef Value = LLVMConstFPToSI(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_ptrtoint(value CV, value T) {
  LLVMValueRef Value = LLVMConstPtrToInt(Value_val(CV), Type_val(T));
@@ -1337,12 +1301,6 @@ value llvm_const_pointercast(value CV, value T) {
  return to_val(Value);
}

/* llvalue -> lltype -> llvalue */
value llvm_const_fpcast(value CV, value T) {
  LLVMValueRef Value = LLVMConstFPCast(Value_val(CV), Type_val(T));
  return to_val(Value);
}

/* llvalue -> llvalue -> llvalue */
value llvm_const_extractelement(value V, value I) {
  LLVMValueRef Value = LLVMConstExtractElement(Value_val(V), Value_val(I));
+0 −32
Original line number Diff line number Diff line
@@ -4657,38 +4657,6 @@ The following is the syntax for constant expressions:
``trunc (CST to TYPE)``
    Perform the :ref:`trunc operation <i_trunc>` on constants.
``fptrunc (CST to TYPE)``
    Truncate a floating-point constant to another floating-point type.
    The size of CST must be larger than the size of TYPE. Both types
    must be floating-point.
``fpext (CST to TYPE)``
    Floating-point extend a constant to another type. The size of CST
    must be smaller or equal to the size of TYPE. Both types must be
    floating-point.
``fptoui (CST to TYPE)``
    Convert a floating-point constant to the corresponding unsigned
    integer constant. TYPE must be a scalar or vector integer type. CST
    must be of scalar or vector floating-point type. Both CST and TYPE
    must be scalars, or vectors of the same number of elements. If the
    value won't fit in the integer type, the result is a
    :ref:`poison value <poisonvalues>`.
``fptosi (CST to TYPE)``
    Convert a floating-point constant to the corresponding signed
    integer constant. TYPE must be a scalar or vector integer type. CST
    must be of scalar or vector floating-point type. Both CST and TYPE
    must be scalars, or vectors of the same number of elements. If the
    value won't fit in the integer type, the result is a
    :ref:`poison value <poisonvalues>`.
``uitofp (CST to TYPE)``
    Convert an unsigned integer constant to the corresponding
    floating-point constant. TYPE must be a scalar or vector floating-point
    type.  CST must be of scalar or vector integer type. Both CST and TYPE must
    be scalars, or vectors of the same number of elements.
``sitofp (CST to TYPE)``
    Convert a signed integer constant to the corresponding floating-point
    constant. TYPE must be a scalar or vector floating-point type.
    CST must be of scalar or vector integer type. Both CST and TYPE must
    be scalars, or vectors of the same number of elements.
``ptrtoint (CST to TYPE)``
    Perform the :ref:`ptrtoint operation <i_ptrtoint>` on constants.
``inttoptr (CST to TYPE)``
+13 −0
Original line number Diff line number Diff line
@@ -59,6 +59,12 @@ Changes to the LLVM IR
  * ``or``
  * ``zext``
  * ``sext``
  * ``fptrunc``
  * ``fpext``
  * ``fptoui``
  * ``fptosi``
  * ``uitofp``
  * ``sitofp``

* Added `llvm.exp10` intrinsic.

@@ -173,6 +179,13 @@ Changes to the C API
  * ``LLVMConstZExtOrBitCast``
  * ``LLVMConstSExtOrBitCast``
  * ``LLVMConstIntCast``
  * ``LLVMConstFPTrunc``
  * ``LLVMConstFPExt``
  * ``LLVMConstFPToUI``
  * ``LLVMConstFPToSI``
  * ``LLVMConstUIToFP``
  * ``LLVMConstSIToFP``
  * ``LLVMConstFPCast``

* Added ``LLVMCreateTargetMachineWithOptions``, along with helper functions for
  an opaque option structure, as an alternative to ``LLVMCreateTargetMachine``.
Loading