Is there a simple way to just change the opcode of a machine instruction. I have a lot of long/short pairs where when I know the offset, i can replace the long version with the short version. Tia. REed
----- Original Message -----> From: "reed kotler" <rkotler at mips.com> > To: llvmdev at cs.uiuc.edu > Sent: Wednesday, February 13, 2013 6:00:45 PM > Subject: [LLVMdev] changing opcode > > Is there a simple way to just change the opcode of a machine > instruction. > > I have a lot of long/short pairs where when I know the offset, i can > replace the long version with the short version.Are you looking for something like this: MI.setDesc(TII.get(NewOpcode)); This is in PPCRegisterInfo::eliminateFrameIndex. -Hal> > Tia. > > REed > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Wed, Feb 13, 2013 at 7:00 PM, reed kotler <rkotler at mips.com> wrote:> Is there a simple way to just change the opcode of a machine instruction. > > I have a lot of long/short pairs where when I know the offset, i can > replace the long version with the short version. >Hey Reed, The x86 target does something like this. Check out ReplaceableInstrs inlib/Target/X86/X86InstrInfo.cpp. Hope that helps, Cameron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130213/09a36415/attachment.html>
On 02/13/2013 04:06 PM, Hal Finkel wrote:> ----- Original Message ----- >> From: "reed kotler" <rkotler at mips.com> >> To: llvmdev at cs.uiuc.edu >> Sent: Wednesday, February 13, 2013 6:00:45 PM >> Subject: [LLVMdev] changing opcode >> >> Is there a simple way to just change the opcode of a machine >> instruction. >> >> I have a lot of long/short pairs where when I know the offset, i can >> replace the long version with the short version. > Are you looking for something like this: > MI.setDesc(TII.get(NewOpcode)); > > This is in PPCRegisterInfo::eliminateFrameIndex.Not sure. I want to change the instruction. Maybe opcode was the wrong word for me to use. AddiuX16 to Addiu16 They are basically the same except that one is a 32 bit instruction and one is a 16 bit instruction.> -Hal > >> Tia. >> >> REed >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>
That looks right. Thanks! On 02/13/2013 04:06 PM, Hal Finkel wrote:> ----- Original Message ----- >> From: "reed kotler" <rkotler at mips.com> >> To: llvmdev at cs.uiuc.edu >> Sent: Wednesday, February 13, 2013 6:00:45 PM >> Subject: [LLVMdev] changing opcode >> >> Is there a simple way to just change the opcode of a machine >> instruction. >> >> I have a lot of long/short pairs where when I know the offset, i can >> replace the long version with the short version. > > Are you looking for something like this: > MI.setDesc(TII.get(NewOpcode)); > > This is in PPCRegisterInfo::eliminateFrameIndex. > > -Hal > >> >> Tia. >> >> REed >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>
Nice idea using the table. On 02/13/2013 04:12 PM, Cameron McInally wrote:> On Wed, Feb 13, 2013 at 7:00 PM, reed kotler <rkotler at mips.com > <mailto:rkotler at mips.com>> wrote: > > Is there a simple way to just change the opcode of a machine > instruction. > > I have a lot of long/short pairs where when I know the offset, i can > replace the long version with the short version. > > > Hey Reed, > > > The x86 target does something like this. Check out ReplaceableInstrs > inlib/Target/X86/X86InstrInfo.cpp. > > > Hope that helps, > > Cameron > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >