From: Mike Danes Date: Sat, 29 Apr 2017 10:12:21 +0000 (+0300) Subject: Add INS_bt X-Git-Tag: accepted/tizen/base/20180629.140029~670^2~38^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78f26895bf246e16df683c3d9bfdbd5273e749b2;p=platform%2Fupstream%2Fcoreclr.git Add INS_bt --- diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp index a24a778..889e07e 100644 --- a/src/jit/emitxarch.cpp +++ b/src/jit/emitxarch.cpp @@ -1903,6 +1903,9 @@ UNATIVE_OFFSET emitter::emitInsSizeAM(instrDesc* id, code_t code) } else if (code & 0x00FF0000) { + // BT supports 16 bit operands and this code doesn't handle the necessary 66 prefix. + assert(ins != INS_bt); + assert((attrSize == EA_4BYTE) || (attrSize == EA_PTRSIZE) // Only for x64 || (attrSize == EA_16BYTE) // only for x64 || (ins == INS_movzx) || (ins == INS_movsx)); @@ -2079,6 +2082,11 @@ inline UNATIVE_OFFSET emitter::emitInsSizeAM(instrDesc* id, code_t code, int val UNATIVE_OFFSET valSize = EA_SIZE_IN_BYTES(id->idOpSize()); bool valInByte = ((signed char)val == val) && (ins != INS_mov) && (ins != INS_test); + // We should never generate BT mem,reg because it has poor performance. BT mem,imm might be useful + // but it requires special handling of the immediate value (it is always encoded in a byte). + // Let's not complicate things until this is needed. + assert(ins != INS_bt); + #ifdef _TARGET_AMD64_ // mov reg, imm64 is the only opcode which takes a full 8 byte immediate // all other opcodes take a sign-extended 4-byte immediate @@ -3481,6 +3489,10 @@ void emitter::emitIns_R_I(instruction ins, emitAttr attr, regNumber reg, ssize_t insFormat fmt = emitInsModeFormat(ins, IF_RRD_CNS); bool valInByte = ((signed char)val == val) && (ins != INS_mov) && (ins != INS_test); + // BT reg,imm might be useful but it requires special handling of the immediate value + // (it is always encoded in a byte). Let's not complicate things until this is needed. + assert(ins != INS_bt); + // Figure out the size of the instruction switch (ins) { @@ -7064,6 +7076,11 @@ void emitter::emitDispIns( { printf("%s, %s", emitRegName(id->idReg1(), EA_PTRSIZE), emitRegName(id->idReg2(), attr)); } + else if (ins == INS_bt) + { + // INS_bt operands are reversed. Display them in the normal order. + printf("%s, %s", emitRegName(id->idReg2(), attr), emitRegName(id->idReg1(), attr)); + } else { printf("%s, %s", emitRegName(id->idReg1(), attr), emitRegName(id->idReg2(), attr)); @@ -7635,6 +7652,9 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } else if (code & 0x00FF0000) { + // BT supports 16 bit operands and this code doesn't handle the necessary 66 prefix. + assert(ins != INS_bt); + // Output the REX prefix dst += emitOutputRexOrVexPrefixIfNeeded(ins, dst, code); @@ -8186,6 +8206,9 @@ BYTE* emitter::emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } else if (code & 0x00FF0000) { + // BT supports 16 bit operands and this code doesn't add the necessary 66 prefix. + assert(ins != INS_bt); + // Output the REX prefix dst += emitOutputRexOrVexPrefixIfNeeded(ins, dst, code); @@ -9558,6 +9581,10 @@ BYTE* emitter::emitOutputRI(BYTE* dst, instrDesc* id) ssize_t val = emitGetInsSC(id); bool valInByte = ((signed char)val == val) && (ins != INS_mov) && (ins != INS_test); + // BT reg,imm might be useful but it requires special handling of the immediate value + // (it is always encoded in a byte). Let's not complicate things until this is needed. + assert(ins != INS_bt); + if (id->idIsCnsReloc()) { valInByte = false; // relocs can't be placed in a byte diff --git a/src/jit/instrsxarch.h b/src/jit/instrsxarch.h index 0952770..225539a 100644 --- a/src/jit/instrsxarch.h +++ b/src/jit/instrsxarch.h @@ -82,6 +82,10 @@ INST4(lea , "lea" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, 0x00008D, B // enum name FP updmode rf wf R/M,R/M[reg] R/M,icon reg,R/M +// Note that emitter has only partial support for BT. It can only emit the reg,reg form +// and the registers need to be reversed to get the correct encoding. +INST3(bt , "bt" , 0, IUM_RD, 0, 1, 0x0F00A3, BAD_CODE, 0x0F00A3) + INST3(movsx , "movsx" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, 0x0F00BE) #ifdef _TARGET_AMD64_ INST3(movsxd , "movsxd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, 0x4800000063LL )