Mercurial > hg > graal-compiler
comparison graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java @ 4142:bc8527f3071c
Adjust code base to new level of warnings.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 18 Dec 2011 05:24:06 +0100 |
parents | e233f5660da4 |
children | 9e0c1b4cfef5 |
comparison
equal
deleted
inserted
replaced
4141:04d21be7a24f | 4142:bc8527f3071c |
---|---|
686 prefix(dst); | 686 prefix(dst); |
687 emitByte(0xFF); | 687 emitByte(0xFF); |
688 emitOperandHelper(rax, dst); | 688 emitOperandHelper(rax, dst); |
689 } | 689 } |
690 | 690 |
691 public final void jcc(ConditionFlag cc, int target, boolean forceDisp32) { | 691 public final void jcc(ConditionFlag cc, int jumpTarget, boolean forceDisp32) { |
692 int shortSize = 2; | 692 int shortSize = 2; |
693 int longSize = 6; | 693 int longSize = 6; |
694 long disp = target - codeBuffer.position(); | 694 long disp = jumpTarget - codeBuffer.position(); |
695 if (!forceDisp32 && isByte(disp - shortSize)) { | 695 if (!forceDisp32 && isByte(disp - shortSize)) { |
696 // 0111 tttn #8-bit disp | 696 // 0111 tttn #8-bit disp |
697 emitByte(0x70 | cc.value); | 697 emitByte(0x70 | cc.value); |
698 emitByte((int) ((disp - shortSize) & 0xFF)); | 698 emitByte((int) ((disp - shortSize) & 0xFF)); |
699 } else { | 699 } else { |
743 prefix(adr); | 743 prefix(adr); |
744 emitByte(0xFF); | 744 emitByte(0xFF); |
745 emitOperandHelper(rsp, adr); | 745 emitOperandHelper(rsp, adr); |
746 } | 746 } |
747 | 747 |
748 public final void jmp(int target, boolean forceDisp32) { | 748 public final void jmp(int jumpTarget, boolean forceDisp32) { |
749 int shortSize = 2; | 749 int shortSize = 2; |
750 int longSize = 5; | 750 int longSize = 5; |
751 long disp = target - codeBuffer.position(); | 751 long disp = jumpTarget - codeBuffer.position(); |
752 if (!forceDisp32 && isByte(disp - shortSize)) { | 752 if (!forceDisp32 && isByte(disp - shortSize)) { |
753 emitByte(0xEB); | 753 emitByte(0xEB); |
754 emitByte((int) ((disp - shortSize) & 0xFF)); | 754 emitByte((int) ((disp - shortSize) & 0xFF)); |
755 } else { | 755 } else { |
756 emitByte(0xE9); | 756 emitByte(0xE9); |
1276 | 1276 |
1277 public final void nop() { | 1277 public final void nop() { |
1278 nop(1); | 1278 nop(1); |
1279 } | 1279 } |
1280 | 1280 |
1281 public void nop(int i) { | 1281 public void nop(int count) { |
1282 int i = count; | |
1282 if (AsmOptions.UseNormalNop) { | 1283 if (AsmOptions.UseNormalNop) { |
1283 assert i > 0 : " "; | 1284 assert i > 0 : " "; |
1284 // The fancy nops aren't currently recognized by debuggers making it a | 1285 // The fancy nops aren't currently recognized by debuggers making it a |
1285 // pain to disassemble code while debugging. If assert are on clearly | 1286 // pain to disassemble code while debugging. If assert are on clearly |
1286 // speed is not an issue so simply use the single byte traditional nop | 1287 // speed is not an issue so simply use the single byte traditional nop |
2121 } | 2122 } |
2122 | 2123 |
2123 int prefixAndEncode(int regEnc, boolean byteinst) { | 2124 int prefixAndEncode(int regEnc, boolean byteinst) { |
2124 if (regEnc >= 8) { | 2125 if (regEnc >= 8) { |
2125 emitByte(Prefix.REXB); | 2126 emitByte(Prefix.REXB); |
2126 regEnc -= 8; | 2127 return regEnc - 8; |
2127 } else if (byteinst && regEnc >= 4) { | 2128 } else if (byteinst && regEnc >= 4) { |
2128 emitByte(Prefix.REX); | 2129 emitByte(Prefix.REX); |
2129 } | 2130 } |
2130 return regEnc; | 2131 return regEnc; |
2131 } | 2132 } |
2132 | 2133 |
2133 int prefixqAndEncode(int regEnc) { | 2134 int prefixqAndEncode(int regEnc) { |
2134 if (regEnc < 8) { | 2135 if (regEnc < 8) { |
2135 emitByte(Prefix.REXW); | 2136 emitByte(Prefix.REXW); |
2137 return regEnc; | |
2136 } else { | 2138 } else { |
2137 emitByte(Prefix.REXWB); | 2139 emitByte(Prefix.REXWB); |
2138 regEnc -= 8; | 2140 return regEnc - 8; |
2139 } | 2141 } |
2140 return regEnc; | |
2141 } | 2142 } |
2142 | 2143 |
2143 int prefixAndEncode(int dstEnc, int srcEnc) { | 2144 int prefixAndEncode(int dstEnc, int srcEnc) { |
2144 return prefixAndEncode(dstEnc, srcEnc, false); | 2145 return prefixAndEncode(dstEnc, srcEnc, false); |
2145 } | 2146 } |
2146 | 2147 |
2147 int prefixAndEncode(int dstEnc, int srcEnc, boolean byteinst) { | 2148 int prefixAndEncode(int dstEncoding, int srcEncoding, boolean byteinst) { |
2149 int srcEnc = srcEncoding; | |
2150 int dstEnc = dstEncoding; | |
2148 if (dstEnc < 8) { | 2151 if (dstEnc < 8) { |
2149 if (srcEnc >= 8) { | 2152 if (srcEnc >= 8) { |
2150 emitByte(Prefix.REXB); | 2153 emitByte(Prefix.REXB); |
2151 srcEnc -= 8; | 2154 srcEnc -= 8; |
2152 } else if (byteinst && srcEnc >= 4) { | 2155 } else if (byteinst && srcEnc >= 4) { |
2170 * | 2173 * |
2171 * @param regEnc the encoding of the register part of the ModRM-Byte | 2174 * @param regEnc the encoding of the register part of the ModRM-Byte |
2172 * @param rmEnc the encoding of the r/m part of the ModRM-Byte | 2175 * @param rmEnc the encoding of the r/m part of the ModRM-Byte |
2173 * @return the lower 6 bits of the ModRM-Byte that should be emitted | 2176 * @return the lower 6 bits of the ModRM-Byte that should be emitted |
2174 */ | 2177 */ |
2175 private int prefixqAndEncode(int regEnc, int rmEnc) { | 2178 private int prefixqAndEncode(int regEncoding, int rmEncoding) { |
2179 int rmEnc = rmEncoding; | |
2180 int regEnc = regEncoding; | |
2176 if (regEnc < 8) { | 2181 if (regEnc < 8) { |
2177 if (rmEnc < 8) { | 2182 if (rmEnc < 8) { |
2178 emitByte(Prefix.REXW); | 2183 emitByte(Prefix.REXW); |
2179 } else { | 2184 } else { |
2180 emitByte(Prefix.REXWB); | 2185 emitByte(Prefix.REXWB); |
2927 | 2932 |
2928 public void enter(short imm16, byte imm8) { | 2933 public void enter(short imm16, byte imm8) { |
2929 emitByte(0xC8); | 2934 emitByte(0xC8); |
2930 // appended: | 2935 // appended: |
2931 emitByte(imm16 & 0xff); | 2936 emitByte(imm16 & 0xff); |
2932 imm16 >>= 8; | 2937 emitByte((imm16 >> 8) & 0xff); |
2933 emitByte(imm16 & 0xff); | |
2934 emitByte(imm8); | 2938 emitByte(imm8); |
2935 } | 2939 } |
2936 | 2940 |
2937 private void emitx87(int b1, int b2, int i) { | 2941 private void emitx87(int b1, int b2, int i) { |
2938 assert 0 <= i && i < 8 : "illegal stack offset"; | 2942 assert 0 <= i && i < 8 : "illegal stack offset"; |