Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

documentation missing for how to emit bitcode and machine code #4847

Open Quuxplusone opened 15 years ago

Quuxplusone commented 15 years ago
Bugzilla Link PR4343
Status NEW
Importance P normal
Reported by John Nowak (john@johnnowak.com)
Reported on 2009-06-07 03:31:39 -0700
Last modified on 2010-03-06 13:59:17 -0800
Version trunk
Hardware PC All
CC edwin+bugs@etorok.eu, llvm-bugs@lists.llvm.org, nicholas@mxc.ca
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
[04:21am] johnnowak: where in the documentation does it discuss how to emit
bitcode and machine code?
[04:21am] johnnowak: i can't seem to track it down
[04:22am] ddunbar__: not sure if its in the actual docs
[04:23am] ddunbar__: see include/llvm/Bitcode/ReaderWriter.h though
[04:23am] johnnowak: you'd think discussing how to generate code would be part
of the documentation for a compiler infrastructure
[04:23am] ddunbar__: patches welcome!
[04:23am] ddunbar__: I thought the tutorial covered this stuff though
[04:24am] johnnowak: it doesn't
[04:24am] edwin: opt -load=yourplugin.so input.bc -o output.bc
[04:26am] johnnowak: i'd hope that you wouldn't want people unfamiliar with the
project submitting essential pieces of documentation for basic yet critical
functionality
[04:27am] ddunbar__: johnnowak: file a docs bug if you like
Quuxplusone commented 15 years ago
Do you mean:
 a) when running clang on the command line?
 b) when running llvm-gcc on the command line?
 c) given a .ll (textual LLVM IR) file, on the command line?
 d) from inside your LLVM-using C++ program?

The first three are well documented:
 a) http://clang.llvm.org/get_started.html
 b) http://llvm.org/cmds/llvmgcc.html
 c) i. To bitcode: http://llvm.org/cmds/llvm-as.html (described on http://llvm.org/docs/CommandGuide/ as "assemble a human-readable .ll file into bytecode")
    ii. To machine code: http://llvm.org/cmds/llc.html (described in the command guide as "generate native machine code for a bytecode file")

The last one however, is not.
 d) i. JITing is in the tutorial: http://llvm.org/docs/tutorial/LangImpl4.html#jit
    ii. To bitcode: Look at the source to llvm-as (it's only 149 lines). The important part is WriteBitcodeToFile() which is in the doxygen, but you'd have to know where to look: http://llvm.org/doxygen/namespacellvm.html#e74f76713a63766894166c9a8dd8e94a
    iii. To machine code: Look at the source to llc (364 lines). Sadly there's more than one function call needed to emit machine code.

So clearly that should be documented. But where? Add it to the tutorial? I
can't think of an obvious place this should go.
Quuxplusone commented 15 years ago
(In reply to comment #1)
> So clearly that should be documented. But where? Add it to the tutorial? I
> can't think of an obvious place this should go.
>

http://llvm.org/docs/tutorial/
Simple JIT Tutorials
4. Reading and Writing Bitcode
^ that looks like the obvious place to me.
Quuxplusone commented 15 years ago
(In reply to comment #1)
> Do you mean:
>  d) from inside your LLVM-using C++ program?

Yes, d. Török Edwin's suggestion seems appropriate.