Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java @ 15011:c8e575742f36
allow compilation with custom RegisterConfig
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Mon, 07 Apr 2014 19:21:22 +0200 |
parents | f3a5036cc13c |
children | 76c90aa967b1 |
rev | line source |
---|---|
10956 | 1 /* |
2 * Copyright (c) 2013, 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 */ | |
23 package com.oracle.graal.lir.amd64; | |
24 | |
25 import com.oracle.graal.api.code.*; | |
26 import com.oracle.graal.api.meta.*; | |
27 import com.oracle.graal.lir.*; | |
28 | |
29 /** | |
30 * AMD64 specific frame map. | |
14906 | 31 * |
10956 | 32 * This is the format of an AMD64 stack frame: |
14906 | 33 * |
10956 | 34 * <pre> |
35 * Base Contents | |
14906 | 36 * |
10956 | 37 * : : ----- |
38 * caller | incoming overflow argument n | ^ | |
39 * frame : ... : | positive | |
40 * | incoming overflow argument 0 | | offsets | |
41 * ---------+--------------------------------+--------------------- | |
42 * | return address | | ^ | |
43 * current +--------------------------------+ | | ----- | |
44 * frame | | | | ^ | |
45 * : callee save area : | | | | |
46 * | | | | | | |
47 * +--------------------------------+ | | | | |
48 * | spill slot 0 | | negative | | | |
49 * : ... : v offsets | | | |
50 * | spill slot n | ----- total frame | |
51 * +--------------------------------+ frame size | |
52 * | alignment padding | size | | |
53 * +--------------------------------+ ----- | | | |
54 * | outgoing overflow argument n | ^ | | | |
55 * : ... : | positive | | | |
56 * | outgoing overflow argument 0 | | offsets v v | |
14906 | 57 * %sp--> +--------------------------------+--------------------------- |
58 * | |
10956 | 59 * </pre> |
14906 | 60 * |
10956 | 61 * The spill slot area also includes stack allocated memory blocks (ALLOCA blocks). The size of such |
62 * a block may be greater than the size of a normal spill slot or the word size. | |
63 * <p> | |
64 * A runtime can reserve space at the beginning of the overflow argument area. The calling | |
65 * convention can specify that the first overflow stack argument is not at offset 0, but at a | |
66 * specified offset. Use {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that | |
67 * call-free methods also have this space reserved. Then the VM can use the memory at offset 0 | |
68 * relative to the stack pointer. | |
69 */ | |
11594
3d358ea11300
allow backend to specify spill slot size
Mick Jordan <mick.jordan@oracle.com>
parents:
10958
diff
changeset
|
70 public class AMD64FrameMap extends FrameMap { |
10956 | 71 |
15011
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14906
diff
changeset
|
72 public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) { |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14906
diff
changeset
|
73 super(codeCache, registerConfig); |
10958
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
74 // (negative) offset relative to sp + total frame size |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
75 initialSpillSize = returnAddressSize() + calleeSaveAreaSize(); |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
76 spillSize = initialSpillSize; |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
77 } |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
78 |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
79 @Override |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
80 public int totalFrameSize() { |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
81 return frameSize() + returnAddressSize(); |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
82 } |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
83 |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
84 @Override |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
85 public int currentFrameSize() { |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
86 return alignFrameSize(outgoingSize + spillSize - returnAddressSize()); |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
87 } |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
88 |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
89 @Override |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
90 protected int alignFrameSize(int size) { |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
91 int x = size + returnAddressSize() + (target.stackAlignment - 1); |
e2c63a0b799c
moved move logic into architecture specific FrameMap
twisti
parents:
10956
diff
changeset
|
92 return (x / target.stackAlignment) * target.stackAlignment - returnAddressSize(); |
10956 | 93 } |
94 | |
95 @Override | |
96 public int offsetToCalleeSaveArea() { | |
97 return frameSize() - calleeSaveAreaSize(); | |
98 } | |
99 | |
100 @Override | |
101 protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { | |
102 return StackSlot.get(kind, -spillSize + additionalOffset, true); | |
103 } | |
104 } |