1
Fork 0

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.
This commit is contained in:
Alex Crichton 2021-11-01 13:44:28 -07:00
parent d208e1943b
commit d2a3c24a95
8 changed files with 16 additions and 12 deletions

View file

@ -320,7 +320,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {} InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
InlineAsmArch::S390x => {} InlineAsmArch::S390x => {}
InlineAsmArch::SpirV => {} InlineAsmArch::SpirV => {}
InlineAsmArch::Wasm32 => {} InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {}
InlineAsmArch::Bpf => {} InlineAsmArch::Bpf => {}
} }
} }

View file

@ -769,7 +769,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
// we like. To ensure that LLVM picks the right instruction we choose // we like. To ensure that LLVM picks the right instruction we choose
// the raw wasm intrinsic functions which avoid LLVM inserting all the // the raw wasm intrinsic functions which avoid LLVM inserting all the
// other control flow automatically. // other control flow automatically.
if self.sess().target.arch == "wasm32" { if self.sess().target.arch.starts_with("wasm32") {
let src_ty = self.cx.val_ty(val); let src_ty = self.cx.val_ty(val);
if self.cx.type_kind(src_ty) != TypeKind::Vector { if self.cx.type_kind(src_ty) != TypeKind::Vector {
let float_width = self.cx.float_width(src_ty); let float_width = self.cx.float_width(src_ty);
@ -791,7 +791,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
// see `fptoui` above for why wasm is different here // see `fptoui` above for why wasm is different here
if self.sess().target.arch == "wasm32" { if self.sess().target.arch.starts_with("wasm") {
let src_ty = self.cx.val_ty(val); let src_ty = self.cx.val_ty(val);
if self.cx.type_kind(src_ty) != TypeKind::Vector { if self.cx.type_kind(src_ty) != TypeKind::Vector {
let float_width = self.cx.float_width(src_ty); let float_width = self.cx.float_width(src_ty);

View file

@ -490,7 +490,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
// Wasm statics with custom link sections get special treatment as they // Wasm statics with custom link sections get special treatment as they
// go into custom sections of the wasm executable. // go into custom sections of the wasm executable.
if self.tcx.sess.opts.target_triple.triple().starts_with("wasm32") { if self.tcx.sess.opts.target_triple.triple().starts_with("wasm") {
if let Some(section) = attrs.link_section { if let Some(section) = attrs.link_section {
let section = llvm::LLVMMDStringInContext( let section = llvm::LLVMMDStringInContext(
self.llcx, self.llcx,

View file

@ -189,6 +189,7 @@ pub enum InlineAsmArch {
S390x, S390x,
SpirV, SpirV,
Wasm32, Wasm32,
Wasm64,
Bpf, Bpf,
} }
@ -212,6 +213,7 @@ impl FromStr for InlineAsmArch {
"s390x" => Ok(Self::S390x), "s390x" => Ok(Self::S390x),
"spirv" => Ok(Self::SpirV), "spirv" => Ok(Self::SpirV),
"wasm32" => Ok(Self::Wasm32), "wasm32" => Ok(Self::Wasm32),
"wasm64" => Ok(Self::Wasm64),
"bpf" => Ok(Self::Bpf), "bpf" => Ok(Self::Bpf),
_ => Err(()), _ => Err(()),
} }
@ -318,7 +320,7 @@ impl InlineAsmReg {
InlineAsmArch::SpirV => { InlineAsmArch::SpirV => {
Self::SpirV(SpirVInlineAsmReg::parse(arch, has_feature, target, &name)?) Self::SpirV(SpirVInlineAsmReg::parse(arch, has_feature, target, &name)?)
} }
InlineAsmArch::Wasm32 => { InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
Self::Wasm(WasmInlineAsmReg::parse(arch, has_feature, target, &name)?) Self::Wasm(WasmInlineAsmReg::parse(arch, has_feature, target, &name)?)
} }
InlineAsmArch::Bpf => { InlineAsmArch::Bpf => {
@ -529,7 +531,9 @@ impl InlineAsmRegClass {
} }
InlineAsmArch::S390x => Self::S390x(S390xInlineAsmRegClass::parse(arch, name)?), InlineAsmArch::S390x => Self::S390x(S390xInlineAsmRegClass::parse(arch, name)?),
InlineAsmArch::SpirV => Self::SpirV(SpirVInlineAsmRegClass::parse(arch, name)?), InlineAsmArch::SpirV => Self::SpirV(SpirVInlineAsmRegClass::parse(arch, name)?),
InlineAsmArch::Wasm32 => Self::Wasm(WasmInlineAsmRegClass::parse(arch, name)?), InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
Self::Wasm(WasmInlineAsmRegClass::parse(arch, name)?)
}
InlineAsmArch::Bpf => Self::Bpf(BpfInlineAsmRegClass::parse(arch, name)?), InlineAsmArch::Bpf => Self::Bpf(BpfInlineAsmRegClass::parse(arch, name)?),
}) })
} }
@ -725,7 +729,7 @@ pub fn allocatable_registers(
spirv::fill_reg_map(arch, has_feature, target, &mut map); spirv::fill_reg_map(arch, has_feature, target, &mut map);
map map
} }
InlineAsmArch::Wasm32 => { InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
let mut map = wasm::regclass_map(); let mut map = wasm::regclass_map();
wasm::fill_reg_map(arch, has_feature, target, &mut map); wasm::fill_reg_map(arch, has_feature, target, &mut map);
map map

View file

@ -537,7 +537,7 @@ fn fn_maybe_err(tcx: TyCtxt<'_>, sp: Span, abi: Abi) {
fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId, span: Span) { fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId, span: Span) {
// Only restricted on wasm32 target for now // Only restricted on wasm32 target for now
if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") { if !tcx.sess.opts.target_triple.triple().starts_with("wasm") {
return; return;
} }

View file

@ -284,7 +284,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
// Prevent the usage of `Instant` in some cases: // Prevent the usage of `Instant` in some cases:
// - It's currently not supported for wasm targets. // - It's currently not supported for wasm targets.
// - We disable it for miri because it's not available when isolation is enabled. // - We disable it for miri because it's not available when isolation is enabled.
let is_instant_supported = !cfg!(target_arch = "wasm32") && !cfg!(miri); let is_instant_supported = !cfg!(target_family = "wasm") && !cfg!(miri);
let start_time = is_instant_supported.then(Instant::now); let start_time = is_instant_supported.then(Instant::now);
run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?; run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?;

View file

@ -470,7 +470,7 @@ pub fn run_test(
// Emscripten can catch panics but other wasm targets cannot // Emscripten can catch panics but other wasm targets cannot
let ignore_because_no_process_support = desc.should_panic != ShouldPanic::No let ignore_because_no_process_support = desc.should_panic != ShouldPanic::No
&& cfg!(target_arch = "wasm32") && cfg!(target_family = "wasm")
&& !cfg!(target_os = "emscripten"); && !cfg!(target_os = "emscripten");
if force_ignore || desc.ignore || ignore_because_no_process_support { if force_ignore || desc.ignore || ignore_because_no_process_support {
@ -519,7 +519,7 @@ pub fn run_test(
// If the platform is single-threaded we're just going to run // If the platform is single-threaded we're just going to run
// the test synchronously, regardless of the concurrency // the test synchronously, regardless of the concurrency
// level. // level.
let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32"); let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_family = "wasm");
if concurrency == Concurrent::Yes && supports_threads { if concurrency == Concurrent::Yes && supports_threads {
let cfg = thread::Builder::new().name(name.as_slice().to_owned()); let cfg = thread::Builder::new().name(name.as_slice().to_owned());
let mut runtest = Arc::new(Mutex::new(Some(runtest))); let mut runtest = Arc::new(Mutex::new(Some(runtest)));

View file

@ -1276,7 +1276,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
builder.ensure(native::TestHelpers { target: compiler.host }); builder.ensure(native::TestHelpers { target: compiler.host });
// As well as the target, except for plain wasm32, which can't build it // As well as the target, except for plain wasm32, which can't build it
if !target.contains("wasm32") || target.contains("emscripten") { if !target.contains("wasm") || target.contains("emscripten") {
builder.ensure(native::TestHelpers { target }); builder.ensure(native::TestHelpers { target });
} }