diff --git a/compiler/codegen/OMRCodeGenerator.cpp b/compiler/codegen/OMRCodeGenerator.cpp index 841671fd71e..77ba80e8d38 100644 --- a/compiler/codegen/OMRCodeGenerator.cpp +++ b/compiler/codegen/OMRCodeGenerator.cpp @@ -1284,16 +1284,8 @@ void OMR::CodeGenerator::apply16BitLabelRelativeRelocation(int32_t * cursor, TR: { *(int16_t *)cursor += (int16_t)(intptr_t)label->getCodeLocation(); } void OMR::CodeGenerator::apply24BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *) { TR_ASSERT(0, "unexpected call to OMR::CodeGenerator::apply24BitLabelRelativeRelocation"); } -void OMR::CodeGenerator::apply16BitLoadLabelRelativeRelocation(TR::Instruction *, TR::LabelSymbol *, TR::LabelSymbol *, int32_t) - { TR_ASSERT(0, "unexpected call to OMR::CodeGenerator::apply16BitLoadLabelRelativeRelocation"); } -void OMR::CodeGenerator::apply32BitLoadLabelRelativeRelocation(TR::Instruction *, TR::LabelSymbol *, TR::LabelSymbol *, int32_t) - { TR_ASSERT(0, "unexpected call to OMR::CodeGenerator::apply32BitLoadLabelRelativeRelocation"); } -void OMR::CodeGenerator::apply64BitLoadLabelRelativeRelocation(TR::Instruction *, TR::LabelSymbol *) - { TR_ASSERT(0, "unexpected call to OMR::CodeGenerator::apply64BitLoadLabelRelativeRelocation"); } void OMR::CodeGenerator::apply32BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *) { TR_ASSERT(0, "unexpected call to OMR::CodeGenerator::apply32BitLabelRelativeRelocation"); } -void OMR::CodeGenerator::apply32BitLabelTableRelocation(int32_t * cursor, TR::LabelSymbol *) - { TR_ASSERT(0, "unexpected call to OMR::CodeGenerator::apply32BitLabelTableRelocation"); } void OMR::CodeGenerator::addSnippet(TR::Snippet *s) { diff --git a/compiler/codegen/OMRCodeGenerator.hpp b/compiler/codegen/OMRCodeGenerator.hpp index 92c0a0a4d3c..60b8d3cfd88 100644 --- a/compiler/codegen/OMRCodeGenerator.hpp +++ b/compiler/codegen/OMRCodeGenerator.hpp @@ -1146,11 +1146,7 @@ class OMR_EXTENSIBLE CodeGenerator void apply16BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol * label); void apply16BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol * label,int8_t d, bool isInstrOffset = false); void apply24BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); - void apply16BitLoadLabelRelativeRelocation(TR::Instruction *, TR::LabelSymbol *, TR::LabelSymbol *, int32_t); - void apply32BitLoadLabelRelativeRelocation(TR::Instruction *, TR::LabelSymbol *, TR::LabelSymbol *, int32_t); - void apply64BitLoadLabelRelativeRelocation(TR::Instruction *, TR::LabelSymbol *); void apply32BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); - void apply32BitLabelTableRelocation(int32_t * cursor, TR::LabelSymbol *); bool supportsMergingGuards(); diff --git a/compiler/codegen/Relocation.cpp b/compiler/codegen/Relocation.cpp index bfec9cdbafc..74b5c717c78 100644 --- a/compiler/codegen/Relocation.cpp +++ b/compiler/codegen/Relocation.cpp @@ -158,24 +158,6 @@ TR::InstructionLabelRelative32BitRelocation::apply(TR::CodeGenerator* cg) *reinterpret_cast(p) = static_cast(getLabel()->getCodeLocation() - p) / _divisor; } -void TR::LoadLabelRelative16BitRelocation::apply(TR::CodeGenerator *codeGen) - { - AOTcgDiag3(codeGen->comp(), "TR::LoadLabelRelative16BitRelocation::apply lastInstruction=" POINTER_PRINTF_FORMAT " startLabel=" POINTER_PRINTF_FORMAT " endLabel=" POINTER_PRINTF_FORMAT "\n", getLastInstruction(), getStartLabel(), getEndLabel()); - codeGen->apply16BitLoadLabelRelativeRelocation(getLastInstruction(), getStartLabel(), getEndLabel(), getDeltaToStartLabel()); - } - -void TR::LoadLabelRelative32BitRelocation::apply(TR::CodeGenerator *codeGen) - { - AOTcgDiag3(codeGen->comp(), "TR::LoadLabelRelative32BitRelocation::apply lastInstruction=" POINTER_PRINTF_FORMAT " startLabel=" POINTER_PRINTF_FORMAT " endLabel=" POINTER_PRINTF_FORMAT "\n", getLastInstruction(), getStartLabel(), getEndLabel()); - codeGen->apply32BitLoadLabelRelativeRelocation(getLastInstruction(), getStartLabel(), getEndLabel(), getDeltaToStartLabel()); - } - -void TR::LoadLabelRelative64BitRelocation::apply(TR::CodeGenerator *codeGen) - { - AOTcgDiag2(codeGen->comp(), "TR::LoadLabelRelative64BitRelocation::apply lastInstruction=" POINTER_PRINTF_FORMAT " label=" POINTER_PRINTF_FORMAT "\n", getLastInstruction(), getLabel()); - codeGen->apply64BitLoadLabelRelativeRelocation(getLastInstruction(), getLabel()); - } - uint8_t TR::ExternalRelocation::collectModifier() { TR::Compilation *comp = TR::comp(); @@ -577,8 +559,3 @@ void TR::IteratedExternalRelocation::addRelocationEntry(uint32_t locationOffset) _relocationDataCursor += 4; } } - -void TR::LabelTable32BitRelocation::apply(TR::CodeGenerator *codeGen) - { - codeGen->apply32BitLabelTableRelocation((int32_t *)getUpdateLocation(), getLabel()); - } diff --git a/compiler/codegen/Relocation.hpp b/compiler/codegen/Relocation.hpp index 1d58a85633f..15b0bbc3c62 100644 --- a/compiler/codegen/Relocation.hpp +++ b/compiler/codegen/Relocation.hpp @@ -39,15 +39,6 @@ namespace TR { class Node; } extern char* AOTcgDiagOn; -#if 0 //defined(ENABLE_AOT_S390) -#define AOTcgDiag0(comp,s) if (AOTcgDiagOn) dumpOptDetails(comp,s) -#define AOTcgDiag1(comp,s,p1) if (AOTcgDiagOn) dumpOptDetails(comp,s,p1) -#define AOTcgDiag2(comp,s,p1,p2) if (AOTcgDiagOn) dumpOptDetails(comp,s,p1,p2) -#define AOTcgDiag3(comp,s,p1,p2,p3) if (AOTcgDiagOn) dumpOptDetails(comp,s,p1,p2,p3) -#define AOTcgDiag4(comp,s,p1,p2,p3,p4) if (AOTcgDiagOn) dumpOptDetails(comp,s,p1,p2,p3,p4) -#define AOTcgDiag5(comp,s,p1,p2,p3,p4,p5) if (AOTcgDiagOn) dumpOptDetails(comp,s,p1,p2,p3,p4,p5) -#define AOTcgDiag6(comp,s,p1,p2,p3,p4,p5,p6) if (AOTcgDiagOn) dumpOptDetails(comp,s,p1,p2,p3,p4,p5,p6) -#else #define AOTcgDiag0(comp,s) AOTcgDummy() #define AOTcgDiag1(comp,s,p1) AOTcgDummy() #define AOTcgDiag2(comp,s,p1,p2) AOTcgDummy() @@ -56,7 +47,6 @@ extern char* AOTcgDiagOn; #define AOTcgDiag5(comp,s,p1,p2,p3,p4,p5) AOTcgDummy() #define AOTcgDiag6(comp,s,p1,p2,p3,p4,p5,p6) AOTcgDummy() inline void AOTcgDummy(){} -#endif typedef enum { @@ -277,71 +267,6 @@ class LabelAbsoluteRelocation : public TR::LabelRelocation }; -class LoadLabelRelative16BitRelocation : public TR::Relocation - { - TR::Instruction *_lastInstruction; - TR::LabelSymbol *_startLabel; - TR::LabelSymbol *_endLabel; - int32_t _deltaToStartLabel; // used to catch potentially nasty register dep related bugs - - public: - LoadLabelRelative16BitRelocation() : TR::Relocation() {} - LoadLabelRelative16BitRelocation(TR::Instruction *i, TR::LabelSymbol *start, TR::LabelSymbol *end, int32_t delta) - : TR::Relocation(NULL), _lastInstruction(i), _startLabel(start), _endLabel(end), _deltaToStartLabel(delta) {} - TR::Instruction *getLastInstruction() {return _lastInstruction;} - TR::Instruction *setLastInstruction(TR::Instruction *i) {return (_lastInstruction = i);} - - TR::LabelSymbol *getStartLabel() {return _startLabel;} - TR::LabelSymbol *setStartLabel(TR::LabelSymbol *l) {return (_startLabel = l);} - - TR::LabelSymbol *getEndLabel() {return _endLabel;} - TR::LabelSymbol *setEndLabel(TR::LabelSymbol *l) {return (_endLabel = l);} - - int32_t setDeltaToStartLabel(int32_t d) { return (_deltaToStartLabel = d); } - int32_t getDeltaToStartLabel() { return _deltaToStartLabel; } - - virtual void apply(TR::CodeGenerator *codeGen); - }; - -class LoadLabelRelative32BitRelocation : public TR::Relocation - { - TR::Instruction *_lastInstruction; - TR::LabelSymbol *_startLabel; - TR::LabelSymbol *_endLabel; - int32_t _deltaToStartLabel; // used to catch potentially nasty register dep related bugs - - public: - LoadLabelRelative32BitRelocation() : TR::Relocation() {} - LoadLabelRelative32BitRelocation(TR::Instruction *i, TR::LabelSymbol *start, TR::LabelSymbol *end, int32_t delta) - : TR::Relocation(NULL), _lastInstruction(i), _startLabel(start), _endLabel(end), _deltaToStartLabel(delta) {} - TR::Instruction *getLastInstruction() {return _lastInstruction;} - TR::Instruction *setLastInstruction(TR::Instruction *i) {return (_lastInstruction = i);} - - TR::LabelSymbol *getStartLabel() {return _startLabel;} - TR::LabelSymbol *setStartLabel(TR::LabelSymbol *l) {return (_startLabel = l);} - - TR::LabelSymbol *getEndLabel() {return _endLabel;} - TR::LabelSymbol *setEndLabel(TR::LabelSymbol *l) {return (_endLabel = l);} - - int32_t setDeltaToStartLabel(int32_t d) { return (_deltaToStartLabel = d); } - int32_t getDeltaToStartLabel() { return _deltaToStartLabel; } - - virtual void apply(TR::CodeGenerator *codeGen); - }; - -class LoadLabelRelative64BitRelocation : public TR::LabelRelocation - { - TR::Instruction *_lastInstruction; - public: - LoadLabelRelative64BitRelocation() : TR::LabelRelocation() {} - LoadLabelRelative64BitRelocation(TR::Instruction *i, TR::LabelSymbol *l) - : TR::LabelRelocation(NULL, l), _lastInstruction(i) {} - TR::Instruction *getLastInstruction() {return _lastInstruction;} - TR::Instruction *setLastInstruction(TR::Instruction *i) {return (_lastInstruction = i);} - - virtual void apply(TR::CodeGenerator *codeGen); - }; - #define MAX_SIZE_RELOCATION_DATA ((uint16_t)0xffff) #define MIN_SHORT_OFFSET -32768 #define MAX_SHORT_OFFSET 32767 @@ -551,33 +476,6 @@ class BeforeBinaryEncodingExternalRelocation : public TR::ExternalRelocation }; -class LabelTable32BitRelocation : public TR::LabelRelocation - { - public: - LabelTable32BitRelocation() : TR::LabelRelocation() {} - LabelTable32BitRelocation(uint8_t *p, TR::LabelSymbol *l) - : TR::LabelRelocation(p, l) {} - virtual void apply(TR::CodeGenerator *codeGen); - }; - } -typedef TR::RelocationDebugInfo TR_RelocationDebugInfo; -typedef TR::Relocation TR_Relocation; -typedef TR::LabelRelocation TR_LabelRelocation; -typedef TR::LabelRelative8BitRelocation TR_8BitLabelRelativeRelocation; -typedef TR::LabelRelative12BitRelocation TR_12BitLabelRelativeRelocation; -typedef TR::LabelRelative16BitRelocation TR_16BitLabelRelativeRelocation; -typedef TR::LabelRelative24BitRelocation TR_24BitLabelRelativeRelocation; -typedef TR::LabelRelative32BitRelocation TR_32BitLabelRelativeRelocation; -typedef TR::LabelAbsoluteRelocation TR_LabelAbsoluteRelocation; -typedef TR::LoadLabelRelative16BitRelocation TR_16BitLoadLabelRelativeRelocation; -typedef TR::LoadLabelRelative32BitRelocation TR_32BitLoadLabelRelativeRelocation; -typedef TR::LoadLabelRelative64BitRelocation TR_64BitLoadLabelRelativeRelocation; -typedef TR::IteratedExternalRelocation TR_IteratedExternalRelocation; -typedef TR::ExternalRelocation TR_ExternalRelocation; -typedef TR::ExternalOrderedPair32BitRelocation TR_32BitExternalOrderedPairRelocation; -typedef TR::BeforeBinaryEncodingExternalRelocation TR_BeforeBinaryEncodingExternalRelocation; -typedef TR::LabelTable32BitRelocation TR_32BitLabelTableRelocation; - #endif diff --git a/compiler/p/codegen/OMRCodeGenerator.cpp b/compiler/p/codegen/OMRCodeGenerator.cpp index a75561393a1..30d5ffbef81 100644 --- a/compiler/p/codegen/OMRCodeGenerator.cpp +++ b/compiler/p/codegen/OMRCodeGenerator.cpp @@ -1694,58 +1694,6 @@ void OMR::Power::CodeGenerator::apply24BitLabelRelativeRelocation(int32_t * curs *cursor |= distance & 0x03fffffcu; } -void OMR::Power::CodeGenerator::apply16BitLoadLabelRelativeRelocation(TR::Instruction *liInstruction, TR::LabelSymbol *startLabel, TR::LabelSymbol *endLabel, int32_t deltaToStartLabel) - { - // Patch up the mainline code that stores an offset value into a register using: - // li addrReg, Value & 0x0000ffff - - TR::Instruction *liPPCInstruction = liInstruction; - TR_ASSERT(liPPCInstruction->getOpCodeValue() == TR::InstOpCode::li,"wrong load instruction used for apply32BitLoadLabelRelativeRelocation\n"); - - int32_t distance = int32_t((endLabel->getCodeLocation() - startLabel->getCodeLocation())/4); - TR_ASSERT(!((endLabel->getCodeLocation() - startLabel->getCodeLocation())%4),"misaligned code"); - TR_ASSERT(!(distance & 0xffff0000), "relative label does not fit in 16-bit li instruction"); - - int32_t *patchAddr = (int32_t *)(liPPCInstruction->getBinaryEncoding()); - - TR_ASSERT((*(int32_t *)patchAddr & 0x0000ffff) == 0,"offset should be 0 to start\n"); - - // This type of relocation is used in some projects so an exception handler can get the return address off of the stack - // and then use this return address and the offset loaded here to find an exit label in the generated code. - // If the register deps are not done properly then the register assigner may insert instructions after the call but before - // the startLabel. If this bad register motion occurs then the loaded offset would be wrong (when used in this way) - // and if an exception occurs we may end up with a wild branch. - // This would be a very tough bug to find and fix so it is worth some ugliness in the function interface. - *patchAddr |= distance & 0x0000ffff; - } - -void OMR::Power::CodeGenerator::apply64BitLoadLabelRelativeRelocation(TR::Instruction *lastInstruction, TR::LabelSymbol *label) - { - // Patch up the mainline code that materializes a base register and does a load with update from this base register - // This is the instruction sequence generated by fixedSeqMemAccess - // hiAddr = HI_VALUE(addrValue) - // patchAddr-4 lis tempReg, hiAddr>>32 - // patchAddr-3 lis baseReg, hiAddr & 0x0000FFFF - // patchAddr-2 ori tempReg, tempReg, (hiAddr>>16) & 0x0000ffff - // patchAddr-1 rldimi baseReg, tempReg, 32, 0xffffFFFF00000000 (not patched) - // patchAddr ldu trgReg, [baseReg+addrValue] <-- lastInstruction - - TR::Instruction *lastPPCInstruction = lastInstruction; - TR_ASSERT((lastPPCInstruction->getOpCodeValue() == TR::InstOpCode::ldu || lastPPCInstruction->getOpCodeValue() == TR::InstOpCode::ld) && - lastPPCInstruction->getPrev()->getPrev()->getOpCodeValue() == TR::InstOpCode::ori && - lastPPCInstruction->getPrev()->getPrev()->getPrev()->getOpCodeValue() == TR::InstOpCode::lis && - lastPPCInstruction->getPrev()->getPrev()->getPrev()->getPrev()->getOpCodeValue() == TR::InstOpCode::lis, - "fixedSeqMemAccess instruction sequence has changed.\n"); - - int32_t *patchAddr = (int32_t *)(lastPPCInstruction->getBinaryEncoding()); - intptr_t addrValue = (intptr_t)label->getCodeLocation(); - *patchAddr |= addrValue & 0x0000ffff; - addrValue = HI_VALUE(addrValue); - *(patchAddr-2) |= (addrValue>>16) & 0x0000ffff; - *(patchAddr-3) |= addrValue & 0x0000ffff; - *(patchAddr-4) |= (addrValue>>32) & 0x0000ffff; - } - static int32_t getAssociationIndex(TR::Register *reg, TR::RealRegister::RegNum realNum) { diff --git a/compiler/p/codegen/OMRCodeGenerator.hpp b/compiler/p/codegen/OMRCodeGenerator.hpp index d0cb11aef37..12adae3ca80 100644 --- a/compiler/p/codegen/OMRCodeGenerator.hpp +++ b/compiler/p/codegen/OMRCodeGenerator.hpp @@ -252,8 +252,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator using OMR::CodeGenerator::apply16BitLabelRelativeRelocation; void apply16BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); void apply24BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); - void apply16BitLoadLabelRelativeRelocation(TR::Instruction *liInstruction, TR::LabelSymbol *startLabel, TR::LabelSymbol *endLabel, int32_t deltaToStartLabel); - void apply64BitLoadLabelRelativeRelocation(TR::Instruction *lastInstruction, TR::LabelSymbol *label); TR::RealRegister *getStackPointerRegister() { diff --git a/compiler/x/codegen/OMRCodeGenerator.cpp b/compiler/x/codegen/OMRCodeGenerator.cpp index 55ab558312e..8d1b0f48e58 100644 --- a/compiler/x/codegen/OMRCodeGenerator.cpp +++ b/compiler/x/codegen/OMRCodeGenerator.cpp @@ -2350,30 +2350,6 @@ OMR::X86::CodeGenerator::estimateBinaryLength(TR::MemoryReference *mr) return mr->estimateBinaryLength(self()); } -// movInstruction MOV4RegImm4 reg,<4 byte imm> -// ... -// startLabel: -// ... -// endLabel: -// -// This relocation encodes the distance (endLabel - startLabel) in the movInstruction's immediate field -// deltaToStartLabel is the byte distance from the start of the instruction following the mov to the startLabel address -void OMR::X86::CodeGenerator::apply32BitLoadLabelRelativeRelocation(TR::Instruction *movInstruction, TR::LabelSymbol *startLabel, TR::LabelSymbol *endLabel, int32_t deltaToStartLabel) - { - TR::Instruction *movInstructionX86 = movInstruction; - - TR_ASSERT(movInstructionX86->getOpCodeValue() == MOV4RegImm4,"wrong load instruction used for apply32BitLoadLabelRelativeRelocation\n"); - - uint8_t *cursor = movInstructionX86->getBinaryEncoding(); - cursor += movInstructionX86->getOpCode().length(movInstructionX86->rexBits()) + movInstructionX86->rexRepeatCount(); - - int32_t distance = int32_t(endLabel->getCodeLocation() - startLabel->getCodeLocation()); - TR_ASSERT(IS_32BIT_SIGNED(distance), - "relative label does not fit in 4 byte mov immediate instruction\n"); - TR_ASSERT(*(int32_t *)cursor == 0,"offset should be 0 to start\n"); - - *(int32_t *)cursor = distance; - } void OMR::X86::CodeGenerator::apply32BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol * label) { diff --git a/compiler/x/codegen/OMRCodeGenerator.hpp b/compiler/x/codegen/OMRCodeGenerator.hpp index 276cacc35f8..cfc1e77db5c 100644 --- a/compiler/x/codegen/OMRCodeGenerator.hpp +++ b/compiler/x/codegen/OMRCodeGenerator.hpp @@ -536,8 +536,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator // uint32_t estimateBinaryLength(TR::MemoryReference *); - void apply32BitLoadLabelRelativeRelocation(TR::Instruction *movInstruction, TR::LabelSymbol *startLabel, TR::LabelSymbol *endLabel, int32_t deltaToStartLabel); - void apply32BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); bool isAddressScaleIndexSupported(int32_t scale) { if (scale <= 8) return true; return false; } diff --git a/compiler/z/codegen/OMRCodeGenerator.cpp b/compiler/z/codegen/OMRCodeGenerator.cpp index f2a6057c795..2aa152e8f6a 100644 --- a/compiler/z/codegen/OMRCodeGenerator.cpp +++ b/compiler/z/codegen/OMRCodeGenerator.cpp @@ -3578,15 +3578,6 @@ OMR::Z::CodeGenerator::apply32BitLabelRelativeRelocation(int32_t * cursor, TR::L *(int32_t *) (((uint8_t *) cursor) + 2) = (int32_t) (((intptr_t) (label->getCodeLocation()) - ((intptr_t) cursor)) / 2); } -//////////////////////////////////////////////////////////////////////////////// -// OMR::Z::CodeGenerator::apply32BitLabelTableRelocation -//////////////////////////////////////////////////////////////////////////////// -void -OMR::Z::CodeGenerator::apply32BitLabelTableRelocation(int32_t * cursor, TR::LabelSymbol * label) - { - *(uint32_t *) cursor = (intptr_t) label->getCodeLocation() - ((intptr_t) cursor - *(uint32_t *) cursor); - } - /** * Get the first snippet entry. If there is at least one targetAddress entry, * this value will be returned. If no targetAddress exists, the first dataConstant diff --git a/compiler/z/codegen/OMRCodeGenerator.hpp b/compiler/z/codegen/OMRCodeGenerator.hpp index 40ca7535666..e3b16495b6e 100644 --- a/compiler/z/codegen/OMRCodeGenerator.hpp +++ b/compiler/z/codegen/OMRCodeGenerator.hpp @@ -331,7 +331,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator void apply16BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *, int8_t addressDifferenceDivisor, bool isInstrOffset = false); void apply16BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); void apply32BitLabelRelativeRelocation(int32_t * cursor, TR::LabelSymbol *); - void apply32BitLabelTableRelocation(int32_t * cursor, TR::LabelSymbol *); void setUnavailableRegisters(TR::Block *b, TR_BitVector &unavailableRegisters);