3 // Copyright (c) 2010 ARM Limited
6 // The license below extends only to copyright in the software and shall
7 // not be construed as granting a license to any other intellectual
8 // property including but not limited to intellectual property relating
9 // to a hardware implementation of the functionality of the software
10 // licensed hereunder. You may use the software subject to the license
11 // terms below provided that you ensure that this notice is replicated
12 // unmodified and in its entirety in all distributions of the software,
13 // modified or unmodified, in source code or in binary form.
15 // Redistribution and use in source and binary forms, with or without
16 // modification, are permitted provided that the following conditions are
17 // met: redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer;
19 // redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution;
22 // neither the name of the copyright holders nor the names of its
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 // Authors: Gabe Black
44 fault = new SupervisorCall;
46 fault = new SupervisorCall(machInst);
50 svcIop = InstObjParams("svc", "Svc", "PredOp",
52 "predicate_test": predicateTest }, ["IsSyscall"])
53 header_output = BasicDeclare.subst(svcIop)
54 decoder_output = BasicConstructor.subst(svcIop)
55 exec_output = PredOpExecute.subst(svcIop)
61 header_output = decoder_output = exec_output = ""
63 mrsCpsrCode = "Dest = (Cpsr | CondCodes) & 0xF8FF03DF"
64 mrsCpsrIop = InstObjParams("mrs", "MrsCpsr", "MrsOp",
65 { "code": mrsCpsrCode,
66 "predicate_test": condPredicateTest },
67 ["IsSerializeBefore"])
68 header_output += MrsDeclare.subst(mrsCpsrIop)
69 decoder_output += MrsConstructor.subst(mrsCpsrIop)
70 exec_output += PredOpExecute.subst(mrsCpsrIop)
72 mrsSpsrCode = "Dest = Spsr"
73 mrsSpsrIop = InstObjParams("mrs", "MrsSpsr", "MrsOp",
74 { "code": mrsSpsrCode,
75 "predicate_test": predicateTest },
76 ["IsSerializeBefore"])
77 header_output += MrsDeclare.subst(mrsSpsrIop)
78 decoder_output += MrsConstructor.subst(mrsSpsrIop)
79 exec_output += PredOpExecute.subst(mrsSpsrIop)
84 cpsrWriteByInstr(Cpsr | CondCodes, Op1, byteMask, false, sctlr.nmfi);
85 Cpsr = ~CondCodesMask & newCpsr;
86 NextThumb = ((CPSR)newCpsr).t;
87 NextJazelle = ((CPSR)newCpsr).j;
88 ForcedItState = ((((CPSR)Op1).it2 << 2) & 0xFC)
89 | (((CPSR)Op1).it1 & 0x3);
90 CondCodes = CondCodesMask & newCpsr;
92 msrCpsrRegIop = InstObjParams("msr", "MsrCpsrReg", "MsrRegOp",
93 { "code": msrCpsrRegCode,
94 "predicate_test": condPredicateTest },
95 ["IsSerializeAfter","IsNonSpeculative"])
96 header_output += MsrRegDeclare.subst(msrCpsrRegIop)
97 decoder_output += MsrRegConstructor.subst(msrCpsrRegIop)
98 exec_output += PredOpExecute.subst(msrCpsrRegIop)
100 msrSpsrRegCode = "Spsr = spsrWriteByInstr(Spsr, Op1, byteMask, false);"
101 msrSpsrRegIop = InstObjParams("msr", "MsrSpsrReg", "MsrRegOp",
102 { "code": msrSpsrRegCode,
103 "predicate_test": predicateTest },
104 ["IsSerializeAfter","IsNonSpeculative"])
105 header_output += MsrRegDeclare.subst(msrSpsrRegIop)
106 decoder_output += MsrRegConstructor.subst(msrSpsrRegIop)
107 exec_output += PredOpExecute.subst(msrSpsrRegIop)
112 cpsrWriteByInstr(Cpsr | CondCodes, imm, byteMask, false, sctlr.nmfi);
113 Cpsr = ~CondCodesMask & newCpsr;
114 NextThumb = ((CPSR)newCpsr).t;
115 NextJazelle = ((CPSR)newCpsr).j;
116 ForcedItState = ((((CPSR)imm).it2 << 2) & 0xFC)
117 | (((CPSR)imm).it1 & 0x3);
118 CondCodes = CondCodesMask & newCpsr;
120 msrCpsrImmIop = InstObjParams("msr", "MsrCpsrImm", "MsrImmOp",
121 { "code": msrCpsrImmCode,
122 "predicate_test": condPredicateTest },
123 ["IsSerializeAfter","IsNonSpeculative"])
124 header_output += MsrImmDeclare.subst(msrCpsrImmIop)
125 decoder_output += MsrImmConstructor.subst(msrCpsrImmIop)
126 exec_output += PredOpExecute.subst(msrCpsrImmIop)
128 msrSpsrImmCode = "Spsr = spsrWriteByInstr(Spsr, imm, byteMask, false);"
129 msrSpsrImmIop = InstObjParams("msr", "MsrSpsrImm", "MsrImmOp",
130 { "code": msrSpsrImmCode,
131 "predicate_test": predicateTest },
132 ["IsSerializeAfter","IsNonSpeculative"])
133 header_output += MsrImmDeclare.subst(msrSpsrImmIop)
134 decoder_output += MsrImmConstructor.subst(msrSpsrImmIop)
135 exec_output += PredOpExecute.subst(msrSpsrImmIop)
139 Dest = swap_byte(val);
141 revIop = InstObjParams("rev", "Rev", "RegRegOp",
143 "predicate_test": predicateTest }, [])
144 header_output += RegRegOpDeclare.subst(revIop)
145 decoder_output += RegRegOpConstructor.subst(revIop)
146 exec_output += PredOpExecute.subst(revIop)
150 Dest = (bits(val, 15, 8) << 0) |
151 (bits(val, 7, 0) << 8) |
152 (bits(val, 31, 24) << 16) |
153 (bits(val, 23, 16) << 24);
155 rev16Iop = InstObjParams("rev16", "Rev16", "RegRegOp",
157 "predicate_test": predicateTest }, [])
158 header_output += RegRegOpDeclare.subst(rev16Iop)
159 decoder_output += RegRegOpConstructor.subst(rev16Iop)
160 exec_output += PredOpExecute.subst(rev16Iop)
164 Dest = sext<16>(swap_byte(val));
166 revshIop = InstObjParams("revsh", "Revsh", "RegRegOp",
168 "predicate_test": predicateTest }, [])
169 header_output += RegRegOpDeclare.subst(revshIop)
170 decoder_output += RegRegOpConstructor.subst(revshIop)
171 exec_output += PredOpExecute.subst(revshIop)
174 uint8_t *opBytes = (uint8_t *)&Op1;
176 uint8_t *destBytes = (uint8_t *)&resTemp;
177 // This reverses the bytes and bits of the input, or so says the
179 for (int i = 0; i < 4; i++) {
180 uint32_t temp = opBytes[i];
181 temp = (temp * 0x0802 & 0x22110) | (temp * 0x8020 & 0x88440);
182 destBytes[3 - i] = (temp * 0x10101) >> 16;
186 rbitIop = InstObjParams("rbit", "Rbit", "RegRegOp",
188 "predicate_test": predicateTest }, [])
189 header_output += RegRegOpDeclare.subst(rbitIop)
190 decoder_output += RegRegOpConstructor.subst(rbitIop)
191 exec_output += PredOpExecute.subst(rbitIop)
194 Dest = (Op1 == 0) ? 32 : (31 - findMsbSet(Op1));
196 clzIop = InstObjParams("clz", "Clz", "RegRegOp",
198 "predicate_test": predicateTest }, [])
199 header_output += RegRegOpDeclare.subst(clzIop)
200 decoder_output += RegRegOpConstructor.subst(clzIop)
201 exec_output += PredOpExecute.subst(clzIop)
204 int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0);
206 if (satInt(res, operand, imm))
207 CondCodes = CondCodes | (1 << 27);
209 CondCodes = CondCodes;
212 ssatIop = InstObjParams("ssat", "Ssat", "RegImmRegShiftOp",
214 "predicate_test": condPredicateTest }, [])
215 header_output += RegImmRegShiftOpDeclare.subst(ssatIop)
216 decoder_output += RegImmRegShiftOpConstructor.subst(ssatIop)
217 exec_output += PredOpExecute.subst(ssatIop)
220 int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0);
222 if (uSatInt(res, operand, imm))
223 CondCodes = CondCodes | (1 << 27);
225 CondCodes = CondCodes;
228 usatIop = InstObjParams("usat", "Usat", "RegImmRegShiftOp",
230 "predicate_test": condPredicateTest }, [])
231 header_output += RegImmRegShiftOpDeclare.subst(usatIop)
232 decoder_output += RegImmRegShiftOpConstructor.subst(usatIop)
233 exec_output += PredOpExecute.subst(usatIop)
237 uint32_t resTemp = 0;
238 CondCodes = CondCodes;
239 int32_t argLow = sext<16>(bits(Op1, 15, 0));
240 int32_t argHigh = sext<16>(bits(Op1, 31, 16));
241 if (satInt(res, argLow, imm))
242 CondCodes = CondCodes | (1 << 27);
243 replaceBits(resTemp, 15, 0, res);
244 if (satInt(res, argHigh, imm))
245 CondCodes = CondCodes | (1 << 27);
246 replaceBits(resTemp, 31, 16, res);
249 ssat16Iop = InstObjParams("ssat16", "Ssat16", "RegImmRegOp",
250 { "code": ssat16Code,
251 "predicate_test": condPredicateTest }, [])
252 header_output += RegImmRegOpDeclare.subst(ssat16Iop)
253 decoder_output += RegImmRegOpConstructor.subst(ssat16Iop)
254 exec_output += PredOpExecute.subst(ssat16Iop)
258 uint32_t resTemp = 0;
259 CondCodes = CondCodes;
260 int32_t argLow = sext<16>(bits(Op1, 15, 0));
261 int32_t argHigh = sext<16>(bits(Op1, 31, 16));
262 if (uSatInt(res, argLow, imm))
263 CondCodes = CondCodes | (1 << 27);
264 replaceBits(resTemp, 15, 0, res);
265 if (uSatInt(res, argHigh, imm))
266 CondCodes = CondCodes | (1 << 27);
267 replaceBits(resTemp, 31, 16, res);
270 usat16Iop = InstObjParams("usat16", "Usat16", "RegImmRegOp",
271 { "code": usat16Code,
272 "predicate_test": condPredicateTest }, [])
273 header_output += RegImmRegOpDeclare.subst(usat16Iop)
274 decoder_output += RegImmRegOpConstructor.subst(usat16Iop)
275 exec_output += PredOpExecute.subst(usat16Iop)
277 sxtbIop = InstObjParams("sxtb", "Sxtb", "RegImmRegOp",
279 "Dest = sext<8>((uint8_t)(Op1.ud >> imm));",
280 "predicate_test": predicateTest }, [])
281 header_output += RegImmRegOpDeclare.subst(sxtbIop)
282 decoder_output += RegImmRegOpConstructor.subst(sxtbIop)
283 exec_output += PredOpExecute.subst(sxtbIop)
285 sxtabIop = InstObjParams("sxtab", "Sxtab", "RegRegRegImmOp",
288 Dest = sext<8>((uint8_t)(Op2.ud >> imm)) +
291 "predicate_test": predicateTest }, [])
292 header_output += RegRegRegImmOpDeclare.subst(sxtabIop)
293 decoder_output += RegRegRegImmOpConstructor.subst(sxtabIop)
294 exec_output += PredOpExecute.subst(sxtabIop)
297 uint32_t resTemp = 0;
298 replaceBits(resTemp, 15, 0, sext<8>(bits(Op1, imm + 7, imm)));
299 replaceBits(resTemp, 31, 16,
300 sext<8>(bits(Op1, (imm + 23) % 32, (imm + 16) % 32)));
303 sxtb16Iop = InstObjParams("sxtb16", "Sxtb16", "RegImmRegOp",
304 { "code": sxtb16Code,
305 "predicate_test": predicateTest }, [])
306 header_output += RegImmRegOpDeclare.subst(sxtb16Iop)
307 decoder_output += RegImmRegOpConstructor.subst(sxtb16Iop)
308 exec_output += PredOpExecute.subst(sxtb16Iop)
311 uint32_t resTemp = 0;
312 replaceBits(resTemp, 15, 0, sext<8>(bits(Op2, imm + 7, imm)) +
314 replaceBits(resTemp, 31, 16,
315 sext<8>(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) +
319 sxtab16Iop = InstObjParams("sxtab16", "Sxtab16", "RegRegRegImmOp",
320 { "code": sxtab16Code,
321 "predicate_test": predicateTest }, [])
322 header_output += RegRegRegImmOpDeclare.subst(sxtab16Iop)
323 decoder_output += RegRegRegImmOpConstructor.subst(sxtab16Iop)
324 exec_output += PredOpExecute.subst(sxtab16Iop)
327 uint64_t rotated = (uint32_t)Op1;
328 rotated = (rotated | (rotated << 32)) >> imm;
329 Dest = sext<16>((uint16_t)rotated);
331 sxthIop = InstObjParams("sxth", "Sxth", "RegImmRegOp",
333 "predicate_test": predicateTest }, [])
334 header_output += RegImmRegOpDeclare.subst(sxthIop)
335 decoder_output += RegImmRegOpConstructor.subst(sxthIop)
336 exec_output += PredOpExecute.subst(sxthIop)
339 uint64_t rotated = (uint32_t)Op2;
340 rotated = (rotated | (rotated << 32)) >> imm;
341 Dest = sext<16>((uint16_t)rotated) + Op1;
343 sxtahIop = InstObjParams("sxtah", "Sxtah", "RegRegRegImmOp",
345 "predicate_test": predicateTest }, [])
346 header_output += RegRegRegImmOpDeclare.subst(sxtahIop)
347 decoder_output += RegRegRegImmOpConstructor.subst(sxtahIop)
348 exec_output += PredOpExecute.subst(sxtahIop)
350 uxtbIop = InstObjParams("uxtb", "Uxtb", "RegImmRegOp",
351 { "code": "Dest = (uint8_t)(Op1.ud >> imm);",
352 "predicate_test": predicateTest }, [])
353 header_output += RegImmRegOpDeclare.subst(uxtbIop)
354 decoder_output += RegImmRegOpConstructor.subst(uxtbIop)
355 exec_output += PredOpExecute.subst(uxtbIop)
357 uxtabIop = InstObjParams("uxtab", "Uxtab", "RegRegRegImmOp",
359 "Dest = (uint8_t)(Op2.ud >> imm) + Op1;",
360 "predicate_test": predicateTest }, [])
361 header_output += RegRegRegImmOpDeclare.subst(uxtabIop)
362 decoder_output += RegRegRegImmOpConstructor.subst(uxtabIop)
363 exec_output += PredOpExecute.subst(uxtabIop)
366 uint32_t resTemp = 0;
367 replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op1, imm + 7, imm)));
368 replaceBits(resTemp, 31, 16,
369 (uint8_t)(bits(Op1, (imm + 23) % 32, (imm + 16) % 32)));
372 uxtb16Iop = InstObjParams("uxtb16", "Uxtb16", "RegImmRegOp",
373 { "code": uxtb16Code,
374 "predicate_test": predicateTest }, [])
375 header_output += RegImmRegOpDeclare.subst(uxtb16Iop)
376 decoder_output += RegImmRegOpConstructor.subst(uxtb16Iop)
377 exec_output += PredOpExecute.subst(uxtb16Iop)
380 uint32_t resTemp = 0;
381 replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op2, imm + 7, imm)) +
383 replaceBits(resTemp, 31, 16,
384 (uint8_t)(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) +
388 uxtab16Iop = InstObjParams("uxtab16", "Uxtab16", "RegRegRegImmOp",
389 { "code": uxtab16Code,
390 "predicate_test": predicateTest }, [])
391 header_output += RegRegRegImmOpDeclare.subst(uxtab16Iop)
392 decoder_output += RegRegRegImmOpConstructor.subst(uxtab16Iop)
393 exec_output += PredOpExecute.subst(uxtab16Iop)
396 uint64_t rotated = (uint32_t)Op1;
397 rotated = (rotated | (rotated << 32)) >> imm;
398 Dest = (uint16_t)rotated;
400 uxthIop = InstObjParams("uxth", "Uxth", "RegImmRegOp",
402 "predicate_test": predicateTest }, [])
403 header_output += RegImmRegOpDeclare.subst(uxthIop)
404 decoder_output += RegImmRegOpConstructor.subst(uxthIop)
405 exec_output += PredOpExecute.subst(uxthIop)
408 uint64_t rotated = (uint32_t)Op2;
409 rotated = (rotated | (rotated << 32)) >> imm;
410 Dest = (uint16_t)rotated + Op1;
412 uxtahIop = InstObjParams("uxtah", "Uxtah", "RegRegRegImmOp",
414 "predicate_test": predicateTest }, [])
415 header_output += RegRegRegImmOpDeclare.subst(uxtahIop)
416 decoder_output += RegRegRegImmOpConstructor.subst(uxtahIop)
417 exec_output += PredOpExecute.subst(uxtahIop)
420 uint32_t resTemp = 0;
421 for (unsigned i = 0; i < 4; i++) {
424 replaceBits(resTemp, high, low,
425 bits(CondCodes, 16 + i) ?
426 bits(Op1, high, low) : bits(Op2, high, low));
430 selIop = InstObjParams("sel", "Sel", "RegRegRegOp",
432 "predicate_test": condPredicateTest }, [])
433 header_output += RegRegRegOpDeclare.subst(selIop)
434 decoder_output += RegRegRegOpConstructor.subst(selIop)
435 exec_output += PredOpExecute.subst(selIop)
438 uint32_t resTemp = 0;
439 for (unsigned i = 0; i < 4; i++) {
442 int32_t diff = bits(Op1, high, low) -
443 bits(Op2, high, low);
444 resTemp += ((diff < 0) ? -diff : diff);
448 usad8Iop = InstObjParams("usad8", "Usad8", "RegRegRegOp",
450 "predicate_test": predicateTest }, [])
451 header_output += RegRegRegOpDeclare.subst(usad8Iop)
452 decoder_output += RegRegRegOpConstructor.subst(usad8Iop)
453 exec_output += PredOpExecute.subst(usad8Iop)
456 uint32_t resTemp = 0;
457 for (unsigned i = 0; i < 4; i++) {
460 int32_t diff = bits(Op1, high, low) -
461 bits(Op2, high, low);
462 resTemp += ((diff < 0) ? -diff : diff);
464 Dest = Op3 + resTemp;
466 usada8Iop = InstObjParams("usada8", "Usada8", "RegRegRegRegOp",
467 { "code": usada8Code,
468 "predicate_test": predicateTest }, [])
469 header_output += RegRegRegRegOpDeclare.subst(usada8Iop)
470 decoder_output += RegRegRegRegOpConstructor.subst(usada8Iop)
471 exec_output += PredOpExecute.subst(usada8Iop)
473 bkptCode = 'return new PrefetchAbort(PC, ArmFault::DebugEvent);\n'
474 bkptIop = InstObjParams("bkpt", "BkptInst", "PredOp", bkptCode)
475 header_output += BasicDeclare.subst(bkptIop)
476 decoder_output += BasicConstructor.subst(bkptIop)
477 exec_output += BasicExecute.subst(bkptIop)
479 nopIop = InstObjParams("nop", "NopInst", "PredOp", \
480 { "code" : "", "predicate_test" : predicateTest })
481 header_output += BasicDeclare.subst(nopIop)
482 decoder_output += BasicConstructor.subst(nopIop)
483 exec_output += PredOpExecute.subst(nopIop)
485 yieldIop = InstObjParams("yield", "YieldInst", "PredOp", \
486 { "code" : "", "predicate_test" : predicateTest })
487 header_output += BasicDeclare.subst(yieldIop)
488 decoder_output += BasicConstructor.subst(yieldIop)
489 exec_output += PredOpExecute.subst(yieldIop)
496 PseudoInst::quiesce(xc->tcBase());
499 wfeIop = InstObjParams("wfe", "WfeInst", "PredOp", \
500 { "code" : wfeCode, "predicate_test" : predicateTest },
501 ["IsNonSpeculative", "IsQuiesce", "IsSerializeAfter"])
502 header_output += BasicDeclare.subst(wfeIop)
503 decoder_output += BasicConstructor.subst(wfeIop)
504 exec_output += PredOpExecute.subst(wfeIop)
508 PseudoInst::quiesce(xc->tcBase());
511 wfiIop = InstObjParams("wfi", "WfiInst", "PredOp", \
512 { "code" : wfiCode, "predicate_test" : predicateTest },
513 ["IsNonSpeculative", "IsQuiesce"])
514 header_output += BasicDeclare.subst(wfiIop)
515 decoder_output += BasicConstructor.subst(wfiIop)
516 exec_output += PredOpExecute.subst(wfiIop)
519 // Need a way for O3 to not scoreboard these accesses as pipe flushes.
520 System *sys = xc->tcBase()->getSystemPtr();
521 for (int x = 0; x < sys->numContexts(); x++) {
522 ThreadContext *oc = sys->getThreadContext(x);
523 oc->setMiscReg(MISCREG_SEV_MAILBOX, 1);
526 sevIop = InstObjParams("sev", "SevInst", "PredOp", \
527 { "code" : sevCode, "predicate_test" : predicateTest },
528 ["IsNonSpeculative", "IsQuiesce", "IsSerializeAfter"])
529 header_output += BasicDeclare.subst(sevIop)
530 decoder_output += BasicConstructor.subst(sevIop)
531 exec_output += PredOpExecute.subst(sevIop)
533 itIop = InstObjParams("it", "ItInst", "PredOp", \
534 { "code" : "Itstate = machInst.newItstate;",
535 "predicate_test" : predicateTest },
536 ["IsNonSpeculative", "IsSerializeAfter"])
537 header_output += BasicDeclare.subst(itIop)
538 decoder_output += BasicConstructor.subst(itIop)
539 exec_output += PredOpExecute.subst(itIop)
542 return new UndefinedInstruction;
544 return new UndefinedInstruction(machInst, true);
547 unknownIop = InstObjParams("unknown", "Unknown", "UnknownOp", \
548 { "code": unknownCode,
549 "predicate_test": predicateTest })
550 header_output += BasicDeclare.subst(unknownIop)
551 decoder_output += BasicConstructor.subst(unknownIop)
552 exec_output += PredOpExecute.subst(unknownIop)
555 Dest = bits(Op1, imm2, imm1);
557 ubfxIop = InstObjParams("ubfx", "Ubfx", "RegRegImmImmOp",
559 "predicate_test": predicateTest }, [])
560 header_output += RegRegImmImmOpDeclare.subst(ubfxIop)
561 decoder_output += RegRegImmImmOpConstructor.subst(ubfxIop)
562 exec_output += PredOpExecute.subst(ubfxIop)
565 int32_t resTemp = bits(Op1, imm2, imm1);
566 Dest = resTemp | -(resTemp & (1 << (imm2 - imm1)));
568 sbfxIop = InstObjParams("sbfx", "Sbfx", "RegRegImmImmOp",
570 "predicate_test": predicateTest }, [])
571 header_output += RegRegImmImmOpDeclare.subst(sbfxIop)
572 decoder_output += RegRegImmImmOpConstructor.subst(sbfxIop)
573 exec_output += PredOpExecute.subst(sbfxIop)
576 Dest = Op1 & ~(mask(imm2 - imm1 + 1) << imm1);
578 bfcIop = InstObjParams("bfc", "Bfc", "RegRegImmImmOp",
580 "predicate_test": predicateTest }, [])
581 header_output += RegRegImmImmOpDeclare.subst(bfcIop)
582 decoder_output += RegRegImmImmOpConstructor.subst(bfcIop)
583 exec_output += PredOpExecute.subst(bfcIop)
586 uint32_t bitMask = (mask(imm2 - imm1 + 1) << imm1);
587 Dest = ((Op1 << imm1) & bitMask) | (Dest & ~bitMask);
589 bfiIop = InstObjParams("bfi", "Bfi", "RegRegImmImmOp",
591 "predicate_test": predicateTest }, [])
592 header_output += RegRegImmImmOpDeclare.subst(bfiIop)
593 decoder_output += RegRegImmImmOpConstructor.subst(bfiIop)
594 exec_output += PredOpExecute.subst(bfiIop)
598 if (cpsr.mode == MODE_USER)
600 return new UndefinedInstruction;
602 return new UndefinedInstruction(false, mnemonic);
607 mrc15Iop = InstObjParams("mrc", "Mrc15", "RegRegOp",
609 "predicate_test": predicateTest }, [])
610 header_output += RegRegOpDeclare.subst(mrc15Iop)
611 decoder_output += RegRegOpConstructor.subst(mrc15Iop)
612 exec_output += PredOpExecute.subst(mrc15Iop)
617 if (cpsr.mode == MODE_USER)
619 return new UndefinedInstruction;
621 return new UndefinedInstruction(false, mnemonic);
625 mcr15Iop = InstObjParams("mcr", "Mcr15", "RegRegOp",
627 "predicate_test": predicateTest },
628 ["IsSerializeAfter","IsNonSpeculative"])
629 header_output += RegRegOpDeclare.subst(mcr15Iop)
630 decoder_output += RegRegOpConstructor.subst(mcr15Iop)
631 exec_output += PredOpExecute.subst(mcr15Iop)
633 mrc15UserIop = InstObjParams("mrc", "Mrc15User", "RegRegOp",
634 { "code": "Dest = MiscOp1;",
635 "predicate_test": predicateTest }, [])
636 header_output += RegRegOpDeclare.subst(mrc15UserIop)
637 decoder_output += RegRegOpConstructor.subst(mrc15UserIop)
638 exec_output += PredOpExecute.subst(mrc15UserIop)
640 mcr15UserIop = InstObjParams("mcr", "Mcr15User", "RegRegOp",
641 { "code": "MiscDest = Op1",
642 "predicate_test": predicateTest },
643 ["IsSerializeAfter","IsNonSpeculative"])
644 header_output += RegRegOpDeclare.subst(mcr15UserIop)
645 decoder_output += RegRegOpConstructor.subst(mcr15UserIop)
646 exec_output += PredOpExecute.subst(mcr15UserIop)
652 enterxIop = InstObjParams("enterx", "Enterx", "PredOp",
653 { "code": enterxCode,
654 "predicate_test": predicateTest }, [])
655 header_output += BasicDeclare.subst(enterxIop)
656 decoder_output += BasicConstructor.subst(enterxIop)
657 exec_output += PredOpExecute.subst(enterxIop)
663 leavexIop = InstObjParams("leavex", "Leavex", "PredOp",
664 { "code": leavexCode,
665 "predicate_test": predicateTest }, [])
666 header_output += BasicDeclare.subst(leavexIop)
667 decoder_output += BasicConstructor.subst(leavexIop)
668 exec_output += PredOpExecute.subst(leavexIop)
675 setendIop = InstObjParams("setend", "Setend", "ImmOp",
676 { "code": setendCode,
677 "predicate_test": predicateTest },
678 ["IsSerializeAfter","IsNonSpeculative"])
679 header_output += ImmOpDeclare.subst(setendIop)
680 decoder_output += ImmOpConstructor.subst(setendIop)
681 exec_output += PredOpExecute.subst(setendIop)
684 unsigned memAccessFlags = Request::CLEAR_LL |
685 ArmISA::TLB::AlignWord | Request::LLSC;
686 fault = xc->read(0, (uint32_t&)Mem, memAccessFlags);
688 clrexIop = InstObjParams("clrex", "Clrex","PredOp",
690 "predicate_test": predicateTest },[])
691 header_output += ClrexDeclare.subst(clrexIop)
692 decoder_output += BasicConstructor.subst(clrexIop)
693 exec_output += PredOpExecute.subst(clrexIop)
694 exec_output += ClrexInitiateAcc.subst(clrexIop)
695 exec_output += ClrexCompleteAcc.subst(clrexIop)
699 isbIop = InstObjParams("isb", "Isb", "PredOp",
701 "predicate_test": predicateTest}, ['IsSerializing'])
702 header_output += BasicDeclare.subst(isbIop)
703 decoder_output += BasicConstructor.subst(isbIop)
704 exec_output += PredOpExecute.subst(isbIop)
708 dsbIop = InstObjParams("dsb", "Dsb", "PredOp",
710 "predicate_test": predicateTest},['IsMemBarrier'])
711 header_output += BasicDeclare.subst(dsbIop)
712 decoder_output += BasicConstructor.subst(dsbIop)
713 exec_output += PredOpExecute.subst(dsbIop)
717 dmbIop = InstObjParams("dmb", "Dmb", "PredOp",
719 "predicate_test": predicateTest},['IsMemBarrier'])
720 header_output += BasicDeclare.subst(dmbIop)
721 decoder_output += BasicConstructor.subst(dmbIop)
722 exec_output += PredOpExecute.subst(dmbIop)
726 dbgIop = InstObjParams("dbg", "Dbg", "PredOp",
728 "predicate_test": predicateTest})
729 header_output += BasicDeclare.subst(dbgIop)
730 decoder_output += BasicConstructor.subst(dbgIop)
731 exec_output += PredOpExecute.subst(dbgIop)
734 uint32_t mode = bits(imm, 4, 0);
735 uint32_t f = bits(imm, 5);
736 uint32_t i = bits(imm, 6);
737 uint32_t a = bits(imm, 7);
738 bool setMode = bits(imm, 8);
739 bool enable = bits(imm, 9);
742 if (cpsr.mode != MODE_USER) {
748 if (f && !sctlr.nmfi) cpsr.f = 1;
758 cpsIop = InstObjParams("cps", "Cps", "ImmOp",
760 "predicate_test": predicateTest },
761 ["IsSerializeAfter","IsNonSpeculative"])
762 header_output += ImmOpDeclare.subst(cpsIop)
763 decoder_output += ImmOpConstructor.subst(cpsIop)
764 exec_output += PredOpExecute.subst(cpsIop)