<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68831>68831</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
pacg Instructin instrumentation in llc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Tomal-kuet
</td>
</tr>
</table>
<pre>
I am trying to instrument **pacg** instruction with llvm back-end with the following code:
```
MIB = BuildMI(MBB, MI, DL, TII.get(ARM::t2PACG)).addReg(ARM::R1).addReg(ARM::R0).addReg(ARM::R2)
.add(predOps(ARMCC::AL)).setMIFlag(MachineInstr::NoFlags);
```
From, the ARMInstrThumb2.td file the definition for **pacg** is:
```
// PACBTI
let Predicates = [IsThumb2, HasV8_1MMainline, HasPACBTI] in {
def t2PACG : V8_1MI<(outs rGPR:$Rd),
(ins pred:$p, GPRnopc:$Rn, GPRnopc:$Rm),
AddrModeNone, NoItinerary, "pacg${p}", "$Rd, $Rn, $Rm", "", []> {
bits<4> Rd;
bits<4> Rn;
bits<4> Rm;
let Inst{31-20} = 0b111110110110;
let Inst{19-16} = Rn;
let Inst{15-12} = 0b1111;
let Inst{11-8} = Rd;
let Inst{7-4} = 0b0000;
let Inst{3-0} = Rm;
}
```
I get the following error:
```
llc: ../llvm-project/llvm/include/llvm/MC/MCInst.h:81: int64_t llvm::MCOperand::getImm() const: Assertion `isImm() && "This is not an immediate"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llc -march=arm -mcpu=cortex-m85 out.ll -o outm_pass.s
1. Running pass 'Function Pass Manager' on module 'out.ll'.
2. Running pass 'ARM Assembly Printer' on function '@factorial'
```
The **pacg** instruction of ARMv8.1-M works with three general-purpose registers, why the ARM Assembly Printer pass is asserting for immediate?
I also printed the textual assembly from LLVM IR which shows as: `t2PACG $r1, $r0, $r2, 14, $noreg`
I guess there is something wrong with the parameters of BuildMI, please suggest to me your valuable thoughts. Thank you.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVl-P4jgS_zTmpUSUOPwJDzwEGOaQOrOIbe3ryEmKxNeOHdnOsP3tT-WEoXeGvpMOociuKv_qf9nCOdloxC1b7tjyMBODb43dvppOqPnbgH5Wmvp9ewLRgbfvUjfgDUjtvB061B4YzxnPe1E142riVV4aDTfpW1DqRwelqN7mqOuR5FuEq1HK3AiwMjWyNGfxgcU5W8XTP2yL0w5YeoDdIFVdnBjPit2O8T3Qeg-HF_q-nk5Rg57xLL8UhJTmnp_z_VfGN4xvIlHXF2w-si_JJ_T4EzonqGAREJvxrLdY_9G7UWq_H-Xyl0mlQ1-cjkoQSiGqVmo8UWBGsW-GWI5k091Tv4_WdOQaRSq_FOHsazt0JY98DVepMLBqvEotQ6yvxj5JhvsssIwfGT_COd_vXk8jSaGHs8VaVsKjC2Fny93JjXrJmn8J91f2PSkKIbWSGifaBLI8gNTA1pNHNV5hTAOwNIdw8MTSPeOZGbwD-_V8Iev44lKHqO2nAD_5MZ5J7YBiPh7pSfXX80WbvppA9O-k7n_h5nVtC1PjNzM6882cvNRohX2nLeN8DOaCrXc9Wx8Y5xN9MpvWk-pJ4UNgXIW-YumXR2AASukdS_cLIl_qnzXwC0N_xug-MChpVB1svUuTOY_Z-hAyF5cJ_eLx__xAspknq_uBf6j7KLScJ_yfqA_Bj3LJPCOxEax-DraeL4LMBBbH8SempfP4IfjBYcrBs3I-QYP-l7mC1hr7Wf0rRUUCUcT4kSbUvLfm31j5acv4UepKDTU-CMU-fMjCqGVpniWEILVfLb77MObG7i72f_Roha7HbYP-1HWMZ4xvoDLkX5pD7hza0LhsFUv3kGB8xfiKKui1lQ6kA208CA2y67CWwmOorDVchVRYR6M755cv-Z9fwA1lJz0IKIcGLPbGeprXrfd9mASh6Rvp26GMKpowd99-CYF0bkBHA0LoGqZIhPBWVrg2jHNvRYWT-j-9qN6gH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