Skip to content

Commit

Permalink
Remove TypeBuilder.h, and fix the few locations using it.
Browse files Browse the repository at this point in the history
This shortcut mechanism for creating types was added 10 years ago, but
has seen almost no uptake since then, neither internally nor in
external projects.

The very small number of characters saved by using it does not seem
worth the mental overhead of an additional type-creation API, so,
delete it.

Differential Revision: https://reviews.llvm.org/D56573

llvm-svn: 351020
  • Loading branch information
jyknight committed Jan 13, 2019
1 parent 06e3950 commit c004411
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 831 deletions.
8 changes: 0 additions & 8 deletions llvm/docs/ExtendingLLVM.rst
Expand Up @@ -253,10 +253,6 @@ Adding a fundamental type
add enum ``LLVMTypeKind`` and modify
``LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)`` for the new type

#. ``llvm/include/llvm/IR/TypeBuilder.h``:

add new class to represent new type in the hierarchy

#. ``llvm/lib/AsmParser/LLLexer.cpp``:

add ability to parse in the type from text assembly
Expand Down Expand Up @@ -299,10 +295,6 @@ Adding a derived type
add enum ``LLVMTypeKind`` and modify
`LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)` for the new type

#. ``llvm/include/llvm/IR/TypeBuilder.h``:

add new class to represent new class in the hierarchy

#. ``llvm/lib/AsmParser/LLLexer.cpp``:

modify ``lltok::Kind LLLexer::LexIdentifier()`` to add ability to
Expand Down
31 changes: 0 additions & 31 deletions llvm/docs/ProgrammersManual.rst
Expand Up @@ -2905,37 +2905,6 @@ For example:
GV->eraseFromParent();


.. _create_types:

How to Create Types
-------------------

In generating IR, you may need some complex types. If you know these types
statically, you can use ``TypeBuilder<...>::get()``, defined in
``llvm/Support/TypeBuilder.h``, to retrieve them. ``TypeBuilder`` has two forms
depending on whether you're building types for cross-compilation or native
library use. ``TypeBuilder<T, true>`` requires that ``T`` be independent of the
host environment, meaning that it's built out of types from the ``llvm::types``
(`doxygen <http://llvm.org/doxygen/namespacellvm_1_1types.html>`__) namespace
and pointers, functions, arrays, etc. built of those. ``TypeBuilder<T, false>``
additionally allows native C types whose size may depend on the host compiler.
For example,

.. code-block:: c++

FunctionType *ft = TypeBuilder<types::i<8>(types::i<32>*), true>::get();

is easier to read and write than the equivalent

.. code-block:: c++

std::vector<const Type*> params;
params.push_back(PointerType::getUnqual(Type::Int32Ty));
FunctionType *ft = FunctionType::get(Type::Int8Ty, params, false);
See the `class comment
<http://llvm.org/doxygen/TypeBuilder_8h_source.html#l00001>`_ for more details.

.. _threading:

Threads and LLVM
Expand Down

0 comments on commit c004411

Please sign in to comment.