Search code examples
llvmptx

NVPTX opcode to hexcode in LLVM


In LLVM, when a CUDA source file is compiled into PTX file, opcodes are generated. Now which section on LLVM converts these opcodes in PTX file to binary (hexcode) (i.e the final executable). Searching the llvm/lib/Target/NVPTX didn't give an answer to this.


Solution

  • Normally this would be in NVPTXInstrInfo.td though it looks like they have assembly mnemonics specified but not encoding bits. Usually this means LLVM isn't doing the assembling and this is instead passed to an external assembler.

    You can look at HexagonInstrInfo.td to see what encoding bits would look like. Search for "let Inst{"