Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated codegen Relocations #5578

Merged
merged 2 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 0 additions & 4 deletions compiler/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();


Expand Down
23 changes: 0 additions & 23 deletions compiler/codegen/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,6 @@ TR::InstructionLabelRelative32BitRelocation::apply(TR::CodeGenerator* cg)
*reinterpret_cast<int32_t*>(p) = static_cast<int32_t>(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();
Expand Down Expand Up @@ -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());
}
102 changes: 0 additions & 102 deletions compiler/codegen/Relocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
52 changes: 0 additions & 52 deletions compiler/p/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions compiler/p/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
24 changes: 0 additions & 24 deletions compiler/x/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions compiler/x/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
9 changes: 0 additions & 9 deletions compiler/z/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compiler/z/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down