// arm64: 48 bits
CLANG_FORMAT_COMMENT_ANCHOR;
-#ifdef RELOC_SUPPORT
-
unsigned _idCnsReloc : 1; // LargeCns is an RVA and needs reloc tag
unsigned _idDspReloc : 1; // LargeDsp is an RVA and needs reloc tag
#define ID_EXTRA_RELOC_BITS (2)
-#else // RELOC_SUPPORT
-
-#define ID_EXTRA_RELOC_BITS (0)
-
-#endif // RELOC_SUPPORT
-
////////////////////////////////////////////////////////////////////////
- // Space taken up to here (assuming RELOC_SUPPORT):
+ // Space taken up to here:
// x86: 40 bits
// amd64: 48 bits
// arm: 50 bits
#define ID_MAX_SMALL_CNS (int)((1 << ID_BIT_SMALL_CNS) - 1U)
////////////////////////////////////////////////////////////////////////
- // Small constant size (assuming RELOC_SUPPORT):
+ // Small constant size:
// x86: 24 bits
// amd64: 16 bits
// arm: 14 bits
unsigned _idSmallCns : ID_BIT_SMALL_CNS;
////////////////////////////////////////////////////////////////////////
- // Space taken up to here (with RELOC_SUPPORT): 64 bits, all architectures, by design.
+ // Space taken up to here: 64 bits, all architectures, by design.
////////////////////////////////////////////////////////////////////////
CLANG_FORMAT_COMMENT_ANCHOR;
#define ID_EXTRA_BITFIELD_BITS (7)
-//
-// For x86, we are using 7 bits from the second DWORD for bitfields.
-//
-
-#ifdef RELOC_SUPPORT
+ //
+ // For x86, we are using 7 bits from the second DWORD for bitfields.
+ //
unsigned _idCnsReloc : 1; // LargeCns is an RVA and needs reloc tag
unsigned _idDspReloc : 1; // LargeDsp is an RVA and needs reloc tag
-#define ID_EXTRA_RELOC_BITS (2)
-
-#else // RELOC_SUPPORT
-
-#define ID_EXTRA_RELOC_BITS (0)
-
-#endif // RELOC_SUPPORT
-
#define ID_EXTRA_REG_BITS (0)
#define ID_EXTRA_BITS (ID_EXTRA_BITFIELD_BITS + ID_EXTRA_RELOC_BITS + ID_EXTRA_REG_BITS)
#define ID_MIN_SMALL_CNS 0
#define ID_MAX_SMALL_CNS (int)((1 << ID_BIT_SMALL_CNS) - 1U)
- // For x86 (assuming RELOC_SUPPORT) we have 23 bits remaining for the
+ // For x86 we have 23 bits remaining for the
// small constant in this extra DWORD.
unsigned _idSmallCns : ID_BIT_SMALL_CNS;
}
#endif // defined(_TARGET_ARM_)
-#ifdef RELOC_SUPPORT
-
bool idIsCnsReloc() const
{
assert(!idIsTiny());
return idIsDspReloc() || idIsCnsReloc();
}
-#endif
-
unsigned idSmallCns() const
{
assert(!idIsTiny());
id->idInsFmt(fmt);
id->idInsSize(isz);
-#if RELOC_SUPPORT
if (emitComp->opts.compReloc)
{
// Set the relocation flags - these give hint to zap to perform
// relocation of the specified 32bit address.
id->idSetRelocFlags(attr);
}
-#endif // RELOC_SUPPORT
dispIns(id);
appendToCurIG(id);
id->idSetIsCallAddr();
}
-#if RELOC_SUPPORT
if (emitComp->opts.compReloc)
{
// Since this is an indirect call through a pointer and we don't
id->idSetIsDspReloc();
}
-#endif
}
#ifdef DEBUG
else if (fmt == IF_T2_J2)
{
assert((distVal & 1) == 0);
-#ifdef RELOC_SUPPORT
if (emitComp->opts.compReloc && emitJumpCrossHotColdBoundary(srcOffs, dstOffs))
{
// dst isn't an actual final target location, just some intermediate
// rely on the relocation to do all the work
}
else
-#endif
{
assert(distVal >= CALL_DIST_MAX_NEG);
assert(distVal <= CALL_DIST_MAX_POS);
unsigned instrSize = emitOutput_Thumb2Instr(dst, code);
-#ifdef RELOC_SUPPORT
if (emitComp->opts.compReloc)
{
if (emitJumpCrossHotColdBoundary(srcOffs, dstOffs))
}
}
}
-#endif // RELOC_SUPPORT
dst += instrSize;
}
assert(!id->idIsLclVar());
assert((ins == INS_movw) || (ins == INS_movt));
imm += (size_t)emitConsBlock;
-#ifdef RELOC_SUPPORT
if (!id->idIsCnsReloc() && !id->idIsDspReloc())
-#endif
{
goto SPLIT_IMM;
}
}
}
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc() || id->idIsDspReloc())
{
assert((ins == INS_movt) || (ins == INS_movw));
emitRecordRelocation((void*)(dst - 8), (void*)imm, IMAGE_REL_BASED_THUMB_MOV32);
}
else
-#endif // RELOC_SUPPORT
{
assert((imm & 0x0000ffff) == imm);
code |= (imm & 0x00ff);
}
code = emitInsCode(ins, fmt);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
callInstrSize = SafeCvtAssert<unsigned char>(emitOutput_Thumb2Instr(dst, code));
emitRecordRelocation((void*)(dst - 4), addr, IMAGE_REL_BASED_THUMB_BRANCH24);
}
else
-#endif // RELOC_SUPPORT
{
addr = (BYTE*)((size_t)addr & ~1); // Clear the lowest bit from target address
{
if (emitComp->opts.disDiffable)
imm = 0xD1FF;
-#if RELOC_SUPPORT
if (id->idIsCnsReloc() || id->idIsDspReloc())
{
if (emitComp->opts.disDiffable)
imm = 0xD1FFAB1E;
printf("%s RELOC ", (id->idIns() == INS_movw) ? "LOW" : "HIGH");
}
-#endif // RELOC_SUPPORT
}
emitDispImm(imm, false, (fmt == IF_T2_N));
break;
assert(jdsc != NULL);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
printf("reloc ");
}
-#endif
printf("%s ADDRESS J_M%03u_DS%02u", (id->idIns() == INS_movw) ? "LOW" : "HIGH",
Compiler::s_compMethodsCount, imm);
valSize = sizeof(int);
}
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
valInByte = false; // relocs can't be placed in a byte
assert(valSize == sizeof(int));
}
-#endif
if (valInByte)
{
break;
}
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
dspInByte = false; // relocs can't be placed in a byte
dspIsZero = false; // relocs won't always be zero
}
-#endif
if (code & 0xFF000000)
{
valSize = sizeof(INT32);
}
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
valInByte = false; // relocs can't be placed in a byte
assert(valSize == sizeof(INT32));
}
-#endif
if (valInByte)
{
valSize = sizeof(INT32);
#endif // !_TARGET_AMD64_
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
valInByte = false; // relocs can't be placed in a byte
assert(valSize == sizeof(INT32));
}
-#endif
if (valInByte)
{
void emitter::emitIns_C(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fldHnd, int offs)
{
-#if RELOC_SUPPORT
// Static always need relocs
if (!jitStaticFldIsGlobAddr(fldHnd))
{
attr = EA_SET_FLG(attr, EA_DSP_RELOC_FLG);
}
-#endif
UNATIVE_OFFSET sz;
instrDesc* id;
*/
void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO_FIELD_HANDLE fldHnd, int offs)
{
-#if RELOC_SUPPORT
// Static always need relocs
if (!jitStaticFldIsGlobAddr(fldHnd))
{
attr = EA_SET_FLG(attr, EA_DSP_RELOC_FLG);
}
-#endif
emitAttr size = EA_SIZE(attr);
void emitter::emitIns_C_R(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fldHnd, regNumber reg, int offs)
{
-#if RELOC_SUPPORT
// Static always need relocs
if (!jitStaticFldIsGlobAddr(fldHnd))
{
attr = EA_SET_FLG(attr, EA_DSP_RELOC_FLG);
}
-#endif
emitAttr size = EA_SIZE(attr);
void emitter::emitIns_C_I(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fldHnd, int offs, int val)
{
-#if RELOC_SUPPORT
// Static always need relocs
if (!jitStaticFldIsGlobAddr(fldHnd))
{
attr = EA_SET_FLG(attr, EA_DSP_RELOC_FLG);
}
-#endif
insFormat fmt;
emitTotalIGjmps++;
#endif
-#if RELOC_SUPPORT
#ifndef _TARGET_AMD64_
// Storing the address of a basicBlock will need a reloc
// as the instruction uses the absolute address,
{
id->idSetIsDspReloc();
}
-#endif // RELOC_SUPPORT
id->idCodeSize(sz);
}
else if (ins == INS_push || ins == INS_push_hide)
{
-#if RELOC_SUPPORT
// Pushing the address of a basicBlock will need a reloc
// as the instruction uses the absolute address,
// not a relative address
{
id->idSetIsDspReloc();
}
-#endif
sz = PUSH_INST_SIZE;
}
else
id->idAddr()->iiaAddr = (BYTE*)addr;
sz = 6;
-#if RELOC_SUPPORT
// Since this is an indirect call through a pointer and we don't
// currently pass in emitAttr into this function, we query codegen
// whether addr needs a reloc.
sz++;
}
#endif //_TARGET_AMD64_
-#endif // RELOC_SUPPORT
}
else
{
id->idSetIsCallAddr();
}
-#if RELOC_SUPPORT
// Direct call to a method and no addr indirection is needed.
if (codeGen->genCodeAddrNeedsReloc((size_t)addr))
{
id->idSetIsDspReloc();
}
-#endif
}
#ifdef DEBUG
doffs = Compiler::eeGetJitDataOffs(fldHnd);
-#ifdef RELOC_SUPPORT
if (reloc)
{
printf("reloc ");
}
-#endif
if (doffs >= 0)
{
if (jdsc)
{
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
printf("reloc ");
}
-#endif
printf("J_M%03u_DS%02u", Compiler::s_compMethodsCount, id->idDebugOnlyInfo()->idMemCookie);
}
nsep = true;
}
-#ifdef RELOC_SUPPORT
if ((id->idIsDspReloc()) && (id->idIns() != INS_i_jmp))
{
if (nsep)
emitDispReloc(disp);
}
else
-#endif
{
// Munge any pointers if we want diff-able disassembly
if (emitComp->opts.disDiffable)
printf("IN%04x: ", idNum);
}
-#ifdef RELOC_SUPPORT
#define ID_INFO_DSP_RELOC ((bool)(id->idIsDspReloc()))
-#else
-#define ID_INFO_DSP_RELOC false
-#endif
+
/* Display a constant value if the instruction references one */
if (!isNew)
// no 8-byte immediates allowed here!
assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL));
#endif
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
emitDispReloc(val);
}
else
-#endif
{
PRINT_CONSTANT:
// Munge any pointers if we want diff-able disassembly
else
{
printf(", ");
-#ifdef RELOC_SUPPORT
if (cnsVal.cnsReloc)
{
emitDispReloc(val);
}
else
-#endif
{
goto PRINT_CONSTANT;
}
else
{
printf(", ");
-#ifdef RELOC_SUPPORT
if (cnsVal.cnsReloc)
{
emitDispReloc(val);
}
else
-#endif
{
goto PRINT_CONSTANT;
}
assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL));
#endif
printf(", ");
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
emitDispReloc(val);
}
else
-#endif
{
goto PRINT_CONSTANT;
}
// no 8-byte immediates allowed here!
assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL));
#endif
-#ifdef RELOC_SUPPORT
if (cnsVal.cnsReloc)
{
emitDispReloc(val);
}
- else
-#endif
- if (id->idInsFmt() == IF_MRW_SHF)
+ else if (id->idInsFmt() == IF_MRW_SHF)
{
emitDispShift(ins, (BYTE)val);
}
case IF_RRW_CNS:
printf("%s, ", emitRegName(id->idReg1(), attr));
val = emitGetInsSC(id);
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
emitDispReloc(val);
}
else
-#endif
{
goto PRINT_CONSTANT;
}
ssize_t cval = addc->cnsVal;
// Does the constant fit in a byte?
- if ((signed char)cval == cval &&
-#ifdef RELOC_SUPPORT
- addc->cnsReloc == false &&
-#endif
- ins != INS_mov && ins != INS_test)
+ if ((signed char)cval == cval && addc->cnsReloc == false && ins != INS_mov && ins != INS_test)
{
if (id->idInsFmt() != IF_ARW_SHF)
{
dspInByte = ((signed char)dsp == (ssize_t)dsp);
dspIsZero = (dsp == 0);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
dspInByte = false; // relocs can't be placed in a byte
}
-#endif
// Is there a [scaled] index component?
if (rgx == REG_NA)
dst += emitOutputWord(dst, code | 0x8500);
dst += emitOutputLong(dst, dsp);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)dsp, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
break;
dst += emitOutputWord(dst, code | 0x8400);
dst += emitOutputByte(dst, 0x24);
dst += emitOutputLong(dst, dsp);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)dsp, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
break;
{
dst += emitOutputWord(dst, code | 0x8000);
dst += emitOutputLong(dst, dsp);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)dsp, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
}
dst += emitOutputWord(dst, code | 0x8400);
dst += emitOutputByte(dst, regByte);
dst += emitOutputLong(dst, dsp);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)dsp, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
}
}
}
dst += emitOutputLong(dst, dsp);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)dsp, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
}
else
dst += emitOutputWord(dst, code | 0x8400);
dst += emitOutputByte(dst, regByte);
dst += emitOutputLong(dst, dsp);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)dsp, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
}
}
assert(!"unexpected operand size");
}
-#ifdef RELOC_SUPPORT
if (addc->cnsReloc)
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)(size_t)cval, IMAGE_REL_BASED_HIGHLOW);
assert(opsz == 4);
}
-#endif
}
DONE:
ssize_t cval = addc->cnsVal;
// Does the constant fit in a byte?
- if ((signed char)cval == cval &&
-#ifdef RELOC_SUPPORT
- addc->cnsReloc == false &&
-#endif
- ins != INS_mov && ins != INS_test)
+ if ((signed char)cval == cval && addc->cnsReloc == false && ins != INS_mov && ins != INS_test)
{
if (id->idInsFmt() != IF_SRW_SHF)
{
dspInByte = ((signed char)dsp == (int)dsp);
dspIsZero = (dsp == 0);
-#ifdef RELOC_SUPPORT
// for stack varaibles the dsp should never be a reloc
assert(id->idIsDspReloc() == 0);
-#endif
if (EBPbased)
{
assert(!"unexpected operand size");
}
-#ifdef RELOC_SUPPORT
if (addc->cnsReloc)
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)(size_t)cval, IMAGE_REL_BASED_HIGHLOW);
assert(opsz == 4);
}
-#endif
}
// Does this instruction operate on a GC ref value?
{
ssize_t cval = addc->cnsVal;
// Does the constant fit in a byte?
- if ((signed char)cval == cval &&
-#ifdef RELOC_SUPPORT
- addc->cnsReloc == false &&
-#endif
- ins != INS_mov && ins != INS_test)
+ if ((signed char)cval == cval && addc->cnsReloc == false && ins != INS_mov && ins != INS_test)
{
if (id->idInsFmt() != IF_MRW_SHF)
{
dst += emitOutputLong(dst, (int)target);
#endif //_TARGET_X86_
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(int)), target, IMAGE_REL_BASED_DISP32, 0, addlDelta);
}
-#endif
}
else
{
dst += emitOutputSizeT(dst, (ssize_t)target);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(void*)), target, IMAGE_REL_BASED_MOFFSET);
}
-#endif
#endif //_TARGET_X86_
}
default:
assert(!"unexpected operand size");
}
-#ifdef RELOC_SUPPORT
if (addc->cnsReloc)
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)(size_t)cval, IMAGE_REL_BASED_HIGHLOW);
assert(opsz == 4);
}
-#endif
}
// Does this instruction operate on a GC ref value?
ssize_t val = emitGetInsSC(id);
bool valInByte = ((signed char)val == val) && (ins != INS_mov) && (ins != INS_test);
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
valInByte = false; // relocs can't be placed in a byte
}
-#endif
noway_assert(emitVerifyEncodable(ins, size, reg));
}
#endif
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
emitRecordRelocation((void*)(dst - (unsigned)EA_SIZE(size)), (void*)(size_t)val, IMAGE_REL_BASED_MOFFSET);
}
-#endif
goto DONE;
}
break;
}
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)(size_t)val, IMAGE_REL_BASED_HIGHLOW);
assert(size == EA_4BYTE);
}
-#endif
}
DONE:
noway_assert(size < EA_8BYTE || ((int)val == val && !id->idIsCnsReloc()));
#endif
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
valInByte = false; // relocs can't be placed in a byte
// Of these instructions only the push instruction can have reloc
assert(ins == INS_push || ins == INS_push_hide);
}
-#endif
switch (ins)
{
dst += emitOutputByte(dst, code);
dst += emitOutputLong(dst, val);
-#ifdef RELOC_SUPPORT
if (id->idIsCnsReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), (void*)(size_t)val, IMAGE_REL_BASED_HIGHLOW);
}
-#endif
}
// Did we push a GC ref value?
dst += emitOutputLong(dst, offset);
-#ifdef RELOC_SUPPORT
if (id->idIsDspReloc())
{
emitRecordRelocation((void*)(dst - sizeof(INT32)), addr, IMAGE_REL_BASED_REL32);
}
-#endif
DONE_CALL: