Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame^] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
| 2 | "http://www.w3.org/TR/html4/strict.dtd">
|
| 3 | <!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
|
| 4 | <html>
|
| 5 | <head>
|
| 6 | <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
| 7 | <title>Hacking on clang</title>
|
| 8 | <link type="text/css" rel="stylesheet" href="menu.css" />
|
| 9 | <link type="text/css" rel="stylesheet" href="content.css" />
|
| 10 | </head>
|
| 11 | <body>
|
| 12 | <!--#include virtual="menu.html.incl"-->
|
| 13 | <div id="content">
|
| 14 | <!--*********************************************************************-->
|
| 15 | <h1>Hacking on Clang</h1>
|
| 16 | <!--*********************************************************************-->
|
| 17 |
|
| 18 | <p>This document provides some hints for how to get started hacking
|
| 19 | on Clang for developers who are new to the Clang and/or LLVM
|
| 20 | codebases.
|
| 21 | <ul>
|
| 22 | <li><a href="#docs">Developer Documentation</a></li>
|
| 23 | <li><a href="#debugging">Debugging</a></li>
|
| 24 | <li><a href="#irgen">LLVM IR Generation</a></li>
|
| 25 | </ul>
|
| 26 | </p>
|
| 27 |
|
| 28 | <!--=====================================================================-->
|
| 29 | <h2 id="debugging">Developer Documentation</h2>
|
| 30 | <!--=====================================================================-->
|
| 31 |
|
| 32 | <p>Both Clang and LLVM use doxygen to provide API documentation. Their
|
| 33 | respective web pages (generated nightly) are here:
|
| 34 | <ul>
|
| 35 | <li><a href="http://clang.llvm.org/doxygen">Clang</a></li>
|
| 36 | <li><a href="http://llvm.org/doxygen">LLVM</a></li>
|
| 37 | </ul>
|
| 38 | </p>
|
| 39 |
|
| 40 | <p>For work on the LLVM IR generation, the LLVM assembly language
|
| 41 | <a href="http://llvm.org/docs/LangRef.html">reference manual</a> is
|
| 42 | also useful.</p>
|
| 43 |
|
| 44 | <!--=====================================================================-->
|
| 45 | <h2 id="debugging">Debugging</h2>
|
| 46 | <!--=====================================================================-->
|
| 47 |
|
| 48 | <p>Inspecting data structures in a debugger:
|
| 49 | <ul>
|
| 50 | <li>Many LLVM and Clang data structures provide
|
| 51 | a <tt>dump()</tt> method which will print a description of the
|
| 52 | data structure to <tt>stderr</tt>.</li>
|
| 53 | <li>The <a href="docs/InternalsManual.html#QualType"><tt>QualType</tt></a>
|
| 54 | structure is used pervasively. This is a simple value class for
|
| 55 | wrapping types with qualifiers; you can use
|
| 56 | the <tt>isConstQualified()</tt>, for example, to get one of the
|
| 57 | qualifiers, and the <tt>getTypePtr()</tt> method to get the
|
| 58 | wrapped <tt>Type*</tt> which you can then dump.</li>
|
| 59 | </ul>
|
| 60 | </p>
|
| 61 |
|
| 62 | <!--=====================================================================-->
|
| 63 | <h2 id="irgen">LLVM IR Generation</h2>
|
| 64 | <!--=====================================================================-->
|
| 65 |
|
| 66 | <p>The LLVM IR generation part of clang handles conversion of the
|
| 67 | AST nodes output by the Sema module to the LLVM Intermediate
|
| 68 | Representation (IR). Historically, this was referred to as
|
| 69 | "codegen", and the Clang code for this lives
|
| 70 | in <tt>lib/CodeGen</tt>.</p>
|
| 71 |
|
| 72 | <p>The output is most easily inspected using the <tt>-emit-llvm</tt>
|
| 73 | option to clang (possibly in conjunction with <tt>-o -</tt>). You
|
| 74 | can also use <tt>-emit-llvm-bc</tt> to write an LLVM bitcode file
|
| 75 | which can be processed by the suite of LLVM tools
|
| 76 | like <tt>llvm-dis</tt>, <tt>llvm-nm</tt>, etc. See the LLVM
|
| 77 | <a href="http://llvm.org/docs/CommandGuide/">Command Guide</tt>
|
| 78 | for more information.</p>
|
| 79 |
|
| 80 | </div>
|
| 81 | </body>
|
| 82 | </html>
|