/[pcsx2_0.9.7]/trunk/common/include/x86emitter/implement/jmpcall.h
ViewVC logotype

Contents of /trunk/common/include/x86emitter/implement/jmpcall.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (10 years, 1 month ago) by william
File MIME type: text/plain
File size: 2457 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 // Implementations found here: CALL and JMP! (unconditional only)
19
20 namespace x86Emitter {
21
22 #ifdef __GNUG__
23 // GCC has a bug that causes the templated function handler for Jmp/Call emitters to generate
24 // bad asm code. (error is something like "7#*_uber_379s_mangled_$&02_name is already defined!")
25 // Using GCC's always_inline attribute fixes it. This differs from __fi in that it
26 // inlines *even in debug builds* which is (usually) undesirable.
27 // ... except when it avoids compiler bugs.
28 # define __always_inline_tmpl_fail __attribute__((always_inline))
29 #else
30 # define __always_inline_tmpl_fail
31 #endif
32
33 extern void xJccKnownTarget( JccComparisonType comparison, const void* target, bool slideForward );
34
35 // ------------------------------------------------------------------------
36 struct xImpl_JmpCall
37 {
38 bool isJmp;
39
40 void operator()( const xRegister32& absreg ) const;
41 void operator()( const xIndirect32& src ) const;
42
43 void operator()( const xRegister16& absreg ) const;
44 void operator()( const xIndirect16& src ) const;
45
46 // Special form for calling functions. This form automatically resolves the
47 // correct displacement based on the size of the instruction being generated.
48 template< typename T > __fi __always_inline_tmpl_fail
49 void operator()( T* func ) const
50 {
51 if( isJmp )
52 xJccKnownTarget( Jcc_Unconditional, (void*)(uptr)func, false ); // double cast to/from (uptr) needed to appease GCC
53 else
54 {
55 // calls are relative to the instruction after this one, and length is
56 // always 5 bytes (16 bit calls are bad mojo, so no bother to do special logic).
57
58 sptr dest = (sptr)func - ((sptr)xGetPtr() + 5);
59 xWrite8( 0xe8 );
60 xWrite32( dest );
61 }
62 }
63 };
64
65 } // End namespace x86Emitter
66

  ViewVC Help
Powered by ViewVC 1.1.22