Files
rust/tests/codegen-llvm
Jacob Pratt 9e0b9bc6cd Rollup merge of #158885 - folkertdev:complex-layout, r=workingjubilee
Add `core::num::Complex`

tracking issue: https://github.com/rust-lang/rust/issues/154023

See also [#t-compiler > representing `_Complex`](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/representing.20.60_Complex.60/with/608308993). The RFC states that the `Complex` type should match the ABI of `_Complex` in C, but provides little detail on how to actually achieve this. We concluded that `repr(complex)` is probably the best approach. Like clang, that means we "desugar" the representation early: `_Complex` is not natively represented in LLVM IR.

I've derived the ABI from `clang` for 28 targets, a decent sample of what we actually support. For now I'm only actually testing `x86_64` because (as you'll see) updating the tests is quite labor-intensive. If we're happy with this direction I can fill more of them in, likely in a separate PR.

The libs side of the type is very bare-bones: I'm not as interested in that part. Others can fill in the various instances, methods, write tests for those, and improve the docs.

r? workingjubilee
2026-08-13 18:16:12 -04:00
..
2026-07-16 16:35:37 +02:00
2026-07-22 11:42:09 +02:00
2026-06-15 00:56:07 +00:00
2026-06-04 15:19:24 +02:00
2026-08-05 13:45:49 +02:00
…
2026-06-04 15:19:24 +02:00
2026-07-22 11:42:09 +02:00
2026-07-22 11:42:09 +02:00
2026-07-13 10:54:53 +02:00
2026-08-13 19:32:19 +02:00
…
2026-07-13 10:54:53 +02:00
2026-06-04 15:19:24 +02:00
2026-05-04 15:35:40 +02:00
2026-04-14 03:25:02 +05:30
2026-06-04 15:19:24 +02:00
2026-02-24 08:33:15 +00:00
…
2026-07-13 10:14:58 -07:00
2026-07-13 10:14:58 -07:00
…
2026-04-25 14:57:23 -07:00
2026-06-04 15:19:24 +02:00
2026-03-31 09:06:31 +02:00
…
…
2026-07-23 12:22:51 +02:00
2026-07-13 10:54:53 +02:00
2026-07-23 12:22:51 +02:00
2026-06-04 15:19:24 +02:00
…
2026-06-05 20:19:51 +02:00
…
2026-06-02 19:56:40 +02:00
…

The files here use the LLVM FileCheck framework, documented at https://llvm.org/docs/CommandGuide/FileCheck.html.

One extension worth noting is the use of revisions as custom prefixes for FileCheck. If your codegen test has different behavior based on the chosen target or different compiler flags that you want to exercise, you can use a revisions annotation, like so:

// revisions: aaa bbb
// [bbb] compile-flags: --flags-for-bbb

After specifying those variations, you can write different expected, or explicitly unexpected output by using <prefix>-SAME: and <prefix>-NOT:, like so:

// CHECK: expected code
// aaa-SAME: emitted-only-for-aaa
// aaa-NOT:                        emitted-only-for-bbb
// bbb-NOT:  emitted-only-for-aaa
// bbb-SAME:                       emitted-only-for-bbb