llvm.org GIT mirror llvm / 8a79448
Merging r243660: ------------------------------------------------------------------------ r243660 | Matthew.Arsenault | 2015-07-30 13:03:08 -0400 (Thu, 30 Jul 2015) | 9 lines AMDGPU: Fix unreachable when emitting binary debug info Copy implementation of applyFixup from AArch64 with AArch64 bits ripped out. Tests will be included with a later commit. Several other problems must be fixed before binary debug info emission will work. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@253229 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
1 changed file(s) with 33 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
7070 }
7171 }
7272
73 static unsigned getFixupKindNumBytes(unsigned Kind) {
74 switch (Kind) {
75 case FK_Data_1:
76 return 1;
77 case FK_Data_2:
78 return 2;
79 case FK_Data_4:
80 return 4;
81 case FK_Data_8:
82 return 8;
83 default:
84 llvm_unreachable("Unknown fixup kind!");
85 }
86 }
87
7388 void AMDGPUAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
7489 unsigned DataSize, uint64_t Value,
7590 bool IsPCRel) const {
7691
7792 switch ((unsigned)Fixup.getKind()) {
78 default: llvm_unreachable("Unknown fixup kind");
7993 case AMDGPU::fixup_si_sopp_br: {
8094 uint16_t *Dst = (uint16_t*)(Data + Fixup.getOffset());
8195 *Dst = (Value - 4) / 4;
94108 // need to add 4 bytes to get to the start of the constants.
95109 *Dst = Value + 4;
96110 break;
111 }
112 default: {
113 // FIXME: Copied from AArch64
114 unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
115 if (!Value)
116 return; // Doesn't change encoding.
117 MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
118
119 // Shift the value into position.
120 Value <<= Info.TargetOffset;
121
122 unsigned Offset = Fixup.getOffset();
123 assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!");
124
125 // For each byte of the fragment that the fixup touches, mask in the
126 // bits from the fixup value.
127 for (unsigned i = 0; i != NumBytes; ++i)
128 Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
97129 }
98130 }
99131 }