comparison src/cpu/sparc/vm/assembler_sparc.hpp @ 2121:c17b998c5926

7011627: C1: call_RT must support targets that don't fit in wdisp30 Summary: Make both compilers emit near and far calls when necessary. Reviewed-by: never, kvn, phh
author iveresov
date Wed, 12 Jan 2011 18:33:25 -0800
parents 7737fa7ec2b5
children 5ae3e3b03224
comparison
equal deleted inserted replaced
2119:d4fca0a6abde 2121:c17b998c5926
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
821 MemIssue = 1 << 5, 821 MemIssue = 1 << 5,
822 Lookaside = 1 << 4 822 Lookaside = 1 << 4
823 }; 823 };
824 824
825 // test if x is within signed immediate range for nbits 825 // test if x is within signed immediate range for nbits
826 static bool is_simm(int x, int nbits) { return -( 1 << nbits-1 ) <= x && x < ( 1 << nbits-1 ); } 826 static bool is_simm(intptr_t x, int nbits) { return -( intptr_t(1) << nbits-1 ) <= x && x < ( intptr_t(1) << nbits-1 ); }
827 827
828 // test if -4096 <= x <= 4095 828 // test if -4096 <= x <= 4095
829 static bool is_simm13(int x) { return is_simm(x, 13); } 829 static bool is_simm13(intptr_t x) { return is_simm(x, 13); }
830
831 static bool is_in_wdisp_range(address a, address b, int nbits) {
832 intptr_t d = intptr_t(b) - intptr_t(a);
833 return is_simm(d, nbits + 2);
834 }
830 835
831 // test if label is in simm16 range in words (wdisp16). 836 // test if label is in simm16 range in words (wdisp16).
832 bool is_in_wdisp16_range(Label& L) { 837 bool is_in_wdisp16_range(Label& L) {
833 intptr_t d = intptr_t(pc()) - intptr_t(target(L)); 838 return is_in_wdisp_range(target(L), pc(), 16);
834 return is_simm(d, 18); 839 }
840 // test if the distance between two addresses fits in simm30 range in words
841 static bool is_in_wdisp30_range(address a, address b) {
842 return is_in_wdisp_range(a, b, 30);
835 } 843 }
836 844
837 enum ASIs { // page 72, v9 845 enum ASIs { // page 72, v9
838 ASI_PRIMARY = 0x80, 846 ASI_PRIMARY = 0x80,
839 ASI_PRIMARY_LITTLE = 0x88 847 ASI_PRIMARY_LITTLE = 0x88
1841 inline void cmp( Register s1, int simm13a ) { subcc( s1, simm13a, G0 ); } 1849 inline void cmp( Register s1, int simm13a ) { subcc( s1, simm13a, G0 ); }
1842 1850
1843 inline void jmp( Register s1, Register s2 ); 1851 inline void jmp( Register s1, Register s2 );
1844 inline void jmp( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() ); 1852 inline void jmp( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() );
1845 1853
1854 // Check if the call target is out of wdisp30 range (relative to the code cache)
1855 static inline bool is_far_target(address d);
1846 inline void call( address d, relocInfo::relocType rt = relocInfo::runtime_call_type ); 1856 inline void call( address d, relocInfo::relocType rt = relocInfo::runtime_call_type );
1847 inline void call( Label& L, relocInfo::relocType rt = relocInfo::runtime_call_type ); 1857 inline void call( Label& L, relocInfo::relocType rt = relocInfo::runtime_call_type );
1848 inline void callr( Register s1, Register s2 ); 1858 inline void callr( Register s1, Register s2 );
1849 inline void callr( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() ); 1859 inline void callr( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() );
1850 1860