Skip to content

Commit d65ab8c

Browse files
authored
Rollup merge of rust-lang#141700 - RalfJung:atomic-intrinsics-part2, r=bjorn3
Atomic intrinsics : use const generic ordering, part 2 This completes what got started in rust-lang#141507 by using a const generic for the ordering for all intrinsics. It is based on that PR; only the last commit is new. Blocked on: - rust-lang#141507 - rust-lang#141687 - rust-lang/stdarch#1811 - rust-lang#141964 r? `@bjorn3`
2 parents 2418991 + 5282405 commit d65ab8c

File tree

25 files changed

+1095
-1969
lines changed

25 files changed

+1095
-1969
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
875875
let ptr = ptr.load_scalar(fx);
876876

877877
let ty = generic_args.type_at(0);
878-
let _ord = generic_args.const_at(1).to_value(); // FIXME: forward this to cranelift once they support that
879878
match ty.kind() {
880879
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
881880
// FIXME implement 128bit atomics
@@ -906,7 +905,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
906905
let val = CValue::by_val(val, fx.layout_of(ty));
907906
ret.write_cvalue(fx, val);
908907
}
909-
_ if intrinsic.as_str().starts_with("atomic_store") => {
908+
sym::atomic_store => {
910909
intrinsic_args!(fx, args => (ptr, val); intrinsic);
911910
let ptr = ptr.load_scalar(fx);
912911

@@ -939,7 +938,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
939938

940939
fx.bcx.ins().atomic_store(MemFlags::trusted(), val, ptr);
941940
}
942-
_ if intrinsic.as_str().starts_with("atomic_xchg") => {
941+
sym::atomic_xchg => {
943942
intrinsic_args!(fx, args => (ptr, new); intrinsic);
944943
let ptr = ptr.load_scalar(fx);
945944

@@ -960,8 +959,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
960959
let old = CValue::by_val(old, layout);
961960
ret.write_cvalue(fx, old);
962961
}
963-
_ if intrinsic.as_str().starts_with("atomic_cxchg") => {
964-
// both atomic_cxchg_* and atomic_cxchgweak_*
962+
sym::atomic_cxchg | sym::atomic_cxchgweak => {
965963
intrinsic_args!(fx, args => (ptr, test_old, new); intrinsic);
966964
let ptr = ptr.load_scalar(fx);
967965

@@ -984,7 +982,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
984982
ret.write_cvalue(fx, ret_val)
985983
}
986984

987-
_ if intrinsic.as_str().starts_with("atomic_xadd") => {
985+
sym::atomic_xadd => {
988986
intrinsic_args!(fx, args => (ptr, amount); intrinsic);
989987
let ptr = ptr.load_scalar(fx);
990988

@@ -1006,7 +1004,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10061004
let old = CValue::by_val(old, layout);
10071005
ret.write_cvalue(fx, old);
10081006
}
1009-
_ if intrinsic.as_str().starts_with("atomic_xsub") => {
1007+
sym::atomic_xsub => {
10101008
intrinsic_args!(fx, args => (ptr, amount); intrinsic);
10111009
let ptr = ptr.load_scalar(fx);
10121010

@@ -1028,7 +1026,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10281026
let old = CValue::by_val(old, layout);
10291027
ret.write_cvalue(fx, old);
10301028
}
1031-
_ if intrinsic.as_str().starts_with("atomic_and") => {
1029+
sym::atomic_and => {
10321030
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10331031
let ptr = ptr.load_scalar(fx);
10341032

@@ -1049,7 +1047,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10491047
let old = CValue::by_val(old, layout);
10501048
ret.write_cvalue(fx, old);
10511049
}
1052-
_ if intrinsic.as_str().starts_with("atomic_or") => {
1050+
sym::atomic_or => {
10531051
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10541052
let ptr = ptr.load_scalar(fx);
10551053

@@ -1070,7 +1068,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10701068
let old = CValue::by_val(old, layout);
10711069
ret.write_cvalue(fx, old);
10721070
}
1073-
_ if intrinsic.as_str().starts_with("atomic_xor") => {
1071+
sym::atomic_xor => {
10741072
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10751073
let ptr = ptr.load_scalar(fx);
10761074

@@ -1091,7 +1089,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10911089
let old = CValue::by_val(old, layout);
10921090
ret.write_cvalue(fx, old);
10931091
}
1094-
_ if intrinsic.as_str().starts_with("atomic_nand") => {
1092+
sym::atomic_nand => {
10951093
intrinsic_args!(fx, args => (ptr, src); intrinsic);
10961094
let ptr = ptr.load_scalar(fx);
10971095

@@ -1112,7 +1110,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11121110
let old = CValue::by_val(old, layout);
11131111
ret.write_cvalue(fx, old);
11141112
}
1115-
_ if intrinsic.as_str().starts_with("atomic_max") => {
1113+
sym::atomic_max => {
11161114
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11171115
let ptr = ptr.load_scalar(fx);
11181116

@@ -1133,7 +1131,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11331131
let old = CValue::by_val(old, layout);
11341132
ret.write_cvalue(fx, old);
11351133
}
1136-
_ if intrinsic.as_str().starts_with("atomic_umax") => {
1134+
sym::atomic_umax => {
11371135
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11381136
let ptr = ptr.load_scalar(fx);
11391137

@@ -1154,7 +1152,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11541152
let old = CValue::by_val(old, layout);
11551153
ret.write_cvalue(fx, old);
11561154
}
1157-
_ if intrinsic.as_str().starts_with("atomic_min") => {
1155+
sym::atomic_min => {
11581156
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11591157
let ptr = ptr.load_scalar(fx);
11601158

@@ -1175,7 +1173,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11751173
let old = CValue::by_val(old, layout);
11761174
ret.write_cvalue(fx, old);
11771175
}
1178-
_ if intrinsic.as_str().starts_with("atomic_umin") => {
1176+
sym::atomic_umin => {
11791177
intrinsic_args!(fx, args => (ptr, src); intrinsic);
11801178
let ptr = ptr.load_scalar(fx);
11811179

compiler/rustc_codegen_ssa/messages.ftl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ codegen_ssa_aix_strip_not_used = using host's `strip` binary to cross-compile to
88
99
codegen_ssa_archive_build_failure = failed to build archive at `{$path}`: {$error}
1010
11-
codegen_ssa_atomic_compare_exchange = Atomic compare-exchange intrinsic missing failure memory ordering
12-
1311
codegen_ssa_autodiff_without_lto = using the autodiff feature requires using fat-lto
1412
1513
codegen_ssa_bare_instruction_set = `#[instruction_set]` requires an argument
@@ -206,8 +204,6 @@ codegen_ssa_missing_cpp_build_tool_component = or a necessary component may be m
206204
207205
codegen_ssa_missing_features = add the missing features in a `target_feature` attribute
208206
209-
codegen_ssa_missing_memory_ordering = Atomic intrinsic missing memory ordering
210-
211207
codegen_ssa_missing_query_depgraph =
212208
found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
213209
@@ -374,10 +370,6 @@ codegen_ssa_unexpected_parameter_name = unexpected parameter name
374370
codegen_ssa_unknown_archive_kind =
375371
Don't know how to build archive of type: {$kind}
376372
377-
codegen_ssa_unknown_atomic_operation = unknown atomic operation
378-
379-
codegen_ssa_unknown_atomic_ordering = unknown ordering in atomic intrinsic
380-
381373
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
382374
383375
codegen_ssa_unsupported_instruction_set = target does not support `#[instruction_set]`

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -796,22 +796,6 @@ pub(crate) struct ShuffleIndicesEvaluation {
796796
pub span: Span,
797797
}
798798

799-
#[derive(Diagnostic)]
800-
#[diag(codegen_ssa_missing_memory_ordering)]
801-
pub(crate) struct MissingMemoryOrdering;
802-
803-
#[derive(Diagnostic)]
804-
#[diag(codegen_ssa_unknown_atomic_ordering)]
805-
pub(crate) struct UnknownAtomicOrdering;
806-
807-
#[derive(Diagnostic)]
808-
#[diag(codegen_ssa_atomic_compare_exchange)]
809-
pub(crate) struct AtomicCompareExchange;
810-
811-
#[derive(Diagnostic)]
812-
#[diag(codegen_ssa_unknown_atomic_operation)]
813-
pub(crate) struct UnknownAtomicOperation;
814-
815799
#[derive(Diagnostic)]
816800
pub enum InvalidMonomorphization<'tcx> {
817801
#[diag(codegen_ssa_invalid_monomorphization_basic_integer_type, code = E0511)]

0 commit comments

Comments
 (0)