1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright (c) 2015, 2018, Loongson Technology. All rights reserved. |
3 * Copyright (c) 2015, 2019, Loongson Technology. All rights reserved. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * |
5 * |
6 * This code is free software; you can redistribute it and/or modify it |
6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as |
7 * under the terms of the GNU General Public License version 2 only, as |
8 * published by the Free Software Foundation. |
8 * published by the Free Software Foundation. |
99 : "memory" |
99 : "memory" |
100 ); |
100 ); |
101 |
101 |
102 return res; |
102 return res; |
103 } |
103 } |
|
104 |
104 //use mips unaligned load instructions |
105 //use mips unaligned load instructions |
105 static inline void put_native_u2(address p, u2 x) { |
106 static inline void put_native_u2(address p, u2 x) { |
106 if((intptr_t)p & 0x1) { |
107 if((intptr_t)p & 0x1) { |
107 p[0] = (u_char)(x); |
108 p[0] = (u_char)(x); |
108 p[1] = (u_char)(x>>8); |
109 p[1] = (u_char)(x>>8); |
109 } else { |
110 } else { |
110 *(u2*)p = x; |
111 *(u2*)p = x; |
111 } |
112 } |
112 } |
113 } |
|
114 |
113 static inline void put_native_u4(address p, u4 x) { |
115 static inline void put_native_u4(address p, u4 x) { |
114 // refer to sparc implementation. |
116 // refer to sparc implementation. |
115 // Note that sparc is big-endian, while mips is little-endian |
117 // Note that sparc is big-endian, while mips is little-endian |
116 switch ( intptr_t(p) & 3 ) { |
118 switch ( intptr_t(p) & 3 ) { |
117 case 0: *(u4*)p = x; |
119 case 0: *(u4*)p = x; |
118 break; |
120 break; |
119 |
121 |
120 case 2: ((u2*)p)[1] = x >> 16; |
122 case 2: ((u2*)p)[1] = x >> 16; |
121 ((u2*)p)[0] = x; |
123 ((u2*)p)[0] = x; |
122 break; |
124 break; |
123 |
125 |
124 default: ((u1*)p)[3] = x >> 24; |
126 default: ((u1*)p)[3] = x >> 24; |
125 ((u1*)p)[2] = x >> 16; |
127 ((u1*)p)[2] = x >> 16; |
126 ((u1*)p)[1] = x >> 8; |
128 ((u1*)p)[1] = x >> 8; |
127 ((u1*)p)[0] = x; |
129 ((u1*)p)[0] = x; |
128 break; |
130 break; |
129 } |
131 } |
130 } |
132 } |
131 static inline void put_native_u8(address p, u8 x) { |
133 static inline void put_native_u8(address p, u8 x) { |
132 // refer to sparc implementation. |
134 // refer to sparc implementation. |
133 // Note that sparc is big-endian, while mips is little-endian |
135 // Note that sparc is big-endian, while mips is little-endian |
134 switch ( intptr_t(p) & 7 ) { |
136 switch ( intptr_t(p) & 7 ) { |