Wed, 18 Sep 2013 14:34:56 -0700
8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
Summary: Some platforms, as ppc and s390x/zArch require that 32-bit ints are passed as 64-bit values to C functions. This change adds support to adapt the signature and to issue proper casts to c2-compiled stubs. The functions are used in generate_native_wrapper(). Adapt signature used by the compiler as in PhaseIdealLoop::intrinsify_fill().
Reviewed-by: kvn
duke@435 | 1 | /* |
kvn@3882 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_OPTO_MULNODE_HPP |
stefank@2314 | 26 | #define SHARE_VM_OPTO_MULNODE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "opto/node.hpp" |
stefank@2314 | 29 | #include "opto/opcodes.hpp" |
stefank@2314 | 30 | #include "opto/type.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | // Portions of code courtesy of Clifford Click |
duke@435 | 33 | |
duke@435 | 34 | class PhaseTransform; |
duke@435 | 35 | |
duke@435 | 36 | //------------------------------MulNode---------------------------------------- |
duke@435 | 37 | // Classic MULTIPLY functionality. This covers all the usual 'multiply' |
duke@435 | 38 | // behaviors for an algebraic ring. Multiply-integer, multiply-float, |
duke@435 | 39 | // multiply-double, and binary-and are all inherited from this class. The |
duke@435 | 40 | // various identity values are supplied by virtual functions. |
duke@435 | 41 | class MulNode : public Node { |
duke@435 | 42 | virtual uint hash() const; |
duke@435 | 43 | public: |
kvn@3882 | 44 | MulNode( Node *in1, Node *in2 ): Node(0,in1,in2) { |
kvn@3882 | 45 | init_class_id(Class_Mul); |
kvn@3882 | 46 | } |
duke@435 | 47 | |
duke@435 | 48 | // Handle algebraic identities here. If we have an identity, return the Node |
duke@435 | 49 | // we are equivalent to. We look for "add of zero" as an identity. |
duke@435 | 50 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 51 | |
duke@435 | 52 | // We also canonicalize the Node, moving constants to the right input, |
duke@435 | 53 | // and flatten expressions (so that 1+x+2 becomes x+3). |
duke@435 | 54 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 55 | |
duke@435 | 56 | // Compute a new Type for this node. Basically we just do the pre-check, |
duke@435 | 57 | // then call the virtual add() to set the type. |
duke@435 | 58 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 59 | |
duke@435 | 60 | // Supplied function returns the product of the inputs. |
duke@435 | 61 | // This also type-checks the inputs for sanity. Guaranteed never to |
duke@435 | 62 | // be passed a TOP or BOTTOM type, these are filtered out by a pre-check. |
duke@435 | 63 | // This call recognizes the multiplicative zero type. |
duke@435 | 64 | virtual const Type *mul_ring( const Type *, const Type * ) const = 0; |
duke@435 | 65 | |
duke@435 | 66 | // Supplied function to return the multiplicative identity type |
duke@435 | 67 | virtual const Type *mul_id() const = 0; |
duke@435 | 68 | |
duke@435 | 69 | // Supplied function to return the additive identity type |
duke@435 | 70 | virtual const Type *add_id() const = 0; |
duke@435 | 71 | |
duke@435 | 72 | // Supplied function to return the additive opcode |
duke@435 | 73 | virtual int add_opcode() const = 0; |
duke@435 | 74 | |
duke@435 | 75 | // Supplied function to return the multiplicative opcode |
duke@435 | 76 | virtual int mul_opcode() const = 0; |
duke@435 | 77 | |
duke@435 | 78 | }; |
duke@435 | 79 | |
duke@435 | 80 | //------------------------------MulINode--------------------------------------- |
duke@435 | 81 | // Multiply 2 integers |
duke@435 | 82 | class MulINode : public MulNode { |
duke@435 | 83 | public: |
duke@435 | 84 | MulINode( Node *in1, Node *in2 ) : MulNode(in1,in2) {} |
duke@435 | 85 | virtual int Opcode() const; |
duke@435 | 86 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 87 | virtual const Type *mul_ring( const Type *, const Type * ) const; |
duke@435 | 88 | const Type *mul_id() const { return TypeInt::ONE; } |
duke@435 | 89 | const Type *add_id() const { return TypeInt::ZERO; } |
duke@435 | 90 | int add_opcode() const { return Op_AddI; } |
duke@435 | 91 | int mul_opcode() const { return Op_MulI; } |
duke@435 | 92 | const Type *bottom_type() const { return TypeInt::INT; } |
duke@435 | 93 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 94 | }; |
duke@435 | 95 | |
duke@435 | 96 | //------------------------------MulLNode--------------------------------------- |
duke@435 | 97 | // Multiply 2 longs |
duke@435 | 98 | class MulLNode : public MulNode { |
duke@435 | 99 | public: |
duke@435 | 100 | MulLNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {} |
duke@435 | 101 | virtual int Opcode() const; |
duke@435 | 102 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 103 | virtual const Type *mul_ring( const Type *, const Type * ) const; |
duke@435 | 104 | const Type *mul_id() const { return TypeLong::ONE; } |
duke@435 | 105 | const Type *add_id() const { return TypeLong::ZERO; } |
duke@435 | 106 | int add_opcode() const { return Op_AddL; } |
duke@435 | 107 | int mul_opcode() const { return Op_MulL; } |
duke@435 | 108 | const Type *bottom_type() const { return TypeLong::LONG; } |
duke@435 | 109 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 110 | }; |
duke@435 | 111 | |
duke@435 | 112 | |
duke@435 | 113 | //------------------------------MulFNode--------------------------------------- |
duke@435 | 114 | // Multiply 2 floats |
duke@435 | 115 | class MulFNode : public MulNode { |
duke@435 | 116 | public: |
duke@435 | 117 | MulFNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {} |
duke@435 | 118 | virtual int Opcode() const; |
duke@435 | 119 | virtual const Type *mul_ring( const Type *, const Type * ) const; |
duke@435 | 120 | const Type *mul_id() const { return TypeF::ONE; } |
duke@435 | 121 | const Type *add_id() const { return TypeF::ZERO; } |
duke@435 | 122 | int add_opcode() const { return Op_AddF; } |
duke@435 | 123 | int mul_opcode() const { return Op_MulF; } |
duke@435 | 124 | const Type *bottom_type() const { return Type::FLOAT; } |
duke@435 | 125 | virtual uint ideal_reg() const { return Op_RegF; } |
duke@435 | 126 | }; |
duke@435 | 127 | |
duke@435 | 128 | //------------------------------MulDNode--------------------------------------- |
duke@435 | 129 | // Multiply 2 doubles |
duke@435 | 130 | class MulDNode : public MulNode { |
duke@435 | 131 | public: |
duke@435 | 132 | MulDNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {} |
duke@435 | 133 | virtual int Opcode() const; |
duke@435 | 134 | virtual const Type *mul_ring( const Type *, const Type * ) const; |
duke@435 | 135 | const Type *mul_id() const { return TypeD::ONE; } |
duke@435 | 136 | const Type *add_id() const { return TypeD::ZERO; } |
duke@435 | 137 | int add_opcode() const { return Op_AddD; } |
duke@435 | 138 | int mul_opcode() const { return Op_MulD; } |
duke@435 | 139 | const Type *bottom_type() const { return Type::DOUBLE; } |
duke@435 | 140 | virtual uint ideal_reg() const { return Op_RegD; } |
duke@435 | 141 | }; |
duke@435 | 142 | |
rasbold@580 | 143 | //-------------------------------MulHiLNode------------------------------------ |
rasbold@580 | 144 | // Upper 64 bits of a 64 bit by 64 bit multiply |
rasbold@580 | 145 | class MulHiLNode : public Node { |
rasbold@580 | 146 | public: |
rasbold@580 | 147 | MulHiLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
rasbold@580 | 148 | virtual int Opcode() const; |
rasbold@580 | 149 | virtual const Type *Value( PhaseTransform *phase ) const; |
rasbold@580 | 150 | const Type *bottom_type() const { return TypeLong::LONG; } |
rasbold@580 | 151 | virtual uint ideal_reg() const { return Op_RegL; } |
rasbold@580 | 152 | }; |
duke@435 | 153 | |
duke@435 | 154 | //------------------------------AndINode--------------------------------------- |
duke@435 | 155 | // Logically AND 2 integers. Included with the MUL nodes because it inherits |
duke@435 | 156 | // all the behavior of multiplication on a ring. |
duke@435 | 157 | class AndINode : public MulINode { |
duke@435 | 158 | public: |
duke@435 | 159 | AndINode( Node *in1, Node *in2 ) : MulINode(in1,in2) {} |
duke@435 | 160 | virtual int Opcode() const; |
duke@435 | 161 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 162 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 163 | virtual const Type *mul_ring( const Type *, const Type * ) const; |
duke@435 | 164 | const Type *mul_id() const { return TypeInt::MINUS_1; } |
duke@435 | 165 | const Type *add_id() const { return TypeInt::ZERO; } |
duke@435 | 166 | int add_opcode() const { return Op_OrI; } |
duke@435 | 167 | int mul_opcode() const { return Op_AndI; } |
duke@435 | 168 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 169 | }; |
duke@435 | 170 | |
duke@435 | 171 | //------------------------------AndINode--------------------------------------- |
duke@435 | 172 | // Logically AND 2 longs. Included with the MUL nodes because it inherits |
duke@435 | 173 | // all the behavior of multiplication on a ring. |
duke@435 | 174 | class AndLNode : public MulLNode { |
duke@435 | 175 | public: |
duke@435 | 176 | AndLNode( Node *in1, Node *in2 ) : MulLNode(in1,in2) {} |
duke@435 | 177 | virtual int Opcode() const; |
duke@435 | 178 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 179 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 180 | virtual const Type *mul_ring( const Type *, const Type * ) const; |
duke@435 | 181 | const Type *mul_id() const { return TypeLong::MINUS_1; } |
duke@435 | 182 | const Type *add_id() const { return TypeLong::ZERO; } |
duke@435 | 183 | int add_opcode() const { return Op_OrL; } |
duke@435 | 184 | int mul_opcode() const { return Op_AndL; } |
duke@435 | 185 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 186 | }; |
duke@435 | 187 | |
duke@435 | 188 | //------------------------------LShiftINode------------------------------------ |
duke@435 | 189 | // Logical shift left |
duke@435 | 190 | class LShiftINode : public Node { |
duke@435 | 191 | public: |
duke@435 | 192 | LShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
duke@435 | 193 | virtual int Opcode() const; |
duke@435 | 194 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 195 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 196 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 197 | const Type *bottom_type() const { return TypeInt::INT; } |
duke@435 | 198 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 199 | }; |
duke@435 | 200 | |
duke@435 | 201 | //------------------------------LShiftLNode------------------------------------ |
duke@435 | 202 | // Logical shift left |
duke@435 | 203 | class LShiftLNode : public Node { |
duke@435 | 204 | public: |
duke@435 | 205 | LShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
duke@435 | 206 | virtual int Opcode() const; |
duke@435 | 207 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 208 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 209 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 210 | const Type *bottom_type() const { return TypeLong::LONG; } |
duke@435 | 211 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 212 | }; |
duke@435 | 213 | |
duke@435 | 214 | //------------------------------RShiftINode------------------------------------ |
duke@435 | 215 | // Signed shift right |
duke@435 | 216 | class RShiftINode : public Node { |
duke@435 | 217 | public: |
duke@435 | 218 | RShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
duke@435 | 219 | virtual int Opcode() const; |
duke@435 | 220 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 221 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 222 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 223 | const Type *bottom_type() const { return TypeInt::INT; } |
duke@435 | 224 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 225 | }; |
duke@435 | 226 | |
duke@435 | 227 | //------------------------------RShiftLNode------------------------------------ |
duke@435 | 228 | // Signed shift right |
duke@435 | 229 | class RShiftLNode : public Node { |
duke@435 | 230 | public: |
duke@435 | 231 | RShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
duke@435 | 232 | virtual int Opcode() const; |
duke@435 | 233 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 234 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 235 | const Type *bottom_type() const { return TypeLong::LONG; } |
duke@435 | 236 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 237 | }; |
duke@435 | 238 | |
duke@435 | 239 | |
duke@435 | 240 | //------------------------------URShiftINode----------------------------------- |
duke@435 | 241 | // Logical shift right |
duke@435 | 242 | class URShiftINode : public Node { |
duke@435 | 243 | public: |
duke@435 | 244 | URShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
duke@435 | 245 | virtual int Opcode() const; |
duke@435 | 246 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 247 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 248 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 249 | const Type *bottom_type() const { return TypeInt::INT; } |
duke@435 | 250 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 251 | }; |
duke@435 | 252 | |
duke@435 | 253 | //------------------------------URShiftLNode----------------------------------- |
duke@435 | 254 | // Logical shift right |
duke@435 | 255 | class URShiftLNode : public Node { |
duke@435 | 256 | public: |
duke@435 | 257 | URShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {} |
duke@435 | 258 | virtual int Opcode() const; |
duke@435 | 259 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 260 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 261 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 262 | const Type *bottom_type() const { return TypeLong::LONG; } |
duke@435 | 263 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 264 | }; |
stefank@2314 | 265 | |
stefank@2314 | 266 | #endif // SHARE_VM_OPTO_MULNODE_HPP |