Path: blob/master/arch/xtensa/variants/csp/include/variant/tie-asm.h
26535 views
/*1* tie-asm.h -- compile-time HAL assembler definitions dependent on CORE & TIE2*3* NOTE: This header file is not meant to be included directly.4*/56/* This header file contains assembly-language definitions (assembly7macros, etc.) for this specific Xtensa processor's TIE extensions8and options. It is customized to this Xtensa processor configuration.910Copyright (c) 1999-2015 Cadence Design Systems Inc.1112Permission is hereby granted, free of charge, to any person obtaining13a copy of this software and associated documentation files (the14"Software"), to deal in the Software without restriction, including15without limitation the rights to use, copy, modify, merge, publish,16distribute, sublicense, and/or sell copies of the Software, and to17permit persons to whom the Software is furnished to do so, subject to18the following conditions:1920The above copyright notice and this permission notice shall be included21in all copies or substantial portions of the Software.2223THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.26IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY27CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,28TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE29SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */3031#ifndef _XTENSA_CORE_TIE_ASM_H32#define _XTENSA_CORE_TIE_ASM_H3334/* Selection parameter values for save-area save/restore macros: */35/* Option vs. TIE: */36#define XTHAL_SAS_TIE 0x0001 /* custom extension or coprocessor */37#define XTHAL_SAS_OPT 0x0002 /* optional (and not a coprocessor) */38#define XTHAL_SAS_ANYOT 0x0003 /* both of the above */39/* Whether used automatically by compiler: */40#define XTHAL_SAS_NOCC 0x0004 /* not used by compiler w/o special opts/code */41#define XTHAL_SAS_CC 0x0008 /* used by compiler without special opts/code */42#define XTHAL_SAS_ANYCC 0x000C /* both of the above */43/* ABI handling across function calls: */44#define XTHAL_SAS_CALR 0x0010 /* caller-saved */45#define XTHAL_SAS_CALE 0x0020 /* callee-saved */46#define XTHAL_SAS_GLOB 0x0040 /* global across function calls (in thread) */47#define XTHAL_SAS_ANYABI 0x0070 /* all of the above three */48/* Misc */49#define XTHAL_SAS_ALL 0xFFFF /* include all default NCP contents */50#define XTHAL_SAS3(optie,ccuse,abi) ( ((optie) & XTHAL_SAS_ANYOT) \51| ((ccuse) & XTHAL_SAS_ANYCC) \52| ((abi) & XTHAL_SAS_ANYABI) )535455/*56* Macro to store all non-coprocessor (extra) custom TIE and optional state57* (not including zero-overhead loop registers).58* Required parameters:59* ptr Save area pointer address register (clobbered)60* (register must contain a 4 byte aligned address).61* at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS62* registers are clobbered, the remaining are unused).63* Optional parameters:64* continue If macro invoked as part of a larger store sequence, set to 165* if this is not the first in the sequence. Defaults to 0.66* ofs Offset from start of larger sequence (from value of first ptr67* in sequence) at which to store. Defaults to next available space68* (or 0 if <continue> is 0).69* select Select what category(ies) of registers to store, as a bitmask70* (see XTHAL_SAS_xxx constants). Defaults to all registers.71* alloc Select what category(ies) of registers to allocate; if any72* category is selected here that is not in <select>, space for73* the corresponding registers is skipped without doing any store.74*/75.macro xchal_ncp_store ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=076xchal_sa_start \continue, \ofs77// Optional global registers used by default by the compiler:78.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\select)79xchal_sa_align \ptr, 0, 1020, 4, 480rur.THREADPTR \at1 // threadptr option81s32i \at1, \ptr, .Lxchal_ofs_+082.set .Lxchal_ofs_, .Lxchal_ofs_ + 483.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\alloc)) == 084xchal_sa_align \ptr, 0, 1020, 4, 485.set .Lxchal_ofs_, .Lxchal_ofs_ + 486.endif87// Optional caller-saved registers used by default by the compiler:88.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)89xchal_sa_align \ptr, 0, 1016, 4, 490rsr.ACCLO \at1 // MAC16 option91s32i \at1, \ptr, .Lxchal_ofs_+092rsr.ACCHI \at1 // MAC16 option93s32i \at1, \ptr, .Lxchal_ofs_+494.set .Lxchal_ofs_, .Lxchal_ofs_ + 895.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 096xchal_sa_align \ptr, 0, 1016, 4, 497.set .Lxchal_ofs_, .Lxchal_ofs_ + 898.endif99// Optional caller-saved registers not used by default by the compiler:100.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)101xchal_sa_align \ptr, 0, 1000, 4, 4102rsr.BR \at1 // boolean option103s32i \at1, \ptr, .Lxchal_ofs_+0104rsr.SCOMPARE1 \at1 // conditional store option105s32i \at1, \ptr, .Lxchal_ofs_+4106rsr.M0 \at1 // MAC16 option107s32i \at1, \ptr, .Lxchal_ofs_+8108rsr.M1 \at1 // MAC16 option109s32i \at1, \ptr, .Lxchal_ofs_+12110rsr.M2 \at1 // MAC16 option111s32i \at1, \ptr, .Lxchal_ofs_+16112rsr.M3 \at1 // MAC16 option113s32i \at1, \ptr, .Lxchal_ofs_+20114.set .Lxchal_ofs_, .Lxchal_ofs_ + 24115.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0116xchal_sa_align \ptr, 0, 1000, 4, 4117.set .Lxchal_ofs_, .Lxchal_ofs_ + 24118.endif119.endm // xchal_ncp_store120121/*122* Macro to load all non-coprocessor (extra) custom TIE and optional state123* (not including zero-overhead loop registers).124* Required parameters:125* ptr Save area pointer address register (clobbered)126* (register must contain a 4 byte aligned address).127* at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS128* registers are clobbered, the remaining are unused).129* Optional parameters:130* continue If macro invoked as part of a larger load sequence, set to 1131* if this is not the first in the sequence. Defaults to 0.132* ofs Offset from start of larger sequence (from value of first ptr133* in sequence) at which to load. Defaults to next available space134* (or 0 if <continue> is 0).135* select Select what category(ies) of registers to load, as a bitmask136* (see XTHAL_SAS_xxx constants). Defaults to all registers.137* alloc Select what category(ies) of registers to allocate; if any138* category is selected here that is not in <select>, space for139* the corresponding registers is skipped without doing any load.140*/141.macro xchal_ncp_load ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0142xchal_sa_start \continue, \ofs143// Optional global registers used by default by the compiler:144.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\select)145xchal_sa_align \ptr, 0, 1020, 4, 4146l32i \at1, \ptr, .Lxchal_ofs_+0147wur.THREADPTR \at1 // threadptr option148.set .Lxchal_ofs_, .Lxchal_ofs_ + 4149.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\alloc)) == 0150xchal_sa_align \ptr, 0, 1020, 4, 4151.set .Lxchal_ofs_, .Lxchal_ofs_ + 4152.endif153// Optional caller-saved registers used by default by the compiler:154.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)155xchal_sa_align \ptr, 0, 1016, 4, 4156l32i \at1, \ptr, .Lxchal_ofs_+0157wsr.ACCLO \at1 // MAC16 option158l32i \at1, \ptr, .Lxchal_ofs_+4159wsr.ACCHI \at1 // MAC16 option160.set .Lxchal_ofs_, .Lxchal_ofs_ + 8161.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0162xchal_sa_align \ptr, 0, 1016, 4, 4163.set .Lxchal_ofs_, .Lxchal_ofs_ + 8164.endif165// Optional caller-saved registers not used by default by the compiler:166.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)167xchal_sa_align \ptr, 0, 1000, 4, 4168l32i \at1, \ptr, .Lxchal_ofs_+0169wsr.BR \at1 // boolean option170l32i \at1, \ptr, .Lxchal_ofs_+4171wsr.SCOMPARE1 \at1 // conditional store option172l32i \at1, \ptr, .Lxchal_ofs_+8173wsr.M0 \at1 // MAC16 option174l32i \at1, \ptr, .Lxchal_ofs_+12175wsr.M1 \at1 // MAC16 option176l32i \at1, \ptr, .Lxchal_ofs_+16177wsr.M2 \at1 // MAC16 option178l32i \at1, \ptr, .Lxchal_ofs_+20179wsr.M3 \at1 // MAC16 option180.set .Lxchal_ofs_, .Lxchal_ofs_ + 24181.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0182xchal_sa_align \ptr, 0, 1000, 4, 4183.set .Lxchal_ofs_, .Lxchal_ofs_ + 24184.endif185.endm // xchal_ncp_load186187188#define XCHAL_NCP_NUM_ATMPS 1189190#define XCHAL_SA_NUM_ATMPS 1191192#endif /*_XTENSA_CORE_TIE_ASM_H*/193194195196