//===-- AMDGPUGIsel.td - AMDGPU GlobalISel Patterns---------*- tablegen -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // This files contains patterns that should only be used by GlobalISel. For // example patterns for V_* instructions that have S_* equivalents. // SelectionDAG does not support selecting V_* instructions. //===----------------------------------------------------------------------===// include "AMDGPU.td" include "AMDGPUCombine.td" def sd_vsrc0 : ComplexPattern; def gi_vsrc0 : GIComplexOperandMatcher, GIComplexPatternEquiv; def sd_vcsrc : ComplexPattern; def gi_vcsrc : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3mods0 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3mods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3_no_mods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3mods_nnan : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3omods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3pmods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3pmodsdot : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_dotiuvop3pmods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_wmmaopselvop3pmods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vop3opselmods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vinterpmods : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_vinterpmods_hi : GIComplexOperandMatcher, GIComplexPatternEquiv; // FIXME: Why do we have both VOP3OpSel and VOP3OpSelMods? def gi_vop3opsel : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_smrd_imm : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_smrd_imm32 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_smrd_sgpr : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_smrd_sgpr_imm : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_flat_offset : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_global_offset : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_global_saddr : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_mubuf_scratch_offset : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_mubuf_scratch_offen : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_flat_scratch_offset : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_flat_scratch_saddr : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_flat_scratch_svaddr : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_ds_1addr_1offset : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_ds_64bit_4byte_aligned : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_ds_128bit_8byte_aligned : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_mubuf_addr64 : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_mubuf_offset : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_smrd_buffer_imm : GIComplexOperandMatcher, GIComplexPatternEquiv; def gi_smrd_buffer_imm32 : GIComplexOperandMatcher, GIComplexPatternEquiv; // Separate load nodes are defined to glue m0 initialization in // SelectionDAG. The GISel selector can just insert m0 initialization // directly before selecting a glue-less load, so hide this // distinction. def : GINodeEquiv { let CheckMMOIsNonAtomic = 1; let IfSignExtend = G_SEXTLOAD; let IfZeroExtend = G_ZEXTLOAD; } def : GINodeEquiv { let CheckMMOIsNonAtomic = 1; } def : GINodeEquiv { bit CheckMMOIsAtomic = 1; } def : GINodeEquiv { bit CheckMMOIsAtomic = 1; } def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; // FIXME: Check MMO is atomic def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; class GISelSop2Pat < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat < (dst_vt (node (src0_vt SReg_32:$src0), (src1_vt SReg_32:$src1))), (inst src0_vt:$src0, src1_vt:$src1) >; class GISelVop2Pat < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat < (dst_vt (node (src0_vt (sd_vsrc0 src0_vt:$src0)), (src1_vt VGPR_32:$src1))), (inst src0_vt:$src0, src1_vt:$src1) >; class GISelVop2CommutePat < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat < (dst_vt (node (src1_vt VGPR_32:$src1), (src0_vt (sd_vsrc0 src0_vt:$src0)))), (inst src0_vt:$src0, src1_vt:$src1) >; class GISelVop3Pat2 < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat < (dst_vt (node (src0_vt (sd_vcsrc src0_vt:$src0)), (src1_vt (sd_vcsrc src1_vt:$src1)))), (inst src0_vt:$src0, src1_vt:$src1) >; class GISelVop3Pat2CommutePat < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat < (dst_vt (node (src0_vt (sd_vcsrc src0_vt:$src0)), (src1_vt (sd_vcsrc src1_vt:$src1)))), (inst src0_vt:$src1, src1_vt:$src0) >; class GISelVop3Pat2ModsPat < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src0_vt = dst_vt, ValueType src1_vt = src0_vt> : GCNPat < (dst_vt (node (src0_vt (VOP3Mods0 src0_vt:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omods)), (src1_vt (VOP3Mods src1_vt:$src1, i32:$src1_modifiers)))), (inst i32:$src0_modifiers, src0_vt:$src0, i32:$src1_modifiers, src1_vt:$src1, $clamp, $omods) >; multiclass GISelVop2IntrPat < SDPatternOperator node, Instruction inst, ValueType dst_vt, ValueType src_vt = dst_vt> { def : GISelVop2Pat ; // FIXME: Intrinsics aren't marked as commutable, so we need to add an explicit // pattern to handle commuting. This is another reason why legalizing to a // generic machine instruction may be better that matching the intrinsic // directly. def : GISelVop2CommutePat ; } // Since GlobalISel is more flexible then SelectionDAG, I think we can get // away with adding patterns for integer types and not legalizing all // loads and stores to vector types. This should help simplify the load/store // legalization. foreach Ty = [i64, p0, p1, p4] in { defm : SMRD_Pattern <"S_LOAD_DWORDX2", Ty>; } def gi_as_i32timm : GICustomOperandRenderer<"renderTruncTImm">, GISDNodeXFormEquiv; def gi_as_i16timm : GICustomOperandRenderer<"renderTruncTImm">, GISDNodeXFormEquiv; def gi_as_i8timm : GICustomOperandRenderer<"renderTruncTImm">, GISDNodeXFormEquiv; def gi_as_i1timm : GICustomOperandRenderer<"renderTruncTImm">, GISDNodeXFormEquiv; def gi_NegateImm : GICustomOperandRenderer<"renderNegateImm">, GISDNodeXFormEquiv; def gi_bitcast_fpimm_to_i32 : GICustomOperandRenderer<"renderBitcastImm">, GISDNodeXFormEquiv; def gi_IMMPopCount : GICustomOperandRenderer<"renderPopcntImm">, GISDNodeXFormEquiv; def gi_extract_cpol : GICustomOperandRenderer<"renderExtractCPol">, GISDNodeXFormEquiv; def gi_extract_swz : GICustomOperandRenderer<"renderExtractSWZ">, GISDNodeXFormEquiv; def gi_set_glc : GICustomOperandRenderer<"renderSetGLC">, GISDNodeXFormEquiv; def gi_frameindex_to_targetframeindex : GICustomOperandRenderer<"renderFrameIndex">, GISDNodeXFormEquiv;