Path: blob/master/arch/xtensa/include/asm/asmmacro.h
15126 views
/*1* include/asm-xtensa/asmmacro.h2*3* This file is subject to the terms and conditions of the GNU General Public4* License. See the file "COPYING" in the main directory of this archive5* for more details.6*7* Copyright (C) 2005 Tensilica Inc.8*/910#ifndef _XTENSA_ASMMACRO_H11#define _XTENSA_ASMMACRO_H1213#include <variant/core.h>1415/*16* Some little helpers for loops. Use zero-overhead-loops17* where applicable and if supported by the processor.18*19* __loopi ar, at, size, inc20* ar register initialized with the start address21* at scratch register used by macro22* size size immediate value23* inc increment24*25* __loops ar, as, at, inc_log2[, mask_log2][, cond][, ncond]26* ar register initialized with the start address27* as register initialized with the size28* at scratch register use by macro29* inc_log2 increment [in log2]30* mask_log2 mask [in log2]31* cond true condition (used in loop'cond')32* ncond false condition (used in b'ncond')33*34* __loop as35* restart loop. 'as' register must not have been modified!36*37* __endla ar, at, incr38* ar start address (modified)39* as scratch register used by macro40* inc increment41*/4243/*44* loop for given size as immediate45*/4647.macro __loopi ar, at, size, incr4849#if XCHAL_HAVE_LOOPS50movi \at, ((\size + \incr - 1) / (\incr))51loop \at, 99f52#else53addi \at, \ar, \size5498:55#endif5657.endm5859/*60* loop for given size in register61*/6263.macro __loops ar, as, at, incr_log2, mask_log2, cond, ncond6465#if XCHAL_HAVE_LOOPS66.ifgt \incr_log2 - 167addi \at, \as, (1 << \incr_log2) - 168.ifnc \mask_log2,69extui \at, \at, \incr_log2, \mask_log270.else71srli \at, \at, \incr_log272.endif73.endif74loop\cond \at, 99f75#else76.ifnc \mask_log2,77extui \at, \as, \incr_log2, \mask_log278.else79.ifnc \ncond,80srli \at, \as, \incr_log281.endif82.endif83.ifnc \ncond,84b\ncond \at, 99f8586.endif87.ifnc \mask_log2,88slli \at, \at, \incr_log289add \at, \ar, \at90.else91add \at, \ar, \as92.endif93#endif9498:9596.endm9798/*99* loop from ar to ax100*/101102.macro __loopt ar, as, at, incr_log2103104#if XCHAL_HAVE_LOOPS105sub \at, \as, \ar106.ifgt \incr_log2 - 1107addi \at, \at, (1 << \incr_log2) - 1108srli \at, \at, \incr_log2109.endif110loop \at, 99f111#else11298:113#endif114115.endm116117/*118* restart loop. registers must be unchanged119*/120121.macro __loop as122123#if XCHAL_HAVE_LOOPS124loop \as, 99f125#else12698:127#endif128129.endm130131/*132* end of loop with no increment of the address.133*/134135.macro __endl ar, as136#if !XCHAL_HAVE_LOOPS137bltu \ar, \as, 98b138#endif13999:140.endm141142/*143* end of loop with increment of the address.144*/145146.macro __endla ar, as, incr147addi \ar, \ar, \incr148__endl \ar \as149.endm150151152#endif /* _XTENSA_ASMMACRO_H */153154155