File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed
llvm/lib/Target/RISCV/MCTargetDesc Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,29 @@ class RISCVMCInstrAnalysis : public MCInstrAnalysis {
272272 }
273273 break ;
274274 }
275+ case RISCV::C_ADDI: {
276+ int64_t Offset = Inst.getOperand (2 ).getImm ();
277+ if (Offset == 0 )
278+ break ;
279+ if (auto TargetRegState = getGPRState (Inst.getOperand (1 ).getReg ())) {
280+ Target = *TargetRegState + SignExtend64<6 >(Offset);
281+ return true ;
282+ }
283+ break ;
284+ }
285+ case RISCV::C_ADDIW: {
286+ int64_t Offset = Inst.getOperand (2 ).getImm ();
287+ if (Offset == 0 )
288+ break ;
289+ if (auto TargetRegState = getGPRState (Inst.getOperand (1 ).getReg ())) {
290+ uint64_t Mask = ~((uint64_t )0 ) >> 32 ;
291+ Target &= Mask;
292+ Target = *TargetRegState + SignExtend64<6 >(Offset);
293+ Target = SignExtend64<32 >(Target);
294+ return true ;
295+ }
296+ break ;
297+ }
275298 case RISCV::LB:
276299 case RISCV::LH:
277300 case RISCV::LD:
@@ -296,7 +319,20 @@ class RISCVMCInstrAnalysis : public MCInstrAnalysis {
296319 Target = Offset;
297320 return true ;
298321 }
299- // TODO: Add cases for compressed load and store instructions
322+ case RISCV::C_LD:
323+ case RISCV::C_SD:
324+ case RISCV::C_FLD:
325+ case RISCV::C_FSD:
326+ case RISCV::C_SW:
327+ case RISCV::C_LW:
328+ case RISCV::C_FSW:
329+ case RISCV::C_FLW: {
330+ if (auto TargetRegState = getGPRState (Inst.getOperand (1 ).getReg ())) {
331+ Target = *TargetRegState + Inst.getOperand (2 ).getImm ();
332+ return true ;
333+ }
334+ break ;
335+ }
300336 }
301337 return false ;
302338 }
You can’t perform that action at this time.
0 commit comments