soroosh khoram via llvm-dev
2016-Oct-30 21:33 UTC
[llvm-dev] Adding assembly instructions to LLVM
Hi, As part of a project I need to compile C code for a new architecture that is based on x86 with some new instructions. In my C code I'm going to use inline assembly, so the only thing I need from LLVM is to recognize the instruction and put it in the binary in the right place with correct input values/register addresses. I tried to add a simple ADD instruction, following the instructions in http://llvm.org/docs/ExtendingLLVM.html#adding-a-new-instruction and just duplicating everything I saw for the ADD instruction for my instruction. The problem is that this page doesn't explain where I should add the opcode for my instruction. I've been reading the documents and the source code for several days now and I feel kind of lost right now. I was hoping someone here could point me to the right direction. Thank you Soroosh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161030/a26f0079/attachment.html>
Joerg Sonnenberger via llvm-dev
2016-Oct-30 21:51 UTC
[llvm-dev] Adding assembly instructions to LLVM
On Sun, Oct 30, 2016 at 04:33:08PM -0500, soroosh khoram via llvm-dev wrote:> I've been reading the documents and the source code for several days now > and I feel kind of lost right now. I was hoping someone here could point me > to the right direction.The expansion for add on x86 starts in lib/Targets/X86/X86InstrArithmethic.td, line 1197 (defm ADD) and involves somewhat complicated multiclassing to deal with various operand combinations. A better starting point is likely the "test" family, line 1223ff. Joerg
John Criswell via llvm-dev
2016-Oct-31 00:44 UTC
[llvm-dev] Adding assembly instructions to LLVM
On 10/30/16 5:33 PM, soroosh khoram via llvm-dev wrote:> Hi, > > As part of a project I need to compile C code for a new architecture > that is based on x86 with some new instructions. In my C code I'm > going to use inline assembly, so the only thing I need from LLVM is to > recognize the instruction and put it in the binary in the right place > with correct input values/register addresses.If you already have an assembler that recognizes your new instruction, it may be easier to use the -no-integrated-as argument on the clang command line and have it use the assembler that supports the instruction. If there is no assembler that understands your new instructions, then enhancing LLVM's code generator/internal assembler/internal disassembler is probably a good way to go. Regards, John Criswell> > I tried to add a simple ADD instruction, following the instructions in > http://llvm.org/docs/ExtendingLLVM.html#adding-a-new-instruction and > just duplicating everything I saw for the ADD instruction for my > instruction. The problem is that this page doesn't explain where I > should add the opcode for my instruction. > > I've been reading the documents and the source code for several days > now and I feel kind of lost right now. I was hoping someone here could > point me to the right direction. > > Thank you > Soroosh > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161030/22efa69d/attachment.html>
Possibly Parallel Threads
- [Bug 98506] New: Pagefault in gf100_vm_flush
- [LLVMdev] Adding a New Instruction to LLVM IR
- Adding new a new type
- LLVM IR intrinsics placeholder for strings [was Re: Back end with special loop instructions (using LLVM IR intrinsics)]
- Adding a NOP bitcode instruction