summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2015-02-06 15:29:47 -0500
committerGravatar bunnei2015-02-06 15:29:47 -0500
commitc4e636681ef7f5fa77893fb2fe141eaac8cc10a4 (patch)
tree22e9c4e9e3e4738d9846e42f1dd4fb836ac4c91d /src/core
parentMerge pull request #535 from bunnei/color-modifiers (diff)
parentvfp_helper: Remove unnecessary extern C blocks (diff)
downloadyuzu-c4e636681ef7f5fa77893fb2fe141eaac8cc10a4.tar.gz
yuzu-c4e636681ef7f5fa77893fb2fe141eaac8cc10a4.tar.xz
yuzu-c4e636681ef7f5fa77893fb2fe141eaac8cc10a4.zip
Merge pull request #541 from lioncash/nits
Small VFP cleanups.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/arm/skyeye_common/vfp/asm_vfp.h141
-rw-r--r--src/core/arm/skyeye_common/vfp/vfp.cpp1
-rw-r--r--src/core/arm/skyeye_common/vfp/vfp.h112
-rw-r--r--src/core/arm/skyeye_common/vfp/vfp_helper.h18
4 files changed, 105 insertions, 167 deletions
diff --git a/src/core/arm/skyeye_common/vfp/asm_vfp.h b/src/core/arm/skyeye_common/vfp/asm_vfp.h
index e113eaf29..ccb7cf4d7 100644
--- a/src/core/arm/skyeye_common/vfp/asm_vfp.h
+++ b/src/core/arm/skyeye_common/vfp/asm_vfp.h
@@ -7,80 +7,77 @@
7 7
8#pragma once 8#pragma once
9 9
10#define FPSID cr0 10// FPSID Information
11#define FPSCR cr1 11// Note that these are used as values and not as flags.
12#define MVFR1 cr6 12enum : u32 {
13#define MVFR0 cr7 13 VFP_FPSID_IMPLMEN = 0, // Implementation code. Should be the same as cp15 0 c0 0
14#define FPEXC cr8 14 VFP_FPSID_SW = 0, // Software emulation bit value
15#define FPINST cr9 15 VFP_FPSID_SUBARCH = 0x2, // Subarchitecture version number
16#define FPINST2 cr10 16 VFP_FPSID_PARTNUM = 0x1, // Part number
17 VFP_FPSID_VARIANT = 0x1, // Variant number
18 VFP_FPSID_REVISION = 0x1 // Revision number
19};
17 20
18/* FPSID bits */ 21// FPEXC bits
19#define FPSID_IMPLEMENTER_BIT (24) 22enum : u32 {
20#define FPSID_IMPLEMENTER_MASK (0xff << FPSID_IMPLEMENTER_BIT) 23 FPEXC_EX = (1U << 31U),
21#define FPSID_SOFTWARE (1<<23) 24 FPEXC_EN = (1 << 30),
22#define FPSID_FORMAT_BIT (21) 25 FPEXC_DEX = (1 << 29),
23#define FPSID_FORMAT_MASK (0x3 << FPSID_FORMAT_BIT) 26 FPEXC_FP2V = (1 << 28),
24#define FPSID_NODOUBLE (1<<20) 27 FPEXC_VV = (1 << 27),
25#define FPSID_ARCH_BIT (16) 28 FPEXC_TFV = (1 << 26),
26#define FPSID_ARCH_MASK (0xF << FPSID_ARCH_BIT) 29 FPEXC_LENGTH_BIT = (8),
27#define FPSID_PART_BIT (8) 30 FPEXC_LENGTH_MASK = (7 << FPEXC_LENGTH_BIT),
28#define FPSID_PART_MASK (0xFF << FPSID_PART_BIT) 31 FPEXC_IDF = (1 << 7),
29#define FPSID_VARIANT_BIT (4) 32 FPEXC_IXF = (1 << 4),
30#define FPSID_VARIANT_MASK (0xF << FPSID_VARIANT_BIT) 33 FPEXC_UFF = (1 << 3),
31#define FPSID_REV_BIT (0) 34 FPEXC_OFF = (1 << 2),
32#define FPSID_REV_MASK (0xF << FPSID_REV_BIT) 35 FPEXC_DZF = (1 << 1),
36 FPEXC_IOF = (1 << 0),
37 FPEXC_TRAP_MASK = (FPEXC_IDF|FPEXC_IXF|FPEXC_UFF|FPEXC_OFF|FPEXC_DZF|FPEXC_IOF)
38};
33 39
34/* FPEXC bits */ 40// FPSCR Flags
35#define FPEXC_EX (1 << 31) 41enum : u32 {
36#define FPEXC_EN (1 << 30) 42 FPSCR_NFLAG = (1U << 31U), // Negative condition flag
37#define FPEXC_DEX (1 << 29) 43 FPSCR_ZFLAG = (1 << 30), // Zero condition flag
38#define FPEXC_FP2V (1 << 28) 44 FPSCR_CFLAG = (1 << 29), // Carry condition flag
39#define FPEXC_VV (1 << 27) 45 FPSCR_VFLAG = (1 << 28), // Overflow condition flag
40#define FPEXC_TFV (1 << 26)
41#define FPEXC_LENGTH_BIT (8)
42#define FPEXC_LENGTH_MASK (7 << FPEXC_LENGTH_BIT)
43#define FPEXC_IDF (1 << 7)
44#define FPEXC_IXF (1 << 4)
45#define FPEXC_UFF (1 << 3)
46#define FPEXC_OFF (1 << 2)
47#define FPEXC_DZF (1 << 1)
48#define FPEXC_IOF (1 << 0)
49#define FPEXC_TRAP_MASK (FPEXC_IDF|FPEXC_IXF|FPEXC_UFF|FPEXC_OFF|FPEXC_DZF|FPEXC_IOF)
50 46
51/* FPSCR bits */ 47 FPSCR_QC = (1 << 27), // Cumulative saturation bit
52#define FPSCR_DEFAULT_NAN (1<<25) 48 FPSCR_AHP = (1 << 26), // Alternative half-precision control bit
53#define FPSCR_FLUSHTOZERO (1<<24) 49 FPSCR_DEFAULT_NAN = (1 << 25), // Default NaN mode control bit
54#define FPSCR_ROUND_NEAREST (0<<22) 50 FPSCR_FLUSH_TO_ZERO = (1 << 24), // Flush-to-zero mode control bit
55#define FPSCR_ROUND_PLUSINF (1<<22) 51 FPSCR_RMODE_MASK = (3 << 22), // Rounding Mode bit mask
56#define FPSCR_ROUND_MINUSINF (2<<22) 52 FPSCR_STRIDE_MASK = (3 << 20), // Vector stride bit mask
57#define FPSCR_ROUND_TOZERO (3<<22) 53 FPSCR_LENGTH_MASK = (7 << 16), // Vector length bit mask
58#define FPSCR_RMODE_BIT (22)
59#define FPSCR_RMODE_MASK (3 << FPSCR_RMODE_BIT)
60#define FPSCR_STRIDE_BIT (20)
61#define FPSCR_STRIDE_MASK (3 << FPSCR_STRIDE_BIT)
62#define FPSCR_LENGTH_BIT (16)
63#define FPSCR_LENGTH_MASK (7 << FPSCR_LENGTH_BIT)
64#define FPSCR_IOE (1<<8)
65#define FPSCR_DZE (1<<9)
66#define FPSCR_OFE (1<<10)
67#define FPSCR_UFE (1<<11)
68#define FPSCR_IXE (1<<12)
69#define FPSCR_IDE (1<<15)
70#define FPSCR_IOC (1<<0)
71#define FPSCR_DZC (1<<1)
72#define FPSCR_OFC (1<<2)
73#define FPSCR_UFC (1<<3)
74#define FPSCR_IXC (1<<4)
75#define FPSCR_IDC (1<<7)
76 54
77/* MVFR0 bits */ 55 FPSCR_IDE = (1 << 15), // Input Denormal exception trap enable.
78#define MVFR0_A_SIMD_BIT (0) 56 FPSCR_IXE = (1 << 12), // Inexact exception trap enable
79#define MVFR0_A_SIMD_MASK (0xf << MVFR0_A_SIMD_BIT) 57 FPSCR_UFE = (1 << 11), // Undeflow exception trap enable
58 FPSCR_OFE = (1 << 10), // Overflow exception trap enable
59 FPSCR_DZE = (1 << 9), // Division by Zero exception trap enable
60 FPSCR_IOE = (1 << 8), // Invalid Operation exception trap enable
80 61
81/* Bit patterns for decoding the packaged operation descriptors */ 62 FPSCR_IDC = (1 << 7), // Input Denormal cumulative exception bit
82#define VFPOPDESC_LENGTH_BIT (9) 63 FPSCR_IXC = (1 << 4), // Inexact cumulative exception bit
83#define VFPOPDESC_LENGTH_MASK (0x07 << VFPOPDESC_LENGTH_BIT) 64 FPSCR_UFC = (1 << 3), // Undeflow cumulative exception bit
84#define VFPOPDESC_UNUSED_BIT (24) 65 FPSCR_OFC = (1 << 2), // Overflow cumulative exception bit
85#define VFPOPDESC_UNUSED_MASK (0xFF << VFPOPDESC_UNUSED_BIT) 66 FPSCR_DZC = (1 << 1), // Division by Zero cumulative exception bit
86#define VFPOPDESC_OPDESC_MASK (~(VFPOPDESC_LENGTH_MASK | VFPOPDESC_UNUSED_MASK)) 67 FPSCR_IOC = (1 << 0), // Invalid Operation cumulative exception bit
68};
69
70// FPSCR bit offsets
71enum : u32 {
72 FPSCR_RMODE_BIT = 22,
73 FPSCR_STRIDE_BIT = 20,
74 FPSCR_LENGTH_BIT = 16,
75};
76
77// FPSCR rounding modes
78enum : u32 {
79 FPSCR_ROUND_NEAREST = (0 << 22),
80 FPSCR_ROUND_PLUSINF = (1 << 22),
81 FPSCR_ROUND_MINUSINF = (2 << 22),
82 FPSCR_ROUND_TOZERO = (3 << 22)
83};
diff --git a/src/core/arm/skyeye_common/vfp/vfp.cpp b/src/core/arm/skyeye_common/vfp/vfp.cpp
index 563247c78..888709124 100644
--- a/src/core/arm/skyeye_common/vfp/vfp.cpp
+++ b/src/core/arm/skyeye_common/vfp/vfp.cpp
@@ -23,6 +23,7 @@
23#include "common/common.h" 23#include "common/common.h"
24 24
25#include "core/arm/skyeye_common/armdefs.h" 25#include "core/arm/skyeye_common/armdefs.h"
26#include "core/arm/skyeye_common/vfp/asm_vfp.h"
26#include "core/arm/skyeye_common/vfp/vfp.h" 27#include "core/arm/skyeye_common/vfp/vfp.h"
27 28
28//ARMul_State* persistent_state; /* function calls from SoftFloat lib don't have an access to ARMul_state. */ 29//ARMul_State* persistent_state; /* function calls from SoftFloat lib don't have an access to ARMul_state. */
diff --git a/src/core/arm/skyeye_common/vfp/vfp.h b/src/core/arm/skyeye_common/vfp/vfp.h
index 09c7520db..445a224bc 100644
--- a/src/core/arm/skyeye_common/vfp/vfp.h
+++ b/src/core/arm/skyeye_common/vfp/vfp.h
@@ -25,86 +25,42 @@
25#define VFP_DEBUG_UNIMPLEMENTED(x) LOG_ERROR(Core_ARM11, "in func %s, " #x " unimplemented\n", __FUNCTION__); exit(-1); 25#define VFP_DEBUG_UNIMPLEMENTED(x) LOG_ERROR(Core_ARM11, "in func %s, " #x " unimplemented\n", __FUNCTION__); exit(-1);
26#define VFP_DEBUG_UNTESTED(x) LOG_TRACE(Core_ARM11, "in func %s, " #x " untested\n", __FUNCTION__); 26#define VFP_DEBUG_UNTESTED(x) LOG_TRACE(Core_ARM11, "in func %s, " #x " untested\n", __FUNCTION__);
27#define CHECK_VFP_ENABLED 27#define CHECK_VFP_ENABLED
28#define CHECK_VFP_CDP_RET vfp_raise_exceptions(cpu, ret, inst_cream->instr, cpu->VFP[VFP_OFFSET(VFP_FPSCR)]); //if (ret == -1) {printf("VFP CDP FAILURE %x\n", inst_cream->instr); exit(-1);} 28#define CHECK_VFP_CDP_RET vfp_raise_exceptions(cpu, ret, inst_cream->instr, cpu->VFP[VFP_OFFSET(VFP_FPSCR)]); //if (ret == -1) {printf("VFP CDP FAILURE %x\n", inst_cream->instr); exit(-1);}
29 29
30unsigned VFPInit (ARMul_State *state); 30unsigned VFPInit(ARMul_State* state);
31unsigned VFPMRC (ARMul_State * state, unsigned type, ARMword instr, ARMword * value); 31unsigned VFPMRC(ARMul_State* state, unsigned type, ARMword instr, ARMword* value);
32unsigned VFPMCR (ARMul_State * state, unsigned type, ARMword instr, ARMword value); 32unsigned VFPMCR(ARMul_State* state, unsigned type, ARMword instr, ARMword value);
33unsigned VFPMRRC (ARMul_State * state, unsigned type, ARMword instr, ARMword * value1, ARMword * value2); 33unsigned VFPMRRC(ARMul_State* state, unsigned type, ARMword instr, ARMword* value1, ARMword* value2);
34unsigned VFPMCRR (ARMul_State * state, unsigned type, ARMword instr, ARMword value1, ARMword value2); 34unsigned VFPMCRR(ARMul_State* state, unsigned type, ARMword instr, ARMword value1, ARMword value2);
35unsigned VFPSTC (ARMul_State * state, unsigned type, ARMword instr, ARMword * value); 35unsigned VFPSTC(ARMul_State* state, unsigned type, ARMword instr, ARMword* value);
36unsigned VFPLDC (ARMul_State * state, unsigned type, ARMword instr, ARMword value); 36unsigned VFPLDC(ARMul_State* state, unsigned type, ARMword instr, ARMword value);
37unsigned VFPCDP (ARMul_State * state, unsigned type, ARMword instr); 37unsigned VFPCDP(ARMul_State* state, unsigned type, ARMword instr);
38 38
39/* FPSID Information */ 39s32 vfp_get_float(ARMul_State* state, u32 reg);
40#define VFP_FPSID_IMPLMEN 0 /* should be the same as cp15 0 c0 0*/ 40void vfp_put_float(ARMul_State* state, s32 val, u32 reg);
41#define VFP_FPSID_SW 0 41u64 vfp_get_double(ARMul_State* state, u32 reg);
42#define VFP_FPSID_SUBARCH 0x2 /* VFP version. Current is v3 (not strict) */ 42void vfp_put_double(ARMul_State* state, u64 val, u32 reg);
43#define VFP_FPSID_PARTNUM 0x1 43void vfp_raise_exceptions(ARMul_State* state, u32 exceptions, u32 inst, u32 fpscr);
44#define VFP_FPSID_VARIANT 0x1
45#define VFP_FPSID_REVISION 0x1
46
47/* FPEXC Flags */
48#define VFP_FPEXC_EX 1<<31
49#define VFP_FPEXC_EN 1<<30
50
51/* FPSCR Flags */
52#define VFP_FPSCR_NFLAG 1<<31
53#define VFP_FPSCR_ZFLAG 1<<30
54#define VFP_FPSCR_CFLAG 1<<29
55#define VFP_FPSCR_VFLAG 1<<28
56
57#define VFP_FPSCR_AHP 1<<26 /* Alternative Half Precision */
58#define VFP_FPSCR_DN 1<<25 /* Default NaN */
59#define VFP_FPSCR_FZ 1<<24 /* Flush-to-zero */
60#define VFP_FPSCR_RMODE 3<<22 /* Rounding Mode */
61#define VFP_FPSCR_STRIDE 3<<20 /* Stride (vector) */
62#define VFP_FPSCR_LEN 7<<16 /* Stride (vector) */
63
64#define VFP_FPSCR_IDE 1<<15 /* Input Denormal exc */
65#define VFP_FPSCR_IXE 1<<12 /* Inexact exc */
66#define VFP_FPSCR_UFE 1<<11 /* Undeflow exc */
67#define VFP_FPSCR_OFE 1<<10 /* Overflow exc */
68#define VFP_FPSCR_DZE 1<<9 /* Division by Zero exc */
69#define VFP_FPSCR_IOE 1<<8 /* Invalid Operation exc */
70
71#define VFP_FPSCR_IDC 1<<7 /* Input Denormal cum exc */
72#define VFP_FPSCR_IXC 1<<4 /* Inexact cum exc */
73#define VFP_FPSCR_UFC 1<<3 /* Undeflow cum exc */
74#define VFP_FPSCR_OFC 1<<2 /* Overflow cum exc */
75#define VFP_FPSCR_DZC 1<<1 /* Division by Zero cum exc */
76#define VFP_FPSCR_IOC 1<<0 /* Invalid Operation cum exc */
77
78/* Inline instructions. Note: Used in a cpp file as well */
79#ifdef __cplusplus
80 extern "C" {
81#endif
82int32_t vfp_get_float(ARMul_State * state, unsigned int reg);
83void vfp_put_float(ARMul_State * state, int32_t val, unsigned int reg);
84uint64_t vfp_get_double(ARMul_State * state, unsigned int reg);
85void vfp_put_double(ARMul_State * state, uint64_t val, unsigned int reg);
86void vfp_raise_exceptions(ARMul_State * state, uint32_t exceptions, uint32_t inst, uint32_t fpscr);
87u32 vfp_single_cpdo(ARMul_State* state, u32 inst, u32 fpscr); 44u32 vfp_single_cpdo(ARMul_State* state, u32 inst, u32 fpscr);
88u32 vfp_double_cpdo(ARMul_State* state, u32 inst, u32 fpscr); 45u32 vfp_double_cpdo(ARMul_State* state, u32 inst, u32 fpscr);
89 46
90/* MRC */ 47// MRC
91void VMRS(ARMul_State * state, ARMword reg, ARMword Rt, ARMword *value); 48void VMRS(ARMul_State* state, ARMword reg, ARMword Rt, ARMword* value);
92void VMOVBRS(ARMul_State * state, ARMword to_arm, ARMword t, ARMword n, ARMword *value); 49void VMOVBRS(ARMul_State* state, ARMword to_arm, ARMword t, ARMword n, ARMword* value);
93void VMOVBRRD(ARMul_State * state, ARMword to_arm, ARMword t, ARMword t2, ARMword n, ARMword *value1, ARMword *value2); 50void VMOVBRRD(ARMul_State* state, ARMword to_arm, ARMword t, ARMword t2, ARMword n, ARMword* value1, ARMword* value2);
94void VMOVBRRSS(ARMul_State* state, ARMword to_arm, ARMword t, ARMword t2, ARMword n, ARMword* value1, ARMword* value2); 51void VMOVBRRSS(ARMul_State* state, ARMword to_arm, ARMword t, ARMword t2, ARMword n, ARMword* value1, ARMword* value2);
95void VMOVI(ARMul_State * state, ARMword single, ARMword d, ARMword imm); 52void VMOVI(ARMul_State* state, ARMword single, ARMword d, ARMword imm);
96void VMOVR(ARMul_State * state, ARMword single, ARMword d, ARMword imm); 53void VMOVR(ARMul_State* state, ARMword single, ARMword d, ARMword imm);
97/* MCR */ 54
98void VMSR(ARMul_State * state, ARMword reg, ARMword Rt); 55// MCR
99/* STC */ 56void VMSR(ARMul_State* state, ARMword reg, ARMword Rt);
100int VSTM(ARMul_State * state, int type, ARMword instr, ARMword* value); 57
101int VPUSH(ARMul_State * state, int type, ARMword instr, ARMword* value); 58// STC
102int VSTR(ARMul_State * state, int type, ARMword instr, ARMword* value); 59int VSTM(ARMul_State* state, int type, ARMword instr, ARMword* value);
103/* LDC */ 60int VPUSH(ARMul_State* state, int type, ARMword instr, ARMword* value);
104int VLDM(ARMul_State * state, int type, ARMword instr, ARMword value); 61int VSTR(ARMul_State* state, int type, ARMword instr, ARMword* value);
105int VPOP(ARMul_State * state, int type, ARMword instr, ARMword value);
106int VLDR(ARMul_State * state, int type, ARMword instr, ARMword value);
107 62
108#ifdef __cplusplus 63// LDC
109 } 64int VLDM(ARMul_State* state, int type, ARMword instr, ARMword value);
110#endif 65int VPOP(ARMul_State* state, int type, ARMword instr, ARMword value);
66int VLDR(ARMul_State* state, int type, ARMword instr, ARMword value);
diff --git a/src/core/arm/skyeye_common/vfp/vfp_helper.h b/src/core/arm/skyeye_common/vfp/vfp_helper.h
index af03cb6e7..581f0358f 100644
--- a/src/core/arm/skyeye_common/vfp/vfp_helper.h
+++ b/src/core/arm/skyeye_common/vfp/vfp_helper.h
@@ -239,15 +239,6 @@ struct vfp_single {
239 u32 significand; 239 u32 significand;
240}; 240};
241 241
242#ifdef __cplusplus
243 extern "C" {
244#endif
245extern s32 vfp_get_float(ARMul_State * state, unsigned int reg);
246extern void vfp_put_float(ARMul_State * state, s32 val, unsigned int reg);
247#ifdef __cplusplus
248 }
249#endif
250
251/* 242/*
252 * VFP_SINGLE_MANTISSA_BITS - number of bits in the mantissa 243 * VFP_SINGLE_MANTISSA_BITS - number of bits in the mantissa
253 * VFP_SINGLE_EXPONENT_BITS - number of bits in the exponent 244 * VFP_SINGLE_EXPONENT_BITS - number of bits in the exponent
@@ -356,14 +347,7 @@ struct vfp_double {
356#else 347#else
357#define VFP_REG_ZERO 16 348#define VFP_REG_ZERO 16
358#endif 349#endif
359#ifdef __cplusplus 350
360 extern "C" {
361#endif
362extern u64 vfp_get_double(ARMul_State * state, unsigned int reg);
363extern void vfp_put_double(ARMul_State * state, u64 val, unsigned int reg);
364#ifdef __cplusplus
365 }
366#endif
367#define VFP_DOUBLE_MANTISSA_BITS (52) 351#define VFP_DOUBLE_MANTISSA_BITS (52)
368#define VFP_DOUBLE_EXPONENT_BITS (11) 352#define VFP_DOUBLE_EXPONENT_BITS (11)
369#define VFP_DOUBLE_LOW_BITS (64 - VFP_DOUBLE_MANTISSA_BITS - 2) 353#define VFP_DOUBLE_LOW_BITS (64 - VFP_DOUBLE_MANTISSA_BITS - 2)