18b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project/*
28b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * Tiny Code Generator for QEMU
38b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project *
48b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * Copyright (c) 2008 Fabrice Bellard
58b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project *
68b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * Permission is hereby granted, free of charge, to any person obtaining a copy
78b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * of this software and associated documentation files (the "Software"), to deal
88b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * in the Software without restriction, including without limitation the rights
98b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
108b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * copies of the Software, and to permit persons to whom the Software is
118b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * furnished to do so, subject to the following conditions:
128b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project *
138b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * The above copyright notice and this permission notice shall be included in
148b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * all copies or substantial portions of the Software.
158b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project *
168b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
178b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
188b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
198b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
208b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
218b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
228b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * THE SOFTWARE.
238b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project */
248b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_SPARC 1
258b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
268b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
278b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_REG_BITS 64
288b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#else
298b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_REG_BITS 32
308b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#endif
318b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
328b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_WORDS_BIGENDIAN
338b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
348b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_NB_REGS 32
358b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
368b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectenum {
378b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G0 = 0,
388b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G1,
398b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G2,
408b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G3,
418b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G4,
428b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G5,
438b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G6,
448b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_G7,
458b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O0,
468b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O1,
478b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O2,
488b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O3,
498b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O4,
508b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O5,
518b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O6,
528b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_O7,
538b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L0,
548b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L1,
558b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L2,
568b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L3,
578b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L4,
588b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L5,
598b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L6,
608b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_L7,
618b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I0,
628b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I1,
638b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I2,
648b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I3,
658b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I4,
668b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I5,
678b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I6,
688b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    TCG_REG_I7,
698b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project};
708b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
718b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_CT_CONST_S11 0x100
728b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_CT_CONST_S13 0x200
738b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
748b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project/* used for function call generation */
758b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_REG_CALL_STACK TCG_REG_I6
768b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#ifdef __arch64__
778b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project// Reserve space for AREG0
785d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TCG_TARGET_STACK_MINFRAME (176 + 4 * (int)sizeof(long) + \
795d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner                                   TCG_STATIC_CALL_ARGS_SIZE)
805d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TCG_TARGET_CALL_STACK_OFFSET (2047 - 16)
818b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_STACK_ALIGN 16
828b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#else
838b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project// AREG0 + one word for alignment
845d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TCG_TARGET_STACK_MINFRAME (92 + (2 + 1) * (int)sizeof(long) + \
855d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner                                   TCG_STATIC_CALL_ARGS_SIZE)
868b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_CALL_STACK_OFFSET TCG_TARGET_STACK_MINFRAME
878b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_TARGET_STACK_ALIGN 8
888b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#endif
898b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
908b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project/* optional instructions */
915d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner//#define TCG_TARGET_HAS_bswap32_i32
925d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner//#define TCG_TARGET_HAS_bswap64_i64
938b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project//#define TCG_TARGET_HAS_neg_i32
948b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project//#define TCG_TARGET_HAS_neg_i64
958b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
968b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
978b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project/* Note: must be synced with dyngen-exec.h and Makefile.target */
988b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#ifdef HOST_SOLARIS
998b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG0 TCG_REG_G2
1008b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG1 TCG_REG_G3
1018b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG2 TCG_REG_G4
1028b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#elif defined(__sparc_v9__)
1038b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG0 TCG_REG_G5
1048b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG1 TCG_REG_G6
1058b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG2 TCG_REG_G7
1068b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#else
1078b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG0 TCG_REG_G6
1088b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG1 TCG_REG_G1
1098b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define TCG_AREG2 TCG_REG_G2
1108b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#endif
1118b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
1128b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectstatic inline void flush_icache_range(unsigned long start, unsigned long stop)
1138b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
1148b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    unsigned long p;
1158b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
1168b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    p = start & ~(8UL - 1UL);
1178b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    stop = (stop + (8UL - 1UL)) & ~(8UL - 1UL);
1188b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
1198b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    for (; p < stop; p += 8)
1208b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project        __asm__ __volatile__("flush\t%0" : : "r" (p));
1218b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
122