Hi,
Does anyone tell which file whose emit the llvm assembly file (.ll), I want to modify for specific use.
Thank you all
Kinds
Hi,
Does anyone tell which file whose emit the llvm assembly file (.ll), I want to modify for specific use.
Thank you all
Kinds
The primary representation of LLVM IR is the llvm::Module class in
memory. That class has two representations on disk: .ll (textual) and
.bc (binary). If you want to add something non-trivial to the llvm IR
(or change it) then you need to change all 5 places implied by that:
+ Add it to the llvm::Module in-memory representation
+ Add support for writing a .ll file in lib/IR/AsmWriter.cpp (probably)
+ Add support for reading a .ll file in lib/AsmParser
+ Add support for writing a .bc file in lib/Bitcode/Writer
+ Add support for reading a .bc file in lib/Bitcode/Reader
Before thinking about upstreaming you'll also need documentation in
docs/LangRef.rst, and tests of course. But those aren't needed for
basic proof of concept work.
Cheers.
Tim.
Hi Mohamed,
(Adding llvm-dev back to record the conversation).
We can see that in V5.0 change the the name with numbers %i.017 >> %3 , %k.016 >> %4 & %add >> %7.
I just want to have the name in .ll file that generated from V5.0, any idea how to fix that?
This is actually a difference between debug and release builds of
LLVM. Release builds are configured to drop all names for efficiency,
but debug builds keep them. So you need to rebuild LLVM with (I think)
-DLLVM_ENABLE_ASSERTIONS=ON.
Of course, the actual IR and names will still be different, and likely
in incompatible ways. The bitcode format is more stable, and LLVM-5.0
should be able to read .bc files generated by LLVM 3.8 (though not the
other way round).
Cheers.
Tim.