[llvm-dev] ARM Backend BuildMI operand issues
Tom Stellard via llvm-dev
llvm-dev at lists.llvm.org
Thu Mar 22 16:18:34 PDT 2018
On 03/22/2018 09:29 AM, Julius Hiller via llvm-dev wrote:
> Hello everyone,
>
> I'm working on a MachineFunctionPass that inserts a list of instructions into an Module so a later Pass can work on them.
> To do so I load a dummy .ll file created from a main stub, create the needed function stubs (ModulePass), insert Blocks and create instructions using BuildMI.
> I started with branch instructions:
>
> const TargetMachine &TM = MF.getTarget();
> const MCInstrInfo *TII = TM.getMCInstrInfo();
> DebugLoc DL;
> BuildMI(BB, BB.end(), DL, TII->get(ARM::B)).addMBB(trgBlock);
>
> these are working fine.
> When creating an compare instruction like cmp r0, 1 with:
>
> BuildMI(BB, BB.end(), DL, TII->get(ARM::tCMPi8),0).addImm(1);
>
> I get the following error:
>
> .../include/llvm/MC/MCInst.h:81: int64_t llvm::MCOperand::getImm() const: Assertion `isImm() && "This is not an immediate"' failed.
>
According to ARMInstrThumb.td, tCMPi8's source arguments are reg, imm and
there is no explicit destination register, so what you want is:
BuildMI(BB, BB.end(), DL, TII->get(ARM::tCMPi8)).addReg(ARM::R0).addImm(1);
-Tom
> Which even after hours I can't make sense why the operand kind is wrong.
>
> Another thing I noticed is that using ARM::tB results in the following error:
>
> .../include/llvm/ADT/SmallVector.h:154: const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) const [with T = llvm::MCOperand; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::const_reference = const llvm::MCOperand&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed.
>
> The architecture is ARMv6-m, I am using llvm 7, the dummy.ll was created with llvm 3.9
> Hope to find some help here, best regards
>
> Julius Hiller
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
More information about the llvm-dev
mailing list