mozilla/rust — pull request #7182 by Aatch (2013-06-16 12:25:38+00:00)
Title: Trans Refactor: Episode 2

This is another big refactoring of `trans` though this is unlikely to have much of an
impact on code size or speed.

The major change here is the implementation of a `Type` struct which is the new
home for all your LLVM `TypeRef` needs. It's a simple wrapper struct, with static
methods for constructing types, then regular methods for manipulating/interrogating them. The purpose of this is mostly to make the code surrounding them somewhat
more ideomatic. A line like: `T_ptr(T_ptr(T_i8()))` is now `Type::i8().ptr_to().ptr_to()`,
which is much more like regular Rust code.

Another big (and potentially controversial) change is the removal of the code for the `count-llvm-insns` debugging option. I've never found it useful when trying to
investigate compiler issues and it was a major blocker removing more of the
`@mut CrateContext` parameters in trans.

There are a variety of smaller changes here and there:

* Remove address spaces. At least it doesn't generate them, I haven't spent much
time looking for related code.
* Use a macro for declaring the LLVM intrinsics, makes it look much nicer.
* Make the type for a string slice actually create a named `str_slice` type in LLVM,
this makes reading the appropriate code much easier.
* Change the way struct and enum type names are generated. This just means
that a struct like `struct Foo { a: int }` now produces the IR
`%struct.Foo = type { i64 }`, which is much easier to read. Similarly, other structs
are a bit tighter to make it easier to read.

--- --- ---

This PR did get away from me a little, as I occasionally got distracted or as I fixed
up problems with unrelated code that were stopping me from continuing. One major
thing is that this PR contains the work from #7168, since that would have conflicted
with this and it was broken anyway. Sorry for bundling it like this.

Fixes #3670 and #7063