TomBebbington / llvm-rs

LLVM wrappers for Rust
BSD 3-Clause "New" or "Revised" License
68 stars 27 forks source link

Implement more functionality for globals + more #7

Closed HeroesGrave closed 8 years ago

HeroesGrave commented 9 years ago

First commit fixes the warnings about the new object safety rules. I hope I fixed it correctly. If not, you (or I) can delete that commit.

Second commit implements more functionality for globals.

All of these dereference into a new type, GlobalValue, which in turn, dereferences into a Value.

Module.add_global_constant() has been removed in favour of Module.add_global_variable(), which can optionally be set to a constant by calling GlobalVariable.set_constant(true). The old behaviour didn't set it to constant anyway, so this breaking change has the benefit of alerting people as to whether their globals should be constant or not.

Global variables/constants can also have their initialiser changed through GlobalVariable.set_initializer() (or you can obtain the value through GlobalVariable.get_initializer())

All global values can have their linkage type changed through the GlobalValue.set_linkage() function using the new Linkage enum.

Also added Module.add_global_in_address_space(), which takes an argument of the new AddressSpace enum.

Some tests are probably needed but I'm too busy over the next few days. As far as I've used the new functionality, it works correctly.

HeroesGrave commented 9 years ago

Travis seems to be having problems with llvm-config.

TomBebbington commented 8 years ago

Good idea with how you handled the values and sorry for the late pull.