Mercurial > hg > truffle
annotate graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java @ 18408:2c3666f44855
Truffle: initial commit of object API implementation
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 18 Nov 2014 23:19:43 +0100 |
parents | c6086a18c9ce |
children | b856446ff7e0 |
rev | line source |
---|---|
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
1 /* |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
4 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
8 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
14 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
18 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
22 */ |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.lir.sparc; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
24 |
16518
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
25 import static com.oracle.graal.api.code.ValueUtil.*; |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
27 |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
28 import com.oracle.graal.api.code.*; |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.asm.sparc.*; |
16519
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
31 import com.oracle.graal.asm.sparc.SPARCAssembler.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
13227
diff
changeset
|
32 import com.oracle.graal.compiler.common.*; |
9856
fbeda9df497d
implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents:
9846
diff
changeset
|
33 import com.oracle.graal.lir.*; |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.lir.asm.*; |
16518
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
35 import com.oracle.graal.lir.gen.*; |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
36 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
37 @Opcode("BSWAP") |
17206
2d401b9ca70d
[SPARC] Improve the lookup for delayable candidates, renaming interfaces/methods
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17177
diff
changeset
|
38 public class SPARCByteSwapOp extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction { |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
39 |
16518
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
40 @Def({REG, HINT}) protected Value result; |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
41 @Use({REG}) protected Value input; |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
42 @Temp({REG}) protected Value tempIndex; |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
43 @Use({STACK}) protected StackSlot tmpSlot; |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
44 |
16518
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
45 public SPARCByteSwapOp(LIRGeneratorTool tool, Value result, Value input) { |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
46 this.result = result; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
47 this.input = input; |
18149
c6086a18c9ce
Rename LIRGenerationResult.getFrameMap() to getFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
17206
diff
changeset
|
48 this.tmpSlot = tool.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(Kind.Long)); |
16518
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
49 this.tempIndex = tool.newVariable(LIRKind.value(Kind.Long)); |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
50 } |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
51 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
52 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
11233
diff
changeset
|
53 public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { |
17206
2d401b9ca70d
[SPARC] Improve the lookup for delayable candidates, renaming interfaces/methods
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17177
diff
changeset
|
54 SPARCMove.move(crb, masm, tmpSlot, input, SPARCDelayedControlTransfer.DUMMY); |
16519
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
55 SPARCAddress addr = (SPARCAddress) crb.asAddress(tmpSlot); |
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
56 if (addr.getIndex().equals(Register.None)) { |
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
57 Register tempReg = ValueUtil.asLongReg(tempIndex); |
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
58 new SPARCMacroAssembler.Setx(addr.getDisplacement(), tempReg, false).emit(masm); |
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
59 addr = new SPARCAddress(addr.getBase(), tempReg); |
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
60 } |
17206
2d401b9ca70d
[SPARC] Improve the lookup for delayable candidates, renaming interfaces/methods
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17177
diff
changeset
|
61 delayedControlTransfer.emitControlTransfer(crb, masm); |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
62 switch (input.getKind()) { |
11233 | 63 case Int: |
16519
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
64 new SPARCAssembler.Lduwa(addr.getBase(), addr.getIndex(), asIntReg(result), Asi.ASI_PRIMARY_LITTLE).emit(masm); |
2b91702c4e69
[SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16518
diff
changeset
|
65 break; |
11233 | 66 case Long: |
16518
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
67 new SPARCAssembler.Ldxa(addr.getBase(), addr.getIndex(), asLongReg(result), Asi.ASI_PRIMARY_LITTLE).emit(masm); |
3eb13b910134
[SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15193
diff
changeset
|
68 break; |
11233 | 69 default: |
70 throw GraalInternalError.shouldNotReachHere(); | |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
71 } |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
72 } |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
73 } |