27
27
28
28
using namespace llvm ;
29
29
30
- #define GET_REGINFO_ENUM
30
+ #define GET_INSTRINFO_ENUM
31
+ #include " DPUGenInstrInfo.inc"
31
32
33
+ #define GET_REGINFO_ENUM
32
34
#include " DPUGenRegisterInfo.inc"
33
35
34
36
// Decoded registers, with respect to their indexing in the DPU. See
@@ -176,12 +178,30 @@ MCDisassembler::DecodeStatus DPUOperandDecoder::Decode_false_cc(MCInst &MI) {
176
178
return MCDisassembler::Success;
177
179
}
178
180
181
+ #define FIXUP_PC (pc ) (0x80000000 | (unsigned )((pc) * 8 ))
182
+
179
183
MCDisassembler::DecodeStatus DPUOperandDecoder::Decode_pc (llvm::MCInst &MI,
180
184
uint64_t Value) {
181
185
LLVM_DEBUG (dbgs () << " PC << " << Value << " \n " );
182
- // Re-adjust PC to linker fixup
183
- unsigned fixedUp = 0x80000000 | (unsigned )(Value * 8 );
184
- DecodePC (MI, fixedUp, Address, Decoder);
186
+ DecodePC (MI, FIXUP_PC (Value), Address, Decoder);
187
+ return MCDisassembler::Success;
188
+ }
189
+
190
+ static MCDisassembler::DecodeStatus DecodeOff (MCInst &MI, int32_t Value,
191
+ const MCDisassembler *Decoder) {
192
+ switch (MI.getOpcode ()) {
193
+ case DPU::CALLrri:
194
+ case DPU::JUMPri:
195
+ case DPU::CALLzri: {
196
+ const MCOperand &lastOperand = MI.getOperand (MI.getNumOperands () - 1 );
197
+ if (lastOperand.isReg () && lastOperand.getReg () == DPU::ZERO &&
198
+ tryAddingSymbolicOperand (FIXUP_PC (Value), true , 0 , 2 , 23 , MI, Decoder))
199
+ return MCDisassembler::Success;
200
+ }
201
+ default :
202
+ break ;
203
+ }
204
+ MI.addOperand (MCOperand::createImm (Value));
185
205
return MCDisassembler::Success;
186
206
}
187
207
@@ -190,14 +210,14 @@ MCDisassembler::DecodeStatus DPUOperandDecoder::Decode_off(llvm::MCInst &MI,
190
210
int32_t ValueSize) {
191
211
LLVM_DEBUG (dbgs () << " off << " << Value << " \n " );
192
212
Value = Value | ((-(Value >> (ValueSize - 1 ))) << ValueSize);
193
- MI. addOperand ( MCOperand::createImm ( Value) );
213
+ DecodeOff (MI, Value, Decoder );
194
214
return MCDisassembler::Success;
195
215
}
196
216
197
217
MCDisassembler::DecodeStatus DPUOperandDecoder::Decode_off (llvm::MCInst &MI,
198
218
int32_t Value) {
199
219
LLVM_DEBUG (dbgs () << " off << " << Value << " \n " );
200
- MI. addOperand ( MCOperand::createImm ( Value) );
220
+ DecodeOff (MI, Value, Decoder );
201
221
return MCDisassembler::Success;
202
222
}
203
223
0 commit comments