Skip to content

Commit 0bf72f9

Browse files
noonefuzyll
authored andcommitted
Add intrinsics for some system instructions
Except for SYNCI, I didn't have any test cases for these, but they're fairly simple.
1 parent c79af77 commit 0bf72f9

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

arch/mips/arch_mips.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,8 @@ class MipsArchitecture: public Architecture
923923
return "moveDwordToCoprocessorUnimplemented";
924924
case MIPS_INTRIN_SYNC:
925925
return "_sync";
926+
case MIPS_INTRIN_SYNCI:
927+
return "_SynchronizeCacheLines";
926928
case MIPS_INTRIN_EI:
927929
return "_enableInterrupts";
928930
case MIPS_INTRIN_DI:
@@ -931,6 +933,8 @@ class MipsArchitecture: public Architecture
931933
return "_clearExecutionHazards";
932934
case MIPS_INTRIN_WAIT:
933935
return "_enterLowPowerMode";
936+
case MIPS_INTRIN_PAUSE:
937+
return "_waitForLLbitClear";
934938
case MIPS_INTRIN_HWR0:
935939
return "_cpuNum";
936940
case MIPS_INTRIN_HWR1:
@@ -951,6 +955,8 @@ class MipsArchitecture: public Architecture
951955
return "_prefetch";
952956
case MIPS_INTRIN_CACHE:
953957
return "_cache";
958+
case MIPS_INTRIN_SDBBP:
959+
return "_softwareDebugBreakpoint";
954960
case MIPS_INTRIN_GET_LEFT_PART32:
955961
return "_getLeftPart32";
956962
case MIPS_INTRIN_GET_RIGHT_PART32:
@@ -1004,10 +1010,12 @@ class MipsArchitecture: public Architecture
10041010
MIPS_INTRIN_DMTC0,
10051011
MIPS_INTRIN_DMTC_UNIMPLEMENTED,
10061012
MIPS_INTRIN_SYNC,
1013+
MIPS_INTRIN_SYNCI,
10071014
MIPS_INTRIN_DI,
10081015
MIPS_INTRIN_EHB,
10091016
MIPS_INTRIN_EI,
10101017
MIPS_INTRIN_WAIT,
1018+
MIPS_INTRIN_PAUSE,
10111019
MIPS_INTRIN_HWR0,
10121020
MIPS_INTRIN_HWR1,
10131021
MIPS_INTRIN_HWR2,
@@ -1095,6 +1103,10 @@ class MipsArchitecture: public Architecture
10951103
return {
10961104
NameAndType("stype", Type::IntegerType(4, false)),
10971105
};
1106+
case MIPS_INTRIN_SYNCI:
1107+
return {
1108+
NameAndType("vaddr", Type::IntegerType(8, false)),
1109+
};
10981110
case MIPS_INTRIN_HWR_UNKNOWN:
10991111
return {
11001112
NameAndType("hwreg", Type::IntegerType(4, false)),
@@ -1110,6 +1122,11 @@ class MipsArchitecture: public Architecture
11101122
NameAndType("address", Type::IntegerType(m_bits == 64 ? 8 : 4, false)),
11111123
};
11121124

1125+
case MIPS_INTRIN_SDBBP:
1126+
return {
1127+
NameAndType("code", Type::IntegerType(1, false)),
1128+
};
1129+
11131130
// NOTE: SET_x_PARTx could potentially benefit from
11141131
// including the old value as an input (since each
11151132
// only sets part of the register and keeps the

arch/mips/il.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
15991599
il.AddInstruction(SetRegisterOrNop(il, 4, registerSize, op1.reg, il.RotateRight(4, ReadILOperand(il, instr, 2, registerSize), ReadILOperand(il, instr, 3, registerSize))));
16001600
break;
16011601
case MIPS_SDBBP:
1602-
il.AddInstruction(il.Unimplemented());
1602+
il.AddInstruction(il.Intrinsic({}, MIPS_INTRIN_SDBBP, { il.Const(1, op1.immediate )}));
16031603
break;
16041604
case MIPS_SEB:
16051605
il.AddInstruction(SetRegisterOrNop(il, registerSize, registerSize, op1.reg, il.SignExtend(registerSize, il.LowPart(1, ReadILOperand(il, instr, 2, registerSize)))));
@@ -1810,6 +1810,10 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
18101810
break;
18111811
}
18121812

1813+
case MIPS_SYNCI:
1814+
il.AddInstruction(il.Intrinsic({}, MIPS_INTRIN_SYNCI, { GetILOperandMemoryAddress(il, op1, addrSize) }));
1815+
break;
1816+
18131817
case MIPS_DI:
18141818
il.AddInstruction(SimpleIntrinsic(il, MIPS_INTRIN_DI));
18151819
break;
@@ -1822,6 +1826,10 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
18221826
il.AddInstruction(SimpleIntrinsic(il, MIPS_INTRIN_EI));
18231827
break;
18241828

1829+
case MIPS_PAUSE:
1830+
il.AddInstruction(SimpleIntrinsic(il, MIPS_INTRIN_PAUSE));
1831+
break;
1832+
18251833
case MIPS_WAIT:
18261834
il.AddInstruction(SimpleIntrinsic(il, MIPS_INTRIN_WAIT));
18271835
break;
@@ -2126,9 +2134,7 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
21262134
case MIPS_JALX: //Special instruction for switching to MIPS32/microMIPS32/MIPS16e
21272135
case MIPS_MTHC1:
21282136
case MIPS_MTHC2:
2129-
case MIPS_PAUSE:
21302137
case MIPS_PREFX:
2131-
case MIPS_SYNCI:
21322138
case MIPS_TLBP:
21332139
case MIPS_TLBR:
21342140
case MIPS_TLBWI:

arch/mips/il.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ enum MipsIntrinsic : uint32_t
2222
MIPS_INTRIN_DMTC2,
2323
MIPS_INTRIN_DMTC_UNIMPLEMENTED,
2424
MIPS_INTRIN_SYNC,
25+
MIPS_INTRIN_SYNCI,
2526
MIPS_INTRIN_DI,
2627
MIPS_INTRIN_EHB,
2728
MIPS_INTRIN_EI,
29+
MIPS_INTRIN_PAUSE,
2830
MIPS_INTRIN_WAIT,
2931
MIPS_INTRIN_HWR0,
3032
MIPS_INTRIN_HWR1,
@@ -36,6 +38,7 @@ enum MipsIntrinsic : uint32_t
3638
MIPS_INTRIN_LLBIT_CHECK,
3739
MIPS_INTRIN_PREFETCH,
3840
MIPS_INTRIN_CACHE,
41+
MIPS_INTRIN_SDBBP,
3942

4043
// there's no clean way to lift LWL/LWR, SWL/SWR, etc when not
4144
// a pair of adjacent instructions, since the number and position

0 commit comments

Comments
 (0)