1//===- llvm/IR/ConstrainedOps.def - Constrained intrinsics ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines properties of constrained intrinsics, in particular corresponding
10// floating point operations and DAG nodes.
11//
12//===----------------------------------------------------------------------===//
13
14// DAG_FUNCTION defers to DAG_INSTRUCTION if its defined, otherwise FUNCTION.
15#ifndef DAG_FUNCTION
16#ifdef DAG_INSTRUCTION
17#define DAG_FUNCTION(N,A,R,I,D) DAG_INSTRUCTION(N,A,R,I,D)
18#else
19#define DAG_FUNCTION(N,A,R,I,D) FUNCTION(N,A,R,I)
20#endif
21#endif
22
23#ifndef INSTRUCTION
24#define INSTRUCTION(N,A,R,I)
25#endif
26
27// DAG_INSTRUCTION is treated like an INSTRUCTION if the DAG node isn't used.
28#ifndef DAG_INSTRUCTION
29#define DAG_INSTRUCTION(N,A,R,I,D) INSTRUCTION(N,A,R,I)
30#endif
31
32// In most cases intrinsic function is handled similar to instruction.
33#ifndef FUNCTION
34#define FUNCTION(N,A,R,I) INSTRUCTION(N,A,R,I)
35#endif
36
37// Compare instruction have a DAG node so they are treated like DAG_INSTRUCTION.
38#ifndef CMP_INSTRUCTION
39#define CMP_INSTRUCTION(N,A,R,I,D) DAG_INSTRUCTION(N,A,R,I,D)
40#endif
41
42// Arguments of the entries are:
43// - instruction or intrinsic function name.
44// - Number of original instruction/intrinsic arguments.
45// - 1 if the corresponding constrained intrinsic has rounding mode argument.
46// - name of the constrained intrinsic to represent this instruction/function.
47// - DAG node corresponding to the constrained intrinsic without prefix STRICT_.
48
49// These are definitions for instructions, that are converted into constrained
50// intrinsics.
51//
52DAG_INSTRUCTION(FAdd, 2, 1, experimental_constrained_fadd, FADD)
53DAG_INSTRUCTION(FSub, 2, 1, experimental_constrained_fsub, FSUB)
54DAG_INSTRUCTION(FMul, 2, 1, experimental_constrained_fmul, FMUL)
55DAG_INSTRUCTION(FDiv, 2, 1, experimental_constrained_fdiv, FDIV)
56DAG_INSTRUCTION(FRem, 2, 1, experimental_constrained_frem, FREM)
57DAG_INSTRUCTION(FPExt, 1, 0, experimental_constrained_fpext, FP_EXTEND)
58DAG_INSTRUCTION(SIToFP, 1, 1, experimental_constrained_sitofp, SINT_TO_FP)
59DAG_INSTRUCTION(UIToFP, 1, 1, experimental_constrained_uitofp, UINT_TO_FP)
60DAG_INSTRUCTION(FPToSI, 1, 0, experimental_constrained_fptosi, FP_TO_SINT)
61DAG_INSTRUCTION(FPToUI, 1, 0, experimental_constrained_fptoui, FP_TO_UINT)
62DAG_INSTRUCTION(FPTrunc, 1, 1, experimental_constrained_fptrunc, FP_ROUND)
63
64// These are definitions for compare instructions (signaling and quiet version).
65// Both of these match to FCmp / SETCC.
66CMP_INSTRUCTION(FCmp, 2, 0, experimental_constrained_fcmp, FSETCC)
67CMP_INSTRUCTION(FCmp, 2, 0, experimental_constrained_fcmps, FSETCCS)
68
69// Theses are definitions for intrinsic functions, that are converted into
70// constrained intrinsics.
71//
72DAG_FUNCTION(ceil, 1, 0, experimental_constrained_ceil, FCEIL)
73DAG_FUNCTION(cos, 1, 1, experimental_constrained_cos, FCOS)
74DAG_FUNCTION(exp, 1, 1, experimental_constrained_exp, FEXP)
75DAG_FUNCTION(exp2, 1, 1, experimental_constrained_exp2, FEXP2)
76DAG_FUNCTION(floor, 1, 0, experimental_constrained_floor, FFLOOR)
77DAG_FUNCTION(fma, 3, 1, experimental_constrained_fma, FMA)
78DAG_FUNCTION(log, 1, 1, experimental_constrained_log, FLOG)
79DAG_FUNCTION(log10, 1, 1, experimental_constrained_log10, FLOG10)
80DAG_FUNCTION(log2, 1, 1, experimental_constrained_log2, FLOG2)
81DAG_FUNCTION(lrint, 1, 1, experimental_constrained_lrint, LRINT)
82DAG_FUNCTION(llrint, 1, 1, experimental_constrained_llrint, LLRINT)
83DAG_FUNCTION(lround, 1, 0, experimental_constrained_lround, LROUND)
84DAG_FUNCTION(llround, 1, 0, experimental_constrained_llround, LLROUND)
85DAG_FUNCTION(maxnum, 2, 0, experimental_constrained_maxnum, FMAXNUM)
86DAG_FUNCTION(minnum, 2, 0, experimental_constrained_minnum, FMINNUM)
87DAG_FUNCTION(maximum, 2, 0, experimental_constrained_maximum, FMAXIMUM)
88DAG_FUNCTION(minimum, 2, 0, experimental_constrained_minimum, FMINIMUM)
89DAG_FUNCTION(nearbyint, 1, 1, experimental_constrained_nearbyint, FNEARBYINT)
90DAG_FUNCTION(pow, 2, 1, experimental_constrained_pow, FPOW)
91DAG_FUNCTION(powi, 2, 1, experimental_constrained_powi, FPOWI)
92DAG_FUNCTION(ldexp, 2, 1, experimental_constrained_ldexp, FLDEXP)
93DAG_FUNCTION(rint, 1, 1, experimental_constrained_rint, FRINT)
94DAG_FUNCTION(round, 1, 0, experimental_constrained_round, FROUND)
95DAG_FUNCTION(roundeven, 1, 0, experimental_constrained_roundeven, FROUNDEVEN)
96DAG_FUNCTION(sin, 1, 1, experimental_constrained_sin, FSIN)
97DAG_FUNCTION(sqrt, 1, 1, experimental_constrained_sqrt, FSQRT)
98DAG_FUNCTION(trunc, 1, 0, experimental_constrained_trunc, FTRUNC)
99
100// This is definition for fmuladd intrinsic function, that is converted into
101// constrained FMA or FMUL + FADD intrinsics.
102FUNCTION(fmuladd, 3, 1, experimental_constrained_fmuladd)
103
104#undef INSTRUCTION
105#undef FUNCTION
106#undef CMP_INSTRUCTION
107#undef DAG_INSTRUCTION
108#undef DAG_FUNCTION
109

source code of llvm/include/llvm/IR/ConstrainedOps.def