Warning, /include/llvm/IR/IntrinsicsSPIRV.td is written in an unsupported language. File is not indexed.
0001 //===- IntrinsicsSPIRV.td - Defines SPIRV intrinsics -------*- tablegen -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines all of the SPIRV-specific intrinsics.
0010 //
0011 //===----------------------------------------------------------------------===//
0012
0013 let TargetPrefix = "spv" in {
0014 def int_spv_assign_type : Intrinsic<[], [llvm_any_ty, llvm_metadata_ty]>;
0015 def int_spv_assign_ptr_type : Intrinsic<[], [llvm_any_ty, llvm_metadata_ty, llvm_i32_ty], [ImmArg<ArgIndex<2>>]>;
0016 def int_spv_assign_name : Intrinsic<[], [llvm_any_ty, llvm_vararg_ty]>;
0017 def int_spv_assign_decoration : Intrinsic<[], [llvm_any_ty, llvm_metadata_ty]>;
0018 def int_spv_value_md : Intrinsic<[], [llvm_metadata_ty]>;
0019
0020 def int_spv_track_constant : Intrinsic<[llvm_any_ty], [llvm_any_ty, llvm_metadata_ty]>;
0021 def int_spv_init_global : Intrinsic<[], [llvm_any_ty, llvm_any_ty]>;
0022 def int_spv_unref_global : Intrinsic<[], [llvm_any_ty]>;
0023
0024 def int_spv_gep : Intrinsic<[llvm_anyptr_ty], [llvm_i1_ty, llvm_any_ty, llvm_vararg_ty], [ImmArg<ArgIndex<0>>]>;
0025 def int_spv_load : Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty, llvm_i16_ty, llvm_i8_ty], [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
0026 def int_spv_store : Intrinsic<[], [llvm_any_ty, llvm_anyptr_ty, llvm_i16_ty, llvm_i8_ty], [ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
0027 def int_spv_extractv : Intrinsic<[llvm_any_ty], [llvm_i32_ty, llvm_vararg_ty]>;
0028 def int_spv_insertv : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_any_ty, llvm_vararg_ty]>;
0029 def int_spv_extractelt : Intrinsic<[llvm_any_ty], [llvm_any_ty, llvm_anyint_ty]>;
0030 def int_spv_insertelt : Intrinsic<[llvm_any_ty], [llvm_any_ty, llvm_any_ty, llvm_anyint_ty]>;
0031 def int_spv_const_composite : Intrinsic<[llvm_any_ty], [llvm_vararg_ty]>;
0032 def int_spv_bitcast : Intrinsic<[llvm_any_ty], [llvm_any_ty]>;
0033 def int_spv_ptrcast : Intrinsic<[llvm_any_ty], [llvm_any_ty, llvm_metadata_ty, llvm_i32_ty], [ImmArg<ArgIndex<2>>]>;
0034 def int_spv_switch : Intrinsic<[], [llvm_any_ty, llvm_vararg_ty]>;
0035 def int_spv_loop_merge : Intrinsic<[], [llvm_vararg_ty]>;
0036 def int_spv_selection_merge : Intrinsic<[], [llvm_any_ty, llvm_i32_ty], [ImmArg<ArgIndex<1>>]>;
0037 def int_spv_cmpxchg : Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_vararg_ty]>;
0038 def int_spv_unreachable : Intrinsic<[], []>;
0039 def int_spv_alloca : Intrinsic<[llvm_any_ty], [llvm_i8_ty], [ImmArg<ArgIndex<0>>]>;
0040 def int_spv_alloca_array : Intrinsic<[llvm_any_ty], [llvm_anyint_ty, llvm_i8_ty], [ImmArg<ArgIndex<1>>]>;
0041 def int_spv_undef : Intrinsic<[llvm_i32_ty], []>;
0042 def int_spv_inline_asm : Intrinsic<[], [llvm_metadata_ty, llvm_metadata_ty, llvm_vararg_ty]>;
0043
0044 // Expect, Assume Intrinsics
0045 def int_spv_assume : Intrinsic<[], [llvm_i1_ty]>;
0046 def int_spv_expect : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
0047
0048 // Memory Use Markers
0049 def int_spv_lifetime_start : Intrinsic<[],
0050 [llvm_i64_ty, llvm_anyptr_ty],
0051 [IntrArgMemOnly, IntrWillReturn,
0052 NoCapture<ArgIndex<1>>,
0053 ImmArg<ArgIndex<0>>]>;
0054 def int_spv_lifetime_end : Intrinsic<[],
0055 [llvm_i64_ty, llvm_anyptr_ty],
0056 [IntrArgMemOnly, IntrWillReturn,
0057 NoCapture<ArgIndex<1>>,
0058 ImmArg<ArgIndex<0>>]>;
0059
0060 // The following intrinsic(s) are mirrored from IntrinsicsDirectX.td for HLSL support.
0061 def int_spv_thread_id : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrWillReturn]>;
0062 def int_spv_group_id : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrWillReturn]>;
0063 def int_spv_thread_id_in_group : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrWillReturn]>;
0064 def int_spv_all : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem]>;
0065 def int_spv_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem]>;
0066 def int_spv_cross : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
0067 def int_spv_degrees : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
0068 def int_spv_distance : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>], [IntrNoMem]>;
0069 def int_spv_frac : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
0070 def int_spv_lerp : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>],
0071 [IntrNoMem] >;
0072 def int_spv_length : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
0073 def int_spv_normalize : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
0074 def int_spv_rsqrt : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
0075 def int_spv_saturate : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem]>;
0076 def int_spv_step : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [LLVMMatchType<0>, llvm_anyfloat_ty], [IntrNoMem]>;
0077 def int_spv_fdot :
0078 DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
0079 [llvm_anyfloat_ty, LLVMScalarOrSameVectorWidth<0, LLVMVectorElementType<0>>],
0080 [IntrNoMem, Commutative] >;
0081 def int_spv_sdot :
0082 DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
0083 [llvm_anyint_ty, LLVMScalarOrSameVectorWidth<0, LLVMVectorElementType<0>>],
0084 [IntrNoMem, Commutative] >;
0085 def int_spv_udot :
0086 DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
0087 [llvm_anyint_ty, LLVMScalarOrSameVectorWidth<0, LLVMVectorElementType<0>>],
0088 [IntrNoMem, Commutative] >;
0089 def int_spv_dot4add_i8packed : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
0090 def int_spv_dot4add_u8packed : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
0091 def int_spv_wave_active_countbits : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i1_ty], [IntrConvergent, IntrNoMem]>;
0092 def int_spv_wave_all : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i1_ty], [IntrConvergent, IntrNoMem]>;
0093 def int_spv_wave_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i1_ty], [IntrConvergent, IntrNoMem]>;
0094 def int_spv_wave_reduce_umax : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>], [IntrConvergent, IntrNoMem]>;
0095 def int_spv_wave_reduce_max : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>], [IntrConvergent, IntrNoMem]>;
0096 def int_spv_wave_reduce_sum : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>], [IntrConvergent, IntrNoMem]>;
0097 def int_spv_wave_is_first_lane : DefaultAttrsIntrinsic<[llvm_i1_ty], [], [IntrConvergent]>;
0098 def int_spv_wave_readlane : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, llvm_i32_ty], [IntrConvergent, IntrNoMem]>;
0099 def int_spv_sign : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i32_ty>], [llvm_any_ty], [IntrNoMem]>;
0100 def int_spv_radians : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
0101 def int_spv_group_memory_barrier_with_group_sync : DefaultAttrsIntrinsic<[], [], []>;
0102 def int_spv_discard : DefaultAttrsIntrinsic<[], [], []>;
0103 def int_spv_uclamp : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
0104 def int_spv_sclamp : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
0105 def int_spv_nclamp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
0106
0107 // Create resource handle given the binding information. Returns a
0108 // type appropriate for the kind of resource given the set id, binding id,
0109 // array size of the binding, as well as an index and an indicator
0110 // whether that index may be non-uniform.
0111 def int_spv_resource_handlefrombinding
0112 : DefaultAttrsIntrinsic<
0113 [llvm_any_ty],
0114 [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i1_ty],
0115 [IntrNoMem]>;
0116
0117 def int_spv_firstbituhigh : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i32_ty>], [llvm_anyint_ty], [IntrNoMem]>;
0118 def int_spv_firstbitshigh : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i32_ty>], [llvm_anyint_ty], [IntrNoMem]>;
0119 def int_spv_firstbitlow : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i32_ty>], [llvm_anyint_ty], [IntrNoMem]>;
0120
0121 def int_spv_resource_updatecounter
0122 : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_i8_ty],
0123 [IntrInaccessibleMemOrArgMemOnly]>;
0124
0125 def int_spv_resource_getpointer
0126 : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_any_ty, llvm_i32_ty],
0127 [IntrNoMem]>;
0128
0129 // Read a value from the image buffer. It does not translate directly to a
0130 // single OpImageRead because the result type is not necessarily a 4 element
0131 // vector.
0132 def int_spv_resource_load_typedbuffer
0133 : DefaultAttrsIntrinsic<[llvm_any_ty], [llvm_any_ty, llvm_i32_ty]>;
0134
0135 // Write a value to the image buffer. Translates directly to a single
0136 // OpImageWrite.
0137 def int_spv_resource_store_typedbuffer
0138 : DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_i32_ty, llvm_anyvector_ty]>;
0139
0140 }