I know the llvm-ir has constructs for volatile but I was referring to any optimizations done above the llvm-ir, such as at the AST level. I am not sure what kinds of optimizations Rust currently does, so this might not be an issue.
> If you want the type safety of a volatile type in Rust, you could > define a volatile<T> enum that only allowed access using methods > defined in terms of the volatile primitives. Ya, I was thinking about defining an enum/class/iface for this purpose. -- John Harrison On May 4, 2012, at 1:36 PM, Joe Groff wrote: > On Fri, May 4, 2012 at 1:09 PM, John Harrison > <harr...@tigermail.auburn.edu> wrote: >> Which is not that different, just more explicit, but again I do not know how >> the optimizer would interact with that kind of a statement. It would be nice >> to be able to mark an expression as volatile possibly instead of a variable. > > It should work fine. In LLVM volatile operations are marked at the > load/store level, so it would map to the same IR as volatile accesses > in C would. (LLVM's semantics for volatile operations is documented at > http://llvm.org/docs/LangRef.html#volatile , if you're curious.) Even > in C, I've seen a lot of code that makes volatile load/stores explicit > at the site of the operation with operations of the form 'int x; > *(volatile int*)&x = 1;' in favor of using volatile typed variables. > > If you want the type safety of a volatile type in Rust, you could > define a volatile<T> enum that only allowed access using methods > defined in terms of the volatile primitives. > > -Joe > _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev