GCN machine description

This patch contains the machine description portion of the GCN back-end.  I've
broken it out mainly to avoid the mailing list size limit.

2019-01-17  Andrew Stubbs  <ams@codesourcery.com>
	    Kwok Cheung Yeung  <kcy@codesourcery.com>
	    Julian Brown  <julian@codesourcery.com>
	    Tom de Vries  <tom@codesourcery.com>
	    Jan Hubicka  <hubicka@ucw.cz>
	    Martin Jambor  <mjambor@suse.cz>

	gcc/
	* config/gcn/constraints.md: New file.
	* config/gcn/gcn-valu.md: New file.
	* config/gcn/gcn.md: New file.
	* config/gcn/predicates.md: New file.


Co-Authored-By: Jan Hubicka <hubicka@ucw.cz>
Co-Authored-By: Julian Brown <julian@codesourcery.com>
Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
Co-Authored-By: Martin Jambor <mjambor@suse.cz>
Co-Authored-By: Tom de Vries <tom@codesourcery.com>

From-SVN: r268022
This commit is contained in:
Andrew Stubbs 2019-01-17 12:31:28 +00:00 committed by Andrew Stubbs
parent 91d7b7fe84
commit 3d6275e30a
5 changed files with 5256 additions and 0 deletions

View File

@ -1,3 +1,15 @@
2019-01-17 Andrew Stubbs <ams@codesourcery.com>
Kwok Cheung Yeung <kcy@codesourcery.com>
Julian Brown <julian@codesourcery.com>
Tom de Vries <tom@codesourcery.com>
Jan Hubicka <hubicka@ucw.cz>
Martin Jambor <mjambor@suse.cz>
* config/gcn/constraints.md: New file.
* config/gcn/gcn-valu.md: New file.
* config/gcn/gcn.md: New file.
* config/gcn/predicates.md: New file.
2019-01-17 Eric Botcazou <ebotcazou@adacore.com>
* gimple-ssa-isolate-paths.c (stmt_uses_name_in_undefined_way): Replace

View File

@ -0,0 +1,139 @@
;; Constraint definitions for GCN.
;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3. If not see
;; <http://www.gnu.org/licenses/>.
(define_constraint "I"
"Inline integer constant"
(and (match_code "const_int")
(match_test "ival >= -16 && ival <= 64")))
(define_constraint "J"
"Signed integer 16-bit inline constant"
(and (match_code "const_int")
(match_test "((unsigned HOST_WIDE_INT) ival + 0x8000) < 0x10000")))
(define_constraint "Kf"
"Immeditate constant -1"
(and (match_code "const_int")
(match_test "ival == -1")))
(define_constraint "L"
"Unsigned integer 15-bit constant"
(and (match_code "const_int")
(match_test "((unsigned HOST_WIDE_INT) ival) < 0x8000")))
(define_constraint "A"
"Inline immediate parameter"
(and (match_code "const_int,const_double,const_vector")
(match_test "gcn_inline_constant_p (op)")))
(define_constraint "B"
"Immediate 32-bit parameter"
(and (match_code "const_int,const_double,const_vector")
(match_test "gcn_constant_p (op)")))
(define_constraint "C"
"Immediate 32-bit parameter zero-extended to 64-bits"
(and (match_code "const_int,const_double,const_vector")
(match_test "gcn_constant64_p (op)")))
(define_constraint "DA"
"Splittable inline immediate 64-bit parameter"
(and (match_code "const_int,const_double,const_vector")
(match_test "gcn_inline_constant64_p (op)")))
(define_constraint "DB"
"Splittable immediate 64-bit parameter"
(match_code "const_int,const_double,const_vector"))
(define_constraint "U"
"unspecified value"
(match_code "unspec"))
(define_constraint "Y"
"Symbol or label for relative calls"
(match_code "symbol_ref,label_ref"))
(define_register_constraint "v" "VGPR_REGS"
"VGPR registers")
(define_register_constraint "Sg" "SGPR_REGS"
"SGPR registers")
(define_register_constraint "SD" "SGPR_DST_REGS"
"registers useable as a destination of scalar operation")
(define_register_constraint "SS" "SGPR_SRC_REGS"
"registers useable as a source of scalar operation")
(define_register_constraint "Sm" "SGPR_MEM_SRC_REGS"
"registers useable as a source of scalar memory operation")
(define_register_constraint "Sv" "SGPR_VOP_SRC_REGS"
"registers useable as a source of VOP3A instruction")
(define_register_constraint "ca" "ALL_CONDITIONAL_REGS"
"SCC VCCZ or EXECZ")
(define_register_constraint "cs" "SCC_CONDITIONAL_REG"
"SCC")
(define_register_constraint "cV" "VCC_CONDITIONAL_REG"
"VCC")
(define_register_constraint "e" "EXEC_MASK_REG"
"EXEC")
(define_special_memory_constraint "RB"
"Buffer memory address to scratch memory."
(and (match_code "mem")
(match_test "AS_SCRATCH_P (MEM_ADDR_SPACE (op))")))
(define_special_memory_constraint "RF"
"Buffer memory address to flat memory."
(and (match_code "mem")
(match_test "AS_FLAT_P (MEM_ADDR_SPACE (op))
&& gcn_flat_address_p (XEXP (op, 0), mode)")))
(define_special_memory_constraint "RS"
"Buffer memory address to scalar flat memory."
(and (match_code "mem")
(match_test "AS_SCALAR_FLAT_P (MEM_ADDR_SPACE (op))
&& gcn_scalar_flat_mem_p (op)")))
(define_special_memory_constraint "RL"
"Buffer memory address to LDS memory."
(and (match_code "mem")
(match_test "AS_LDS_P (MEM_ADDR_SPACE (op))")))
(define_special_memory_constraint "RG"
"Buffer memory address to GDS memory."
(and (match_code "mem")
(match_test "AS_GDS_P (MEM_ADDR_SPACE (op))")))
(define_special_memory_constraint "RD"
"Buffer memory address to GDS or LDS memory."
(and (match_code "mem")
(ior (match_test "AS_GDS_P (MEM_ADDR_SPACE (op))")
(match_test "AS_LDS_P (MEM_ADDR_SPACE (op))"))))
(define_special_memory_constraint "RM"
"Memory address to global (main) memory."
(and (match_code "mem")
(match_test "AS_GLOBAL_P (MEM_ADDR_SPACE (op))
&& gcn_global_address_p (XEXP (op, 0))")))

3049
gcc/config/gcn/gcn-valu.md Normal file

File diff suppressed because it is too large Load Diff

1857
gcc/config/gcn/gcn.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,199 @@
;; Predicate definitions for GCN.
;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3. If not see
;; <http://www.gnu.org/licenses/>.
;; Return true if VALUE can be stored in a sign extended immediate field.
(define_predicate "gcn_conditional_register_operand"
(match_operand 0 "register_operand")
{
if (GET_CODE (op) == SUBREG)
op = SUBREG_REG (op);
if (!REG_P (op) || GET_MODE (op) != BImode)
return 0;
return REGNO (op) == VCCZ_REG
|| REGNO (op) == VCC_REG /* Implied VCCZ. */
|| REGNO (op) == SCC_REG
|| REGNO (op) == EXECZ_REG
|| REGNO (op) >= FIRST_PSEUDO_REGISTER;
})
(define_predicate "gcn_ssrc_register_operand"
(match_operand 0 "register_operand")
{
if (GET_CODE (op) == SUBREG)
op = SUBREG_REG (op);
if (!REG_P (op))
return false;
return SSRC_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})
(define_predicate "gcn_sdst_register_operand"
(match_operand 0 "register_operand")
{
if (GET_CODE (op) == SUBREG)
op = SUBREG_REG (op);
if (!REG_P (op))
return false;
return SDST_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})
(define_predicate "gcn_vgpr_register_operand"
(match_operand 0 "register_operand")
{
if (GET_CODE (op) == SUBREG)
op = SUBREG_REG (op);
if (!REG_P (op))
return false;
return VGPR_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
})
(define_predicate "gcn_inline_immediate_operand"
(match_code "const_int,const_double,const_vector")
{
return gcn_inline_constant_p (op);
})
(define_predicate "gcn_vop3_operand"
(ior (match_operand 0 "gcn_inline_immediate_operand")
(match_operand 0 "register_operand")))
(define_predicate "gcn_vec0_operand"
(match_code "const_vector")
{
return CONST_VECTOR_ELT (op, 0) == const0_rtx && gcn_inline_constant_p (op);
})
(define_predicate "gcn_vec1_operand"
(match_code "const_vector")
{
return CONST_VECTOR_ELT (op, 0) == const1_rtx && gcn_inline_constant_p (op);
})
(define_predicate "gcn_vec1d_operand"
(match_code "const_vector")
{
if (!gcn_inline_constant_p (op))
return false;
rtx elem = CONST_VECTOR_ELT (op, 0);
if (!CONST_DOUBLE_P (elem))
return false;
return real_identical (CONST_DOUBLE_REAL_VALUE (elem), &dconst1);
})
(define_predicate "gcn_const1d_operand"
(match_code "const_double")
{
return gcn_inline_constant_p (op)
&& real_identical (CONST_DOUBLE_REAL_VALUE (op), &dconst1);
})
(define_predicate "gcn_32bit_immediate_operand"
(match_code "const_int,const_double,const_vector,symbol_ref,label_ref")
{
return gcn_constant_p (op);
})
; LRA works smoother when exec values are immediate constants
; prior register allocation.
(define_predicate "gcn_exec_operand"
(ior (match_operand 0 "register_operand")
(match_code "const_int")))
(define_predicate "gcn_exec_reg_operand"
(match_operand 0 "register_operand"))
(define_predicate "gcn_load_operand"
(ior (match_operand 0 "nonimmediate_operand")
(match_operand 0 "gcn_32bit_immediate_operand")))
(define_predicate "gcn_alu_operand"
(ior (match_operand 0 "register_operand")
(match_operand 0 "gcn_32bit_immediate_operand")))
(define_predicate "gcn_ds_memory_operand"
(and (match_code "mem")
(and (match_test "AS_ANY_DS_P (MEM_ADDR_SPACE (op))")
(match_operand 0 "memory_operand"))))
(define_predicate "gcn_valu_dst_operand"
(ior (match_operand 0 "register_operand")
(match_operand 0 "gcn_ds_memory_operand")))
(define_predicate "gcn_valu_src0_operand"
(ior (match_operand 0 "register_operand")
(ior (match_operand 0 "gcn_32bit_immediate_operand")
(match_operand 0 "gcn_ds_memory_operand"))))
(define_predicate "gcn_valu_src1_operand"
(match_operand 0 "register_operand"))
(define_predicate "gcn_valu_src1com_operand"
(ior (match_operand 0 "register_operand")
(match_operand 0 "gcn_32bit_immediate_operand")))
(define_predicate "gcn_conditional_operator"
(match_code "eq,ne"))
(define_predicate "gcn_compare_64bit_operator"
(match_code "eq,ne"))
(define_predicate "gcn_compare_operator"
(match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu"))
(define_predicate "gcn_fp_compare_operator"
(match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu,ordered,unordered"))
(define_predicate "unary_operator"
(match_code "not,popcount"))
(define_predicate "binary_operator"
(match_code "and,ior,xor,ashift,lshiftrt,ashiftrt,smin,smax,umin,umax"))
(define_predicate "gcn_unspec_operand"
(and (match_code "unspec")
(match_test "XINT (op, 1) == UNSPEC_VECTOR")))
(define_predicate "general_or_unspec_operand"
(ior (match_operand 0 "general_operand")
(and (match_code "unspec")
(match_test "XINT (op, 1) == UNSPEC_VECTOR"))))
(define_predicate "gcn_register_or_unspec_operand"
(ior (match_operand 0 "register_operand")
(and (match_code "unspec")
(match_test "XINT (op, 1) == UNSPEC_VECTOR"))))
(define_predicate "gcn_alu_or_unspec_operand"
(ior (match_operand 0 "gcn_alu_operand")
(and (match_code "unspec")
(match_test "XINT (op, 1) == UNSPEC_VECTOR"))))
(define_predicate "gcn_register_ds_or_unspec_operand"
(ior (match_operand 0 "register_operand")
(ior (match_operand 0 "gcn_ds_memory_operand")
(and (match_code "unspec")
(match_test "XINT (op, 1) == UNSPEC_VECTOR")))))