1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
811
812 enum Predict { pt = 1, pn = 0 }; // pt = predict taken
813
814 enum Membar_mask_bits { // page 184, v9
815 StoreStore = 1 << 3,
816 LoadStore = 1 << 2,
817 StoreLoad = 1 << 1,
818 LoadLoad = 1 << 0,
819
820 Sync = 1 << 6,
821 MemIssue = 1 << 5,
822 Lookaside = 1 << 4
823 };
824
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 ); }
827
828 // test if -4096 <= x <= 4095
829 static bool is_simm13(int x) { return is_simm(x, 13); }
830
831 // test if label is in simm16 range in words (wdisp16).
832 bool is_in_wdisp16_range(Label& L) {
833 intptr_t d = intptr_t(pc()) - intptr_t(target(L));
834 return is_simm(d, 18);
835 }
836
837 enum ASIs { // page 72, v9
838 ASI_PRIMARY = 0x80,
839 ASI_PRIMARY_LITTLE = 0x88
840 // add more from book as needed
841 };
842
843 protected:
844 // helpers
845
846 // x is supposed to fit in a field "nbits" wide
847 // and be sign-extended. Check the range.
848
849 static void assert_signed_range(intptr_t x, int nbits) {
850 assert( nbits == 32
851 || -(1 << nbits-1) <= x && x < ( 1 << nbits-1),
852 "value out of range");
853 }
854
|
1 /*
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.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
811
812 enum Predict { pt = 1, pn = 0 }; // pt = predict taken
813
814 enum Membar_mask_bits { // page 184, v9
815 StoreStore = 1 << 3,
816 LoadStore = 1 << 2,
817 StoreLoad = 1 << 1,
818 LoadLoad = 1 << 0,
819
820 Sync = 1 << 6,
821 MemIssue = 1 << 5,
822 Lookaside = 1 << 4
823 };
824
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 ); }
827
828 // test if -4096 <= x <= 4095
829 static bool is_simm13(int x) { return is_simm(x, 13); }
830
831 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 }
835
836 // test if label is in simm16 range in words (wdisp16).
837 bool is_in_wdisp16_range(Label& L) {
838 return is_in_wdisp_range(target(L), pc(), 16);
839 }
840 // test if the distance between two addresses fits in simm30 range in words
841 bool is_in_wdisp30_range(address a, address b) {
842 return is_in_wdisp_range(a, b, 30);
843 }
844
845 enum ASIs { // page 72, v9
846 ASI_PRIMARY = 0x80,
847 ASI_PRIMARY_LITTLE = 0x88
848 // add more from book as needed
849 };
850
851 protected:
852 // helpers
853
854 // x is supposed to fit in a field "nbits" wide
855 // and be sign-extended. Check the range.
856
857 static void assert_signed_range(intptr_t x, int nbits) {
858 assert( nbits == 32
859 || -(1 << nbits-1) <= x && x < ( 1 << nbits-1),
860 "value out of range");
861 }
862
|