Skip to content

Commit d2a3c24

Browse files
committed
Update more rustc/libtest things for wasm64
* Add wasm64 variants for inline assembly along the same lines as wasm32 * Update a few directives in libtest to check for `target_family` instead of `target_arch` * Update some rustc codegen and typechecks specialized for wasm32 to also work for wasm64.
1 parent d208e19 commit d2a3c24

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
320320
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
321321
InlineAsmArch::S390x => {}
322322
InlineAsmArch::SpirV => {}
323-
InlineAsmArch::Wasm32 => {}
323+
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {}
324324
InlineAsmArch::Bpf => {}
325325
}
326326
}

compiler/rustc_codegen_llvm/src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
769769
// we like. To ensure that LLVM picks the right instruction we choose
770770
// the raw wasm intrinsic functions which avoid LLVM inserting all the
771771
// other control flow automatically.
772-
if self.sess().target.arch == "wasm32" {
772+
if self.sess().target.arch.starts_with("wasm32") {
773773
let src_ty = self.cx.val_ty(val);
774774
if self.cx.type_kind(src_ty) != TypeKind::Vector {
775775
let float_width = self.cx.float_width(src_ty);
@@ -791,7 +791,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
791791

792792
fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
793793
// see `fptoui` above for why wasm is different here
794-
if self.sess().target.arch == "wasm32" {
794+
if self.sess().target.arch.starts_with("wasm") {
795795
let src_ty = self.cx.val_ty(val);
796796
if self.cx.type_kind(src_ty) != TypeKind::Vector {
797797
let float_width = self.cx.float_width(src_ty);

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
490490

491491
// Wasm statics with custom link sections get special treatment as they
492492
// go into custom sections of the wasm executable.
493-
if self.tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
493+
if self.tcx.sess.opts.target_triple.triple().starts_with("wasm") {
494494
if let Some(section) = attrs.link_section {
495495
let section = llvm::LLVMMDStringInContext(
496496
self.llcx,

compiler/rustc_target/src/asm/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ pub enum InlineAsmArch {
189189
S390x,
190190
SpirV,
191191
Wasm32,
192+
Wasm64,
192193
Bpf,
193194
}
194195

@@ -212,6 +213,7 @@ impl FromStr for InlineAsmArch {
212213
"s390x" => Ok(Self::S390x),
213214
"spirv" => Ok(Self::SpirV),
214215
"wasm32" => Ok(Self::Wasm32),
216+
"wasm64" => Ok(Self::Wasm64),
215217
"bpf" => Ok(Self::Bpf),
216218
_ => Err(()),
217219
}
@@ -318,7 +320,7 @@ impl InlineAsmReg {
318320
InlineAsmArch::SpirV => {
319321
Self::SpirV(SpirVInlineAsmReg::parse(arch, has_feature, target, &name)?)
320322
}
321-
InlineAsmArch::Wasm32 => {
323+
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
322324
Self::Wasm(WasmInlineAsmReg::parse(arch, has_feature, target, &name)?)
323325
}
324326
InlineAsmArch::Bpf => {
@@ -529,7 +531,9 @@ impl InlineAsmRegClass {
529531
}
530532
InlineAsmArch::S390x => Self::S390x(S390xInlineAsmRegClass::parse(arch, name)?),
531533
InlineAsmArch::SpirV => Self::SpirV(SpirVInlineAsmRegClass::parse(arch, name)?),
532-
InlineAsmArch::Wasm32 => Self::Wasm(WasmInlineAsmRegClass::parse(arch, name)?),
534+
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
535+
Self::Wasm(WasmInlineAsmRegClass::parse(arch, name)?)
536+
}
533537
InlineAsmArch::Bpf => Self::Bpf(BpfInlineAsmRegClass::parse(arch, name)?),
534538
})
535539
}
@@ -725,7 +729,7 @@ pub fn allocatable_registers(
725729
spirv::fill_reg_map(arch, has_feature, target, &mut map);
726730
map
727731
}
728-
InlineAsmArch::Wasm32 => {
732+
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
729733
let mut map = wasm::regclass_map();
730734
wasm::fill_reg_map(arch, has_feature, target, &mut map);
731735
map

compiler/rustc_typeck/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ fn fn_maybe_err(tcx: TyCtxt<'_>, sp: Span, abi: Abi) {
537537

538538
fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId, span: Span) {
539539
// Only restricted on wasm32 target for now
540-
if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
540+
if !tcx.sess.opts.target_triple.triple().starts_with("wasm") {
541541
return;
542542
}
543543

library/test/src/console.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
284284
// Prevent the usage of `Instant` in some cases:
285285
// - It's currently not supported for wasm targets.
286286
// - We disable it for miri because it's not available when isolation is enabled.
287-
let is_instant_supported = !cfg!(target_arch = "wasm32") && !cfg!(miri);
287+
let is_instant_supported = !cfg!(target_family = "wasm") && !cfg!(miri);
288288

289289
let start_time = is_instant_supported.then(Instant::now);
290290
run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?;

library/test/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ pub fn run_test(
470470

471471
// Emscripten can catch panics but other wasm targets cannot
472472
let ignore_because_no_process_support = desc.should_panic != ShouldPanic::No
473-
&& cfg!(target_arch = "wasm32")
473+
&& cfg!(target_family = "wasm")
474474
&& !cfg!(target_os = "emscripten");
475475

476476
if force_ignore || desc.ignore || ignore_because_no_process_support {
@@ -519,7 +519,7 @@ pub fn run_test(
519519
// If the platform is single-threaded we're just going to run
520520
// the test synchronously, regardless of the concurrency
521521
// level.
522-
let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32");
522+
let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_family = "wasm");
523523
if concurrency == Concurrent::Yes && supports_threads {
524524
let cfg = thread::Builder::new().name(name.as_slice().to_owned());
525525
let mut runtest = Arc::new(Mutex::new(Some(runtest)));

src/bootstrap/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
12761276
builder.ensure(native::TestHelpers { target: compiler.host });
12771277

12781278
// As well as the target, except for plain wasm32, which can't build it
1279-
if !target.contains("wasm32") || target.contains("emscripten") {
1279+
if !target.contains("wasm") || target.contains("emscripten") {
12801280
builder.ensure(native::TestHelpers { target });
12811281
}
12821282

0 commit comments

Comments
 (0)