8 ms·
Also Rust uses strings for asm. It can't be bad.
by Tinfoilhat666 7y ago
Also Rust uses strings for asm. It can't be bad.
- jashmatthews 7y agoRust stdlib uses strings because it's just piping through to LLVM and that's what LLVM expects: http://llvm.org/docs/LangRef.html#inline-assembler-expressions http://llvm.org/docs/LangRef.html#inline-assembler-expressio... There's also a Rust version of Dynasm.
- steveklabnik 7y agoIt’s a fairly major point of contention, and we may not keep it. Note that it’s not a stable feature yet. As pointed out below, it’s this way because it’s basically a convenience into LLVM.
- tropo 7y agoKeep it. Porting to rust is easier if it doesn't require a person to be an expert at two different kinds of inline assembly syntax. Being able to grab a chunk of inline assembly from a C project is very useful. Whatever you do, don't embed knowledge of the assembly language into the compiler. That way lies madness. Assembly is often used for new CPU features that are not yet supported by the compilers that people are using. Constantly putting out minor compiler updates for every CPU revision would be miserable, and the users won't want to force those upgrades anyway. There is also the issue, I'm sorry, of the rust preprocessor. It will be written and it will be used. It may even be popular and ultimately written into an ISO standard. The irregularity of switching suddenly to a radically different CPU-specific syntax for assembly code would make the preprocessor situation much more nasty and gross.
- cesarb 7y ago> Being able to grab a chunk of inline assembly from a C project is very useful. Wasn't Rust's current inline assembly syntax subtly different from the gcc-compatible one you'd find in most C projects? IIRC, it uses the syntax from the LLVM IR to specify inputs and outputs, instead of the syntax from GCC inline assembly.
- pjmlp 7y agoUnisys ClearPath MCP, the modern version of the Burroughs linage never supported any kind of Assembly, instead it was the first high level systems programming language to use compiler intrinsics, in 1961. The same path that Microsoft has decided to follow since they introduced 64 bit support. Compiler intrinsics. Also copy paste inline Assembly from C into Rust only works for a specific C compiler.
- steveklabnik 7y ago> Porting to rust is easier if it doesn't require a person to be an expert at two different kinds of inline assembly syntax. Sadly, this doesn't save you from that, in fact, it can be argued that the string syntax is what makes you need to learn a whole second set of syntax. This is due to clobbers. > There is also the issue, I'm sorry, of the rust preprocessor. It will be written and it will be used. I don't forsee this happening; Rust has powerful enough generic capabilities that even with tens of millions of lines of Rust existing today (I'd actually guess we're in the hundreds right now, but still), nobody has invented one yet. Getting away from the pre-processor is considered a pro, not a con.
- pjmlp 7y ago> Getting away from the pre-processor is considered a pro, not a con. Yep, even ISO C++ is putting energy into making each standard revision one reason less to use it.
- jcelerier 7y ago> nobody has invented one yet. no need to invent one when cpp exists and works. I've seen people use it in Java, and it is sometimes used in unix config files (e.g. .Xresources).
- steveklabnik 7y agoSure; I'm not aware of anybody using cpp with Rust either.