1 /*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2017 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
1517 VOPRC_NOZS = 0b0000, // No Zero Search.
1518 VOPRC_RTBYTEIX = 0b0100, // generate byte index to lowest element with true comparison.
1519 VOPRC_RTBITVEC = 0b0000, // generate bit vector, all 1s for true, all 0s for false element comparisons.
1520 VOPRC_INVERT = 0b1000, // invert comparison results.
1521 VOPRC_NOINVERT = 0b0000 // use comparison results as is, do not invert.
1522 };
1523
1524 // Inverse condition code, i.e. determine "15 - cc" for a given condition code cc.
1525 static branch_condition inverse_condition(branch_condition cc);
1526 static branch_condition inverse_float_condition(branch_condition cc);
1527
1528
1529 //-----------------------------------------------
1530 // instruction property getter methods
1531 //-----------------------------------------------
1532
1533 // Calculate length of instruction.
1534 static int instr_len(unsigned char *instr);
1535
1536 // Longest instructions are 6 bytes on z/Architecture.
1537 static int instr_maxlen() { return 6; }
1538
1539 // Average instruction is 4 bytes on z/Architecture (just a guess).
1540 static int instr_avglen() { return 4; }
1541
1542 // Shortest instructions are 2 bytes on z/Architecture.
1543 static int instr_minlen() { return 2; }
1544
1545 // Move instruction at pc right-justified into passed long int.
1546 // Return instr len in bytes as function result.
1547 static unsigned int get_instruction(unsigned char *pc, unsigned long *instr);
1548
1549 // Move instruction in passed (long int) into storage at pc.
1550 // This code is _NOT_ MT-safe!!
1551 static void set_instruction(unsigned char *pc, unsigned long instr, unsigned int len) {
1552 memcpy(pc, ((unsigned char *)&instr)+sizeof(unsigned long)-len, len);
1553 }
1554
1555
1556 //------------------------------------------
1557 // instruction field test methods
1558 //------------------------------------------
1559
1560 // Only used once in s390.ad to implement Matcher::is_short_branch_offset().
1561 static bool is_within_range_of_RelAddr16(address target, address origin) {
1562 return RelAddr::is_in_range_of_RelAddr16(target, origin);
1563 }
|
1 /*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2019 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
1517 VOPRC_NOZS = 0b0000, // No Zero Search.
1518 VOPRC_RTBYTEIX = 0b0100, // generate byte index to lowest element with true comparison.
1519 VOPRC_RTBITVEC = 0b0000, // generate bit vector, all 1s for true, all 0s for false element comparisons.
1520 VOPRC_INVERT = 0b1000, // invert comparison results.
1521 VOPRC_NOINVERT = 0b0000 // use comparison results as is, do not invert.
1522 };
1523
1524 // Inverse condition code, i.e. determine "15 - cc" for a given condition code cc.
1525 static branch_condition inverse_condition(branch_condition cc);
1526 static branch_condition inverse_float_condition(branch_condition cc);
1527
1528
1529 //-----------------------------------------------
1530 // instruction property getter methods
1531 //-----------------------------------------------
1532
1533 // Calculate length of instruction.
1534 static int instr_len(unsigned char *instr);
1535
1536 // Longest instructions are 6 bytes on z/Architecture.
1537 static unsigned int instr_maxlen() { return 6; }
1538
1539 // Average instruction is 4 bytes on z/Architecture (just a guess).
1540 static unsigned int instr_avglen() { return 4; }
1541
1542 // Shortest instructions are 2 bytes on z/Architecture.
1543 static unsigned int instr_minlen() { return 2; }
1544
1545 // Move instruction at pc right-justified into passed long int.
1546 // Return instr len in bytes as function result.
1547 static unsigned int get_instruction(unsigned char *pc, unsigned long *instr);
1548
1549 // Move instruction in passed (long int) into storage at pc.
1550 // This code is _NOT_ MT-safe!!
1551 static void set_instruction(unsigned char *pc, unsigned long instr, unsigned int len) {
1552 memcpy(pc, ((unsigned char *)&instr)+sizeof(unsigned long)-len, len);
1553 }
1554
1555
1556 //------------------------------------------
1557 // instruction field test methods
1558 //------------------------------------------
1559
1560 // Only used once in s390.ad to implement Matcher::is_short_branch_offset().
1561 static bool is_within_range_of_RelAddr16(address target, address origin) {
1562 return RelAddr::is_in_range_of_RelAddr16(target, origin);
1563 }
|