Daily bump.
[official-gcc.git] / gcc / config / riscv / riscv-vector-builtins.h
blobf092dbfa3bef8903c5ba76bcc7a6d23410d7f868
1 /* Builtins definitions for RISC-V 'V' Extension for GNU compiler.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 Contributed by Ju-Zhe Zhong (juzhe.zhong@rivai.ai), RiVAI Technologies Ltd.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_RISCV_VECTOR_BUILTINS_H
22 #define GCC_RISCV_VECTOR_BUILTINS_H
24 /* The full name of an RVV intrinsic function is the concatenation of:
26 - the base name ("vadd", etc.)
27 - the operand suffix ("_vv", "_vx", etc.)
28 - the type suffix ("_i32m1", "_i32mf2", etc.)
29 - the predication suffix ("_tamu", "_tumu", etc.)
31 Each piece of information is individually useful, so we retain this
32 classification throughout:
34 - function_base represents the base name.
36 - operand_type_index can be used as an index to get operand suffix.
38 - rvv_op_info can be used as an index to get argument suffix.
40 - predication_type_index can be used as an index to get predication suffix.
42 In addition to its unique full name, a function may have a shorter
43 overloaded alias. This alias removes pieces of the suffixes that
44 can be inferred from the arguments, such as by shortening the mode
45 suffix or dropping some of the type suffixes. The base name and the
46 predication suffix stay the same.
48 - The function_instance class describes contains all properties of each
49 individual function. Such these information will be used by
50 function_builder, function_base, function_shape, gimple_folder,
51 function_expander, etc.
53 - The function_builder class provides several helper function to add an
54 intrinsic function.
56 - The function_shape class describes how that instruction has been presented
57 at the language level:
59 1. Determine the function name for C and C++ overload function which can
60 be recognized by compiler at language level for each instruction
61 according to members of function_instance (base name, operand suffix,
62 type suffix, predication suffix, etc.).
64 2. Specify the arguments type and return type of each function to
65 describe how that instruction has presented at language level.
67 - The function_base describes how the underlying instruction behaves.
69 The static list of functions uses function_group to describe a group
70 of related functions. The function_builder class is responsible for
71 expanding this static description into a list of individual functions
72 and registering the associated built-in functions. function_instance
73 describes one of these individual functions in terms of the properties
74 described above.
76 The classes involved in compiling a function call are:
78 - function_resolver, which resolves an overloaded function call to a
79 specific function_instance and its associated function decl.
81 - function_checker, which checks whether the values of the arguments
82 conform to the RVV ISA specification.
84 - gimple_folder, which tries to fold a function call at the gimple level
86 - function_expander, which expands a function call into rtl instructions
88 function_resolver and function_checker operate at the language level
89 and so are associated with the function_shape. gimple_folder and
90 function_expander are concerned with the behavior of the function
91 and so are associated with the function_base. */
93 namespace riscv_vector {
95 /* Flags that describe what a function might do, in addition to reading
96 its arguments and returning a result. */
97 static const unsigned int CP_READ_FPCR = 1U << 0;
98 static const unsigned int CP_RAISE_FP_EXCEPTIONS = 1U << 1;
99 static const unsigned int CP_READ_MEMORY = 1U << 2;
100 static const unsigned int CP_WRITE_MEMORY = 1U << 3;
101 static const unsigned int CP_READ_CSR = 1U << 4;
102 static const unsigned int CP_WRITE_CSR = 1U << 5;
104 /* Bit values used to identify required extensions for RVV intrinsics. */
105 #define RVV_REQUIRE_RV64BIT (1 << 0) /* Require RV64. */
106 #define RVV_REQUIRE_ELEN_64 (1 << 1) /* Require TARGET_VECTOR_ELEN_64. */
107 #define RVV_REQUIRE_ELEN_FP_32 (1 << 2) /* Require FP ELEN >= 32. */
108 #define RVV_REQUIRE_ELEN_FP_64 (1 << 3) /* Require FP ELEN >= 64. */
109 #define RVV_REQUIRE_FULL_V (1 << 4) /* Require Full 'V' extension. */
110 #define RVV_REQUIRE_MIN_VLEN_64 (1 << 5) /* Require TARGET_MIN_VLEN >= 64. */
111 #define RVV_REQUIRE_ELEN_FP_16 (1 << 6) /* Require FP ELEN >= 32. */
112 #define RVV_REQUIRE_ELEN_BF_16 (1 << 7) /* Require BF16. */
114 /* Enumerates the required extensions. */
115 enum required_ext
117 VECTOR_EXT, /* Vector extension */
118 ZVBB_EXT, /* Crypto vector Zvbb sub-ext */
119 ZVBB_OR_ZVKB_EXT, /* Crypto vector Zvbb or zvkb sub-ext */
120 ZVBC_EXT, /* Crypto vector Zvbc sub-ext */
121 ZVKG_EXT, /* Crypto vector Zvkg sub-ext */
122 ZVKNED_EXT, /* Crypto vector Zvkned sub-ext */
123 ZVKNHA_OR_ZVKNHB_EXT, /* Crypto vector Zvknh[ab] sub-ext */
124 ZVKNHB_EXT, /* Crypto vector Zvknhb sub-ext */
125 ZVKSED_EXT, /* Crypto vector Zvksed sub-ext */
126 ZVKSH_EXT, /* Crypto vector Zvksh sub-ext */
127 XTHEADVECTOR_EXT, /* XTheadVector extension */
128 ZVFBFMIN_EXT, /* Zvfbfmin extension */
129 ZVFBFWMA_EXT, /* Zvfbfwma extension */
130 /* Please update below to isa_name func when add or remove enum type(s). */
133 static inline const char * required_ext_to_isa_name (enum required_ext required)
135 switch (required)
137 case VECTOR_EXT:
138 return "v";
139 case ZVBB_EXT:
140 return "zvbb";
141 case ZVBB_OR_ZVKB_EXT:
142 return "zvbb or zvkb";
143 case ZVBC_EXT:
144 return "zvbc";
145 case ZVKG_EXT:
146 return "zvkg";
147 case ZVKNED_EXT:
148 return "zvkned";
149 case ZVKNHA_OR_ZVKNHB_EXT:
150 return "zvknha or zvknhb";
151 case ZVKNHB_EXT:
152 return "zvknhb";
153 case ZVKSED_EXT:
154 return "zvksed";
155 case ZVKSH_EXT:
156 return "zvksh";
157 case XTHEADVECTOR_EXT:
158 return "xtheadvector";
159 case ZVFBFMIN_EXT:
160 return "zvfbfmin";
161 case ZVFBFWMA_EXT:
162 return "zvfbfwma";
163 default:
164 gcc_unreachable ();
167 gcc_unreachable ();
170 static inline bool required_extensions_specified (enum required_ext required)
172 switch (required)
174 case VECTOR_EXT:
175 return TARGET_VECTOR;;
176 case ZVBB_EXT:
177 return TARGET_ZVBB;
178 case ZVBB_OR_ZVKB_EXT:
179 return TARGET_ZVBB || TARGET_ZVKB;
180 case ZVBC_EXT:
181 return TARGET_ZVBC;
182 case ZVKG_EXT:
183 return TARGET_ZVKG;
184 case ZVKNED_EXT:
185 return TARGET_ZVKNED;
186 case ZVKNHA_OR_ZVKNHB_EXT:
187 return TARGET_ZVKNHA || TARGET_ZVKNHB;
188 case ZVKNHB_EXT:
189 return TARGET_ZVKNHB;
190 case ZVKSED_EXT:
191 return TARGET_ZVKSED;
192 case ZVKSH_EXT:
193 return TARGET_ZVKSH;
194 case XTHEADVECTOR_EXT:
195 return TARGET_XTHEADVECTOR;
196 case ZVFBFMIN_EXT:
197 return TARGET_ZVFBFMIN;
198 case ZVFBFWMA_EXT:
199 return TARGET_ZVFBFWMA;
200 default:
201 gcc_unreachable ();
204 gcc_unreachable ();
207 /* Enumerates the RVV operand types. */
208 enum operand_type_index
210 OP_TYPE_none,
211 #define DEF_RVV_OP_TYPE(NAME) OP_TYPE_##NAME,
212 #include "riscv-vector-builtins.def"
213 NUM_OP_TYPES
216 /* Enumerates the RVV types, together called
217 "vector types" for brevity. */
218 enum vector_type_index
220 #define DEF_RVV_TYPE(NAME, ABI_NAME, NCHARS, ARGS...) VECTOR_TYPE_##NAME,
221 #define DEF_RVV_TUPLE_TYPE(NAME, ABI_NAME, NCHARS, ARGS...) VECTOR_TYPE_##NAME,
222 #include "riscv-vector-builtins.def"
223 NUM_VECTOR_TYPES,
224 VECTOR_TYPE_INVALID = NUM_VECTOR_TYPES
227 /* Enumerates the RVV governing predication types. */
228 enum predication_type_index
230 PRED_TYPE_none,
231 #define DEF_RVV_PRED_TYPE(NAME) PRED_TYPE_##NAME,
232 #include "riscv-vector-builtins.def"
233 NUM_PRED_TYPES
236 /* Enumerates the RVV base types. */
237 enum rvv_base_type
239 #define DEF_RVV_BASE_TYPE(NAME, ARGS...) RVV_BASE_##NAME,
240 #include "riscv-vector-builtins.def"
241 NUM_BASE_TYPES
244 /* Builtin types that are used to register RVV intrinsics. */
245 struct GTY (()) rvv_builtin_types_t
247 tree vector;
248 tree scalar;
249 tree vector_ptr;
250 tree scalar_ptr;
251 tree scalar_const_ptr;
254 /* Builtin suffix that are used to register RVV intrinsics. */
255 struct rvv_builtin_suffixes
257 const char *vector;
258 const char *scalar;
259 const char *vsetvl;
262 /* Builtin base type used to specify the type of builtin function
263 argument or return result. */
264 struct function_type_info
266 enum vector_type_index type_indexes[NUM_BASE_TYPES];
269 /* RVV Builtin argument information. */
270 struct rvv_arg_type_info
272 CONSTEXPR rvv_arg_type_info (rvv_base_type base_type_in)
273 : base_type (base_type_in)
275 enum rvv_base_type base_type;
277 tree get_scalar_ptr_type (vector_type_index) const;
278 tree get_scalar_const_ptr_type (vector_type_index) const;
279 vector_type_index get_function_type_index (vector_type_index) const;
280 tree get_scalar_type (vector_type_index) const;
281 tree get_vector_type (vector_type_index) const;
282 tree get_tree_type (vector_type_index) const;
283 tree get_tuple_subpart_type (vector_type_index) const;
286 /* Static information for each operand. */
287 struct rvv_type_info
289 enum vector_type_index index;
290 uint64_t required_extensions;
293 /* RVV Builtin operands information. */
294 struct rvv_op_info
296 const rvv_type_info *types;
297 const operand_type_index op;
298 rvv_arg_type_info ret;
299 const rvv_arg_type_info *args;
302 class registered_function;
303 class function_base;
304 class function_shape;
306 /* Static information about a set of functions. */
307 struct function_group_info
309 /* Return true if required extension is enabled */
310 bool match (required_ext ext_value) const
312 switch (ext_value)
314 case VECTOR_EXT:
315 return TARGET_VECTOR;
316 case ZVBB_EXT:
317 return TARGET_ZVBB;
318 case ZVBB_OR_ZVKB_EXT:
319 return (TARGET_ZVBB || TARGET_ZVKB);
320 case ZVBC_EXT:
321 return TARGET_ZVBC;
322 case ZVKG_EXT:
323 return TARGET_ZVKG;
324 case ZVKNED_EXT:
325 return TARGET_ZVKNED;
326 case ZVKNHA_OR_ZVKNHB_EXT:
327 return (TARGET_ZVKNHA || TARGET_ZVKNHB);
328 case ZVKNHB_EXT:
329 return TARGET_ZVKNHB;
330 case ZVKSED_EXT:
331 return TARGET_ZVKSED;
332 case ZVKSH_EXT:
333 return TARGET_ZVKSH;
334 case XTHEADVECTOR_EXT:
335 return TARGET_XTHEADVECTOR;
336 case ZVFBFMIN_EXT:
337 return TARGET_ZVFBFMIN;
338 case ZVFBFWMA_EXT:
339 return TARGET_ZVFBFWMA;
340 default:
341 gcc_unreachable ();
344 /* The base name, as a string. */
345 const char *base_name;
347 /* Describes the behavior associated with the function base name. */
348 const function_base *const *base;
350 /* The shape of the functions, as described above the class definition.
351 It's possible to have entries with the same base name but different
352 shapes. */
353 const function_shape *const *shape;
355 /* A list of the available operand types, predication types,
356 and of the available operand datatype.
357 The function supports every combination of the two.
358 The list of predication is terminated by two NUM_PRED_TYPES,
359 while the list of operand info is terminated by NUM_BASE_TYPES.
360 The list of these type suffix is lexicographically ordered based
361 on the index value. */
362 const predication_type_index *preds;
363 const rvv_op_info ops_infos;
364 /* The required extension value, using it to get the enabled flag. */
365 required_ext required_extensions;
368 class GTY ((user)) function_instance
370 public:
371 function_instance (const char *, const function_base *,
372 const function_shape *, rvv_type_info,
373 predication_type_index, const rvv_op_info *);
375 bool operator== (const function_instance &) const;
376 bool operator!= (const function_instance &) const;
377 hashval_t hash () const;
379 unsigned int call_properties () const;
380 bool reads_global_state_p () const;
381 bool modifies_global_state_p () const;
382 bool could_trap_p () const;
384 /* Return true if return type or arguments are floating point type. */
385 bool any_type_float_p () const;
387 tree get_return_type () const;
388 tree get_arg_type (unsigned opno) const;
390 /* The properties of the function. (The explicit "enum"s are required
391 for gengtype.) */
392 const char *base_name;
393 const function_base *base;
394 const function_shape *shape;
395 rvv_type_info type;
396 enum predication_type_index pred;
397 const rvv_op_info *op_info;
400 /* A class for building and registering function decls. */
401 class function_builder
403 public:
404 function_builder ();
405 ~function_builder ();
407 void allocate_argument_types (const function_instance &, vec<tree> &) const;
408 void apply_predication (const function_instance &, tree, vec<tree> &) const;
409 void add_unique_function (const function_instance &, const function_shape *,
410 tree, vec<tree> &, enum required_ext);
411 void add_overloaded_function (const function_instance &,
412 const function_shape *,
413 enum required_ext);
414 void register_function_group (const function_group_info &);
415 void append_name (const char *);
416 void append_base_name (const char *);
417 void append_sew (int);
418 void append_nf (int);
419 char *finish_name ();
421 private:
422 tree get_attributes (const function_instance &);
424 registered_function &add_function (const function_instance &, const char *,
425 tree, tree, bool, const char *,
426 const vec<tree> &, enum required_ext,
427 bool);
429 /* True if we should create a separate decl for each instance of an
430 overloaded function, instead of using function_builder. */
431 bool m_direct_overloads;
433 /* Used for building up function names. */
434 obstack m_string_obstack;
437 /* A base class for handling calls to built-in functions. */
438 class function_call_info : public function_instance
440 public:
441 function_call_info (location_t, const function_instance &, tree);
443 bool function_returns_void_p ();
445 /* The location of the call. */
446 location_t location;
448 /* The FUNCTION_DECL that is being called. */
449 tree fndecl;
452 /* Return true if the function has no return value. */
453 inline bool
454 function_call_info::function_returns_void_p ()
456 return TREE_TYPE (TREE_TYPE (fndecl)) == void_type_node;
459 /* A class for folding a gimple function call. */
460 class gimple_folder : public function_call_info
462 public:
463 gimple_folder (const function_instance &, tree, gimple_stmt_iterator *,
464 gcall *);
466 gimple *fold ();
468 /* Where to insert extra statements that feed the final replacement. */
469 gimple_stmt_iterator *gsi;
471 /* The call we're folding. */
472 gcall *call;
474 /* The result of the call, or null if none. */
475 tree lhs;
478 /* A class for expanding a function call into RTL. */
479 class function_expander : public function_call_info
481 public:
482 function_expander (const function_instance &, tree, tree, rtx);
483 rtx expand ();
485 void add_input_operand (machine_mode, rtx);
486 void add_input_operand (unsigned);
487 void add_output_operand (machine_mode, rtx);
488 void add_all_one_mask_operand (machine_mode);
489 void add_scalar_move_mask_operand (machine_mode);
490 void add_vundef_operand (machine_mode);
491 void add_fixed_operand (rtx);
492 void add_integer_operand (rtx);
493 void add_mem_operand (machine_mode, unsigned);
495 machine_mode vector_mode (void) const;
496 machine_mode index_mode (void) const;
497 machine_mode arg_mode (int) const;
498 machine_mode mask_mode (void) const;
499 machine_mode ret_mode (void) const;
501 rtx use_exact_insn (insn_code);
502 rtx use_contiguous_load_insn (insn_code);
503 rtx use_contiguous_store_insn (insn_code);
504 rtx use_compare_insn (rtx_code, insn_code);
505 rtx use_ternop_insn (bool, insn_code);
506 rtx use_widen_ternop_insn (insn_code);
507 rtx use_scalar_move_insn (insn_code);
508 rtx generate_insn (insn_code);
510 /* The function call expression. */
511 tree exp;
513 /* For functions that return a value, this is the preferred location
514 of that value. It could be null or could have a different mode
515 from the function return type. */
516 rtx target;
518 /* The number of the operands. */
519 int opno;
521 private:
522 /* Used to build up the operands to an instruction. */
523 struct expand_operand m_ops[MAX_RECOG_OPERANDS];
526 /* Provides information about a particular function base name, and handles
527 tasks related to the base name. */
528 class function_base
530 public:
531 /* Return a set of CP_* flags that describe what the function might do,
532 in addition to reading its arguments and returning a result. */
533 virtual unsigned int call_properties (const function_instance &) const;
535 /* Return true if intrinsics should apply vl operand. */
536 virtual bool apply_vl_p () const;
538 /* Return true if intrinsics should apply tail policy operand. */
539 virtual bool apply_tail_policy_p () const;
541 /* Return true if intrinsics should apply mask policy operand. */
542 virtual bool apply_mask_policy_p () const;
544 /* Return true if intrinsic can be overloaded. */
545 virtual bool can_be_overloaded_p (enum predication_type_index) const;
547 /* Return true if intrinsics use mask predication. */
548 virtual bool use_mask_predication_p () const;
550 /* Return true if intrinsics has merge operand. */
551 virtual bool has_merge_operand_p () const;
553 /* Return true if intrinsics has rounding mode operand. */
554 virtual bool has_rounding_mode_operand_p () const;
556 /* Return true if intrinsics maybe require vxrm operand. */
557 virtual bool may_require_vxrm_p () const;
559 /* Return true if intrinsics maybe require frm operand. */
560 virtual bool may_require_frm_p () const;
562 /* Try to fold the given gimple call. Return the new gimple statement
563 on success, otherwise return null. */
564 virtual gimple *fold (gimple_folder &) const { return NULL; }
566 /* Expand the given call into rtl. Return the result of the function,
567 or an arbitrary value if the function doesn't return a result. */
568 virtual rtx expand (function_expander &) const = 0;
571 /* A class for checking that the semantic constraints on a function call are
572 satisfied, such as arguments being integer constant expressions with
573 a particular range. The parent class's FNDECL is the decl that was
574 called in the original source, before overload resolution. */
575 class function_checker : public function_call_info
577 public:
578 function_checker (location_t, const function_instance &, tree, tree,
579 unsigned int, tree *);
581 machine_mode arg_mode (unsigned int) const;
582 machine_mode ret_mode (void) const;
583 unsigned int arg_num (void) const;
584 bool check (void);
586 bool require_immediate (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT) const;
587 bool require_immediate_range_or (unsigned int, HOST_WIDE_INT,
588 HOST_WIDE_INT, HOST_WIDE_INT) const;
590 private:
591 bool require_immediate_range (unsigned int, HOST_WIDE_INT,
592 HOST_WIDE_INT) const;
593 void report_non_ice (unsigned int) const;
594 void report_out_of_range (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT,
595 HOST_WIDE_INT) const;
596 void report_out_of_range_and_not (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT,
597 HOST_WIDE_INT, HOST_WIDE_INT) const;
599 /* The type of the resolved function. */
600 tree m_fntype;
602 /* The arguments to the function. */
603 unsigned int m_nargs;
604 tree *m_args;
607 /* Classifies functions into "shapes" base on:
609 - Base name of the intrinsic function.
611 - Operand types list.
613 - Argument type list.
615 - Predication type list. */
616 class function_shape
618 public:
619 /* Shape the function name according to function_instance. */
620 virtual char *get_name (function_builder &, const function_instance &,
621 bool) const
622 = 0;
624 /* Define all functions associated with the given group. */
625 virtual void build (function_builder &, const function_group_info &) const
626 = 0;
628 /* Check whether the given call is semantically valid. Return true
629 if it is, otherwise report an error and return false. */
630 virtual bool check (function_checker &) const { return true; }
633 extern const char *const operand_suffixes[NUM_OP_TYPES];
634 extern const rvv_builtin_suffixes type_suffixes[NUM_VECTOR_TYPES + 1];
635 extern const char *const predication_suffixes[NUM_PRED_TYPES];
636 extern rvv_builtin_types_t builtin_types[NUM_VECTOR_TYPES + 1];
637 extern function_instance get_read_vl_instance (void);
638 extern tree get_read_vl_decl (void);
640 inline tree
641 rvv_arg_type_info::get_scalar_type (vector_type_index type_idx) const
643 return get_function_type_index (type_idx) == VECTOR_TYPE_INVALID
644 ? NULL_TREE
645 : builtin_types[get_function_type_index (type_idx)].scalar;
648 inline tree
649 rvv_arg_type_info::get_vector_type (vector_type_index type_idx) const
651 return get_function_type_index (type_idx) == VECTOR_TYPE_INVALID
652 ? NULL_TREE
653 : builtin_types[get_function_type_index (type_idx)].vector;
656 inline bool
657 function_instance::operator!= (const function_instance &other) const
659 return !operator== (other);
662 /* Expand the call and return its lhs. */
663 inline rtx
664 function_expander::expand ()
666 return base->expand (*this);
669 /* Create op and add it into M_OPS and increase OPNO. */
670 inline void
671 function_expander::add_input_operand (machine_mode mode, rtx op)
673 create_input_operand (&m_ops[opno++], op, mode);
676 /* Create output and add it into M_OPS and increase OPNO. */
677 inline void
678 function_expander::add_output_operand (machine_mode mode, rtx target)
680 create_output_operand (&m_ops[opno++], target, mode);
683 /* Since we may normalize vop/vop_tu/vop_m/vop_tumu.. into a single patter.
684 We add a fake all true mask for the intrinsics that don't need a real mask.
686 inline void
687 function_expander::add_all_one_mask_operand (machine_mode mode)
689 add_input_operand (mode, CONSTM1_RTX (mode));
692 /* Add mask operand for scalar move instruction. */
693 inline void
694 function_expander::add_scalar_move_mask_operand (machine_mode mode)
696 add_input_operand (mode, gen_scalar_move_mask (mode));
699 /* Add an operand that must be X. The only way of legitimizing an
700 invalid X is to reload the address of a MEM. */
701 inline void
702 function_expander::add_fixed_operand (rtx x)
704 create_fixed_operand (&m_ops[opno++], x);
707 /* Add an integer operand X. */
708 inline void
709 function_expander::add_integer_operand (rtx x)
711 create_integer_operand (&m_ops[opno++], INTVAL (x));
714 /* Return the machine_mode of the corresponding vector type. */
715 inline machine_mode
716 function_expander::vector_mode (void) const
718 return TYPE_MODE (builtin_types[type.index].vector);
721 /* Return the machine_mode of the corresponding index type. */
722 inline machine_mode
723 function_expander::index_mode (void) const
725 return TYPE_MODE (op_info->args[1].get_tree_type (type.index));
728 /* Return the machine_mode of the corresponding arg type. */
729 inline machine_mode
730 function_expander::arg_mode (int idx) const
732 return TYPE_MODE (op_info->args[idx].get_tree_type (type.index));
735 /* Return the machine_mode of the corresponding return type. */
736 inline machine_mode
737 function_expander::ret_mode (void) const
739 return TYPE_MODE (op_info->ret.get_tree_type (type.index));
742 inline machine_mode
743 function_checker::arg_mode (unsigned int argno) const
745 return TYPE_MODE (TREE_TYPE (m_args[argno]));
748 inline machine_mode
749 function_checker::ret_mode () const
751 return TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl)));
754 inline unsigned int
755 function_checker::arg_num () const
757 return m_nargs;
760 /* Default implementation of function_base::call_properties, with conservatively
761 correct behavior for floating-point instructions. */
762 inline unsigned int
763 function_base::call_properties (const function_instance &instance) const
765 unsigned int flags = 0;
766 if (instance.any_type_float_p ())
767 return flags | CP_READ_FPCR | CP_RAISE_FP_EXCEPTIONS;
768 return flags;
771 /* We choose to apply vl operand by default since most of the intrinsics
772 has vl operand. */
773 inline bool
774 function_base::apply_vl_p () const
776 return true;
779 /* We choose to apply tail policy operand by default since most of the
780 intrinsics has tail policy operand. */
781 inline bool
782 function_base::apply_tail_policy_p () const
784 return true;
787 /* We choose to apply mask policy operand by default since most of the
788 intrinsics has mask policy operand. */
789 inline bool
790 function_base::apply_mask_policy_p () const
792 return true;
795 /* We choose to return true by default since most of the intrinsics use
796 mask predication. */
797 inline bool
798 function_base::use_mask_predication_p () const
800 return true;
803 /* We choose to return true by default since most of the intrinsics use
804 has merge operand. */
805 inline bool
806 function_base::has_merge_operand_p () const
808 return true;
811 /* We choose to return false by default since most of the intrinsics does
812 not have rounding mode operand. */
813 inline bool
814 function_base::has_rounding_mode_operand_p () const
816 return false;
819 /* We choose to return false by default since most of the intrinsics does
820 not need frm operand. */
821 inline bool
822 function_base::may_require_frm_p () const
824 return false;
827 /* We choose to return false by default since most of the intrinsics does
828 not need vxrm operand. */
829 inline bool
830 function_base::may_require_vxrm_p () const
832 return false;
835 /* Since most of intrinsics can be overloaded, we set it true by default. */
836 inline bool
837 function_base::can_be_overloaded_p (enum predication_type_index) const
839 return true;
842 /* Return the single field in tuple type TYPE. */
843 inline tree
844 tuple_type_field (tree type)
846 for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
847 if (TREE_CODE (field) == FIELD_DECL)
848 return field;
849 gcc_unreachable ();
852 } // end namespace riscv_vector
854 #endif