rust/compiler/rustc_codegen_llvm/src
Mara Bos 76fa5f25ab
Rollup merge of #78950 - khyperia:spirv-asm, r=Amanieu
Add asm register information for SPIR-V

As discussed in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Defining.20asm!.20for.20new.20architecture), we at [rust-gpu](https://github.com/EmbarkStudios/rust-gpu) would like to support `asm!` for our SPIR-V backend. However, we cannot do so purely without frontend support: [this match](d4ea0b3e46/compiler/rustc_target/src/asm/mod.rs (L185)) fails and so `asm!` is not supported ([error reported here](d4ea0b3e46/compiler/rustc_ast_lowering/src/expr.rs (L1095))). To resolve this, we need to stub out register information for SPIR-V to support getting the `asm!` content all the way to [`AsmBuilderMethods::codegen_inline_asm`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/traits/trait.AsmBuilderMethods.html#tymethod.codegen_inline_asm), at which point the rust-gpu backend can do all the parsing and codegen that is needed.

This is a pretty weird PR - adding support for a backend that isn't in-tree feels pretty gross to me, but I don't see an easy way around this. ``@Amanieu`` said I should submit it anyway, so, here we are! Let me know if this needs to go through a more formal process (MCP?) and what I should do to help this along.

I based this off the [wasm asm PR](https://github.com/rust-lang/rust/pull/78684), which unfortunately this PR conflicts with that one quite a bit, sorry for any merge conflict pain :(

---

Some open questions:

- What do we call the register class? Some context, SPIR-V is an SSA-based IR, there are "instructions" that create IDs (referred to as `<id>` in the spec), which can be referenced by other instructions. So, `reg` isn't exactly accurate, they're SSA IDs, not re-assignable registers.
- What happens when a SPIR-V register gets to the LLVM backend? Right now it's a `bug!`, but should that be a `sess.fatal()`? I'm not sure if it's even possible to reach that point, maybe there's a check that prevents the `spirv` target from even reaching that codepath.
2020-11-12 19:46:14 +01:00
..
back Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
coverageinfo Addressed all feedback to date 2020-11-05 18:24:17 -08:00
debuginfo Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
llvm Rollup merge of #77950 - arlosi:sha256, r=eddyb 2020-11-03 19:32:26 +01:00
abi.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
allocator.rs Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
asm.rs Change capitalization of Spirv to SpirV 2020-11-11 19:18:06 +01:00
attributes.rs rustc_target: Rename some target options to avoid tautology 2020-11-08 17:29:13 +03:00
base.rs Replace target.target with target and target.ptr_width with target.pointer_width 2020-10-15 12:02:24 +02:00
builder.rs Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
callee.rs rustc_target: Rename some target options to avoid tautology 2020-11-08 17:29:13 +03:00
common.rs s/Scalar::Raw/Scalar::Int 2020-11-04 10:11:31 +00:00
consts.rs Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
context.rs Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
declare.rs Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
intrinsic.rs Changed unwrap_or to unwrap_or_else in some places. 2020-11-10 20:07:47 -08:00
lib.rs Rollup merge of #77795 - bjorn3:codegen_backend_interface_refactor, r=oli-obk 2020-10-14 02:30:38 +02:00
llvm_util.rs rustc_target: Rename some target options to avoid tautology 2020-11-08 17:29:13 +03:00
metadata.rs Collapse all uses of target.options.foo into target.foo 2020-11-08 17:29:13 +03:00
mono_item.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
type_.rs Remove MMX from Rust 2020-09-20 15:13:11 +02:00
type_of.rs Remove MMX from Rust 2020-09-20 15:13:11 +02:00
va_arg.rs rustc_target: Rename some target options to avoid tautology 2020-11-08 17:29:13 +03:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00