📄 arm.md
字号:
;;- Machine description for ARM for GNU compiler;; Copyright 1991, 1993, 1994, 1995, 1996, 1996, 1997, 1998, 1999, 2000,;; 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.;; Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl);; and Martin Simmons (@harleqn.co.uk).;; More major hacks by Richard Earnshaw (rearnsha@arm.com).;; 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 2, 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 COPYING. If not, write to;; the Free Software Foundation, 59 Temple Place - Suite 330,;; Boston, MA 02111-1307, USA.;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.;;---------------------------------------------------------------------------;; Constants;; Register numbers(define_constants [(R0_REGNUM 0) ; First CORE register (IP_REGNUM 12) ; Scratch register (SP_REGNUM 13) ; Stack pointer (LR_REGNUM 14) ; Return address register (PC_REGNUM 15) ; Program counter (CC_REGNUM 24) ; Condition code pseudo register (LAST_ARM_REGNUM 15) ; (FPA_F0_REGNUM 16) ; FIRST_FPA_REGNUM (FPA_F7_REGNUM 23) ; LAST_FPA_REGNUM ]);; 3rd operand to select_dominance_cc_mode(define_constants [(DOM_CC_X_AND_Y 0) (DOM_CC_NX_OR_Y 1) (DOM_CC_X_OR_Y 2) ]);; UNSPEC Usage:;; Note: sin and cos are no-longer used.(define_constants [(UNSPEC_SIN 0) ; `sin' operation (MODE_FLOAT): ; operand 0 is the result, ; operand 1 the parameter. (UNPSEC_COS 1) ; `cos' operation (MODE_FLOAT): ; operand 0 is the result, ; operand 1 the parameter. (UNSPEC_PUSH_MULT 2) ; `push multiple' operation: ; operand 0 is the first register, ; subsequent registers are in parallel (use ...) ; expressions. (UNSPEC_PIC_SYM 3) ; A symbol that has been treated properly for pic ; usage, that is, we will add the pic_register ; value to it before trying to dereference it. (UNSPEC_PIC_BASE 4) ; Adding the PC value to the offset to the ; GLOBAL_OFFSET_TABLE. The operation is fully ; described by the RTL but must be wrapped to ; prevent combine from trying to rip it apart. (UNSPEC_PRLG_STK 5) ; A special barrier that prevents frame accesses ; being scheduled before the stack adjustment insn. (UNSPEC_PROLOGUE_USE 6) ; As USE insns are not meaningful after reload, ; this unspec is used to prevent the deletion of ; instructions setting registers for EH handling ; and stack frame generation. Operand 0 is the ; register to "use". (UNSPEC_CHECK_ARCH 7); Set CCs to indicate 26-bit or 32-bit mode. (UNSPEC_WSHUFH 8) ; Used by the intrinsic form of the iWMMXt WSHUFH instruction. (UNSPEC_WACC 9) ; Used by the intrinsic form of the iWMMXt WACC instruction. (UNSPEC_TMOVMSK 10) ; Used by the intrinsic form of the iWMMXt TMOVMSK instruction. (UNSPEC_WSAD 11) ; Used by the intrinsic form of the iWMMXt WSAD instruction. (UNSPEC_WSADZ 12) ; Used by the intrinsic form of the iWMMXt WSADZ instruction. (UNSPEC_WMACS 13) ; Used by the intrinsic form of the iWMMXt WMACS instruction. (UNSPEC_WMACU 14) ; Used by the intrinsic form of the iWMMXt WMACU instruction. (UNSPEC_WMACSZ 15) ; Used by the intrinsic form of the iWMMXt WMACSZ instruction. (UNSPEC_WMACUZ 16) ; Used by the intrinsic form of the iWMMXt WMACUZ instruction. (UNSPEC_CLRDI 17) ; Used by the intrinsic form of the iWMMXt CLRDI instruction. (UNSPEC_WMADDS 18) ; Used by the intrinsic form of the iWMMXt WMADDS instruction. (UNSPEC_WMADDU 19) ; Used by the intrinsic form of the iWMMXt WMADDU instruction. ]);; UNSPEC_VOLATILE Usage:(define_constants [(VUNSPEC_BLOCKAGE 0) ; `blockage' insn to prevent scheduling across an ; insn in the code. (VUNSPEC_EPILOGUE 1) ; `epilogue' insn, used to represent any part of the ; instruction epilogue sequence that isn't expanded ; into normal RTL. Used for both normal and sibcall ; epilogues. (VUNSPEC_ALIGN 2) ; `align' insn. Used at the head of a minipool table ; for inlined constants. (VUNSPEC_POOL_END 3) ; `end-of-table'. Used to mark the end of a minipool ; table. (VUNSPEC_POOL_1 4) ; `pool-entry(1)'. An entry in the constant pool for ; an 8-bit object. (VUNSPEC_POOL_2 5) ; `pool-entry(2)'. An entry in the constant pool for ; a 16-bit object. (VUNSPEC_POOL_4 6) ; `pool-entry(4)'. An entry in the constant pool for ; a 32-bit object. (VUNSPEC_POOL_8 7) ; `pool-entry(8)'. An entry in the constant pool for ; a 64-bit object. (VUNSPEC_TMRC 8) ; Used by the iWMMXt TMRC instruction. (VUNSPEC_TMCR 9) ; Used by the iWMMXt TMCR instruction. (VUNSPEC_ALIGN8 10) ; 8-byte alignment version of VUNSPEC_ALIGN (VUNSPEC_WCMP_EQ 11) ; Used by the iWMMXt WCMPEQ instructions (VUNSPEC_WCMP_GTU 12) ; Used by the iWMMXt WCMPGTU instructions (VUNSPEC_WCMP_GT 13) ; Used by the iwMMXT WCMPGT instructions (VUNSPEC_EH_RETURN 20); Use to override the return address for exception ; handling. ]);;---------------------------------------------------------------------------;; Attributes; IS_THUMB is set to 'yes' when we are generating Thumb code, and 'no' when; generating ARM code. This is used to control the length of some insn; patterns that share the same RTL in both ARM and Thumb code.(define_attr "is_thumb" "no,yes" (const (symbol_ref "thumb_code"))); IS_STRONGARM is set to 'yes' when compiling for StrongARM, it affects; scheduling decisions for the load unit and the multiplier.(define_attr "is_strongarm" "no,yes" (const (symbol_ref "arm_is_strong"))); IS_XSCALE is set to 'yes' when compiling for XScale.(define_attr "is_xscale" "no,yes" (const (symbol_ref "arm_tune_xscale")));; Operand number of an input operand that is shifted. Zero if the;; given instruction does not shift one of its input operands.(define_attr "shift" "" (const_int 0)); Floating Point Unit. If we only have floating point emulation, then there; is no point in scheduling the floating point insns. (Well, for best; performance we should try and group them together).(define_attr "fpu" "none,fpa,fpe2,fpe3,maverick,vfp" (const (symbol_ref "arm_fpu_attr"))); LENGTH of an instruction (in bytes)(define_attr "length" "" (const_int 4)); POOL_RANGE is how far away from a constant pool entry that this insn; can be placed. If the distance is zero, then this insn will never; reference the pool.; NEG_POOL_RANGE is nonzero for insns that can reference a constant pool entry; before its address.(define_attr "pool_range" "" (const_int 0))(define_attr "neg_pool_range" "" (const_int 0)); An assembler sequence may clobber the condition codes without us knowing.; If such an insn references the pool, then we have no way of knowing how,; so use the most conservative value for pool_range.(define_asm_attributes [(set_attr "conds" "clob") (set_attr "length" "4") (set_attr "pool_range" "250")]);; The instruction used to implement a particular pattern. This;; information is used by pipeline descriptions to provide accurate;; scheduling information.(define_attr "insn" "smulxy,smlaxy,smlalxy,smulwy,smlawx,mul,muls,mla,mlas,umull,umulls,umlal,umlals,smull,smulls,smlal,smlals,smlawy,smuad,smuadx,smlad,smladx,smusd,smusdx,smlsd,smlsdx,smmul,smmulr,other" (const_string "other")); TYPE attribute is used to detect floating point instructions which, if; running on a co-processor can run in parallel with other, basic instructions; If write-buffer scheduling is enabled then it can also be used in the; scheduling of writes.; Classification of each insn; alu any alu instruction that doesn't hit memory or fp; regs or have a shifted source operand; alu_shift any data instruction that doesn't hit memory or fp; regs, but has a source operand shifted by a constant; alu_shift_reg any data instruction that doesn't hit memory or fp; regs, but has a source operand shifted by a register value; mult a multiply instruction; block blockage insn, this blocks all functional units; float a floating point arithmetic operation (subject to expansion); fdivd DFmode floating point division; fdivs SFmode floating point division; fmul Floating point multiply; ffmul Fast floating point multiply; farith Floating point arithmetic (4 cycle); ffarith Fast floating point arithmetic (2 cycle); float_em a floating point arithmetic operation that is normally emulated; even on a machine with an fpa.; f_load a floating point load from memory; f_store a floating point store to memory; f_mem_r a transfer of a floating point register to a real reg via mem; r_mem_f the reverse of f_mem_r; f_2_r fast transfer float to arm (no memory needed); r_2_f fast transfer arm to float; branch a branch; call a subroutine call; load_byte load byte(s) from memory to arm registers; load1 load 1 word from memory to arm registers; load2 load 2 words from memory to arm registers; load3 load 3 words from memory to arm registers; load4 load 4 words from memory to arm registers; store store 1 word to memory from arm registers; store2 store 2 words; store3 store 3 words; store4 store 4 (or more) words; Additions for Cirrus Maverick co-processor:; mav_farith Floating point arithmetic (4 cycle); mav_dmult Double multiplies (7 cycle);(define_attr "type" "alu,alu_shift,alu_shift_reg,mult,block,float,fdivx,fdivd,fdivs,fmul,ffmul,farith,ffarith,float_em,f_load,f_store,f_mem_r,r_mem_f,f_2_r,r_2_f,branch,call,load_byte,load1,load2,load3,load4,store1,store2,store3,store4,mav_farith,mav_dmult" (if_then_else (eq_attr "insn" "smulxy,smlaxy,smlalxy,smulwy,smlawx,mul,muls,mla,mlas,umull,umulls,umlal,umlals,smull,smulls,smlal,smlals") (const_string "mult") (const_string "alu"))); Load scheduling, set from the arm_ld_sched variable; initialized by arm_override_options() (define_attr "ldsched" "no,yes" (const (symbol_ref "arm_ld_sched"))); condition codes: this one is used by final_prescan_insn to speed up; conditionalizing instructions. It saves having to scan the rtl to see if; it uses or alters the condition codes.; ; USE means that the condition codes are used by the insn in the process of; outputting code, this means (at present) that we can't use the insn in; inlined branches;; SET means that the purpose of the insn is to set the condition codes in a; well defined manner.;; CLOB means that the condition codes are altered in an undefined manner, if; they are altered at all;; JUMP_CLOB is used when the condition cannot be represented by a single; instruction (UNEQ and LTGT). These cannot be predicated.;; NOCOND means that the condition codes are neither altered nor affect the; output of this insn(define_attr "conds" "use,set,clob,jump_clob,nocond" (if_then_else (eq_attr "type" "call") (const_string "clob") (const_string "nocond"))); Predicable means that the insn can be conditionally executed based on; an automatically added predicate (additional patterns are generated by ; gen...). We default to 'no' because no Thumb patterns match this rule; and not all ARM patterns do.(define_attr "predicable" "no,yes" (const_string "no")); Only model the write buffer for ARM6 and ARM7. Earlier processors don't; have one. Later ones, such as StrongARM, have write-back caches, so don't; suffer blockages enough to warrant modelling this (and it can adversely; affect the schedule).(define_attr "model_wbuf" "no,yes" (const (symbol_ref "arm_is_6_or_7"))); WRITE_CONFLICT implies that a read following an unrelated write is likely; to stall the processor. Used with model_wbuf above.(define_attr "write_conflict" "no,yes" (if_then_else (eq_attr "type" "block,float_em,f_load,f_store,f_mem_r,r_mem_f,call,load1") (const_string "yes") (const_string "no"))); Classify the insns into those that take one cycle and those that take more; than one on the main cpu execution unit.(define_attr "core_cycles" "single,multi" (if_then_else (eq_attr "type" "alu,alu_shift,float,fdivx,fdivd,fdivs,fmul,ffmul,farith,ffarith") (const_string "single") (const_string "multi")));; FAR_JUMP is "yes" if a BL instruction is used to generate a branch to a;; distant label. Only applicable to Thumb code.(define_attr "far_jump" "yes,no" (const_string "no"))(include "predicates.md");;---------------------------------------------------------------------------;; Pipeline descriptions;; Processor type. This is created automatically from arm-cores.def.(include "arm-tune.md");; True if the generic scheduling description should be used.(define_attr "generic_sched" "yes,no" (const (if_then_else (eq_attr "tune" "arm926ejs,arm1026ejs,arm1136js,arm1136jfs") (const_string "no") (const_string "yes"))))(include "arm-generic.md")(include "arm926ejs.md")(include "arm1026ejs.md")(include "arm1136jfs.md");;---------------------------------------------------------------------------;; Insn patterns;;;; Addition insns.;; Note: For DImode insns, there is normally no reason why operands should;; not be in the same register, what we don't want is for something being;; written to partially overlap something that is an input.;; Cirrus 64bit additions should not be split because we have a native;; 64bit addition instructions.(define_expand "adddi3" [(parallel [(set (match_operand:DI 0 "s_register_operand" "") (plus:DI (match_operand:DI 1 "s_register_operand" "") (match_operand:DI 2 "s_register_operand" ""))) (clobber (reg:CC CC_REGNUM))])] "TARGET_EITHER" " if (TARGET_HARD_FLOAT && TARGET_MAVERICK) { if (!cirrus_fp_register (operands[0], DImode)) operands[0] = force_reg (DImode, operands[0]); if (!cirrus_fp_register (operands[1], DImode)) operands[1] = force_reg (DImode, operands[1]); emit_insn (gen_cirrus_adddi3 (operands[0], operands[1], operands[2])); DONE; } if (TARGET_THUMB) { if (GET_CODE (operands[1]) != REG) operands[1] = force_reg (SImode, operands[1]); if (GET_CODE (operands[2]) != REG) operands[2] = force_reg (SImode, operands[2]); } ")(define_insn "*thumb_adddi3" [(set (match_operand:DI 0 "register_operand" "=l") (plus:DI (match_operand:DI 1 "register_operand" "%0") (match_operand:DI 2 "register_operand" "l"))) (clobber (reg:CC CC_REGNUM)) ] "TARGET_THUMB" "add\\t%Q0, %Q0, %Q2\;adc\\t%R0, %R0, %R2" [(set_attr "length" "4")])(define_insn_and_split "*arm_adddi3" [(set (match_operand:DI 0 "s_register_operand" "=&r,&r") (plus:DI (match_operand:DI 1 "s_register_operand" "%0, 0") (match_operand:DI 2 "s_register_operand" "r, 0"))) (clobber (reg:CC CC_REGNUM))] "TARGET_ARM && !(TARGET_HARD_FLOAT && TARGET_MAVERICK)" "#" "TARGET_ARM && reload_completed" [(parallel [(set (reg:CC_C CC_REGNUM) (compare:CC_C (plus:SI (match_dup 1) (match_dup 2)) (match_dup 1))) (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]) (set (match_dup 3) (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0)) (plus:SI (match_dup 4) (match_dup 5))))] " { operands[3] = gen_highpart (SImode, operands[0]); operands[0] = gen_lowpart (SImode, operands[0]); operands[4] = gen_highpart (SImode, operands[1]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -