Comments (7)
num
crate doesn't look like it could help but typenum
defines types for a lot of int sizes. So we could probably use those for custom width types: IntValue<U9>
, IntType<I30>
along with the builtins: IntType<u32>
, etc. Also, I don't think LLVM supports custom width floats (at least not in 3.7) so those would only use builtins, though there's no f16
or f128
yet.
from inkwell.
Also, it seems like signed types should be explicit, though LLVM doesn't make this distinction.
from inkwell.
It's worth noting StructTypes (and probably StructValues) have two interesting properties:
- Can be opaque, that is, no body yet set, which is useful for recursive types. So we need something like
StructType<Opaque>
. This should allow us to implement aset_body
for only forStructType<Opaque>
- StructTypes need a variable number of types. Not sure what kind of support rust has for variable sized tuples, but knowing variable sized arrays, I don't expect it to be great. Need to be able to express something like
StructType<(A, B, C, D, ..., Z)>
from inkwell.
After looking at #32, it seems that build_global_string
and related build_global_string_ptr
methods segfault when called without an active function being built on for some reason (even though the string is global 👀). One possible solution would be to have a subtype for a builder in the context of a function, ie Builder<Global>
& Builder<Function>
similarly to how librustc_trans has two methods for creating builders (global and function scoped): https://github.com/rust-lang/rust/blob/master/src/librustc_trans/builder.rs#L54-L77
Those two methods could be implemented for only the latter Builder Function subtype.
from inkwell.
I know gtk-rs encountered a similar problem when emulating inheritance in Rust. They came up with an IsA trait which lets you use a child class as its parent.
So you might write a function that takes anything which IsA<IntType>
, allowing you to accept a u32
, i64
, etc.
from inkwell.
Inkwell use to have something like that, however the issue was primarily that the trait would require you to assume the global context which may not always be desired and wasn't super intuitive (why does u64
suddenly have the global context even though my other types have been working with my non global context?)
from inkwell.
We're going to want Builder
subtypes, as an unpositioned builder can cause segfaults in many scenarios.
from inkwell.
Related Issues (20)
- Couldn't compile HOT 5
- Unable to Access Context Dynamically in LLVMManager: Seeking Alternative Approach HOT 2
- `InstructionValue::new` is `pub(crate)` instead of `pub` HOT 2
- Segfaults when builder is called without setting its position first HOT 5
- Add llvm-sys linkage flags
- Question: How to use LLVM `type`? HOT 5
- More examples? HOT 6
- Question: Is there a way to get the BasicValueEnum from the name of the instruction. HOT 6
- Question: What does `get_insert_block` returns. HOT 2
- Question: How can I get all defined structures? HOT 2
- Question: How to get the size of a type during LLVM generation? HOT 4
- Add `typos` to CI
- Create new fine-grained enum for `build_cast` HOT 1
- How to link library to jit? HOT 2
- Support llvm 17 HOT 1
- Add support for `global_ctor` HOT 4
- Add support for `global_ctor` HOT 3
- ORC support HOT 1
- Const struct member access HOT 1
- Segfault when using `module.create_jit_execution_engine()` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inkwell.