-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
129 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1291,6 +1291,7 @@ symbols! { | |
vreg, | ||
vreg_low16, | ||
warn, | ||
wasm, | ||
wasm_import_module, | ||
wasm_target_feature, | ||
while_let, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::abi::call::{ArgAbi, FnAbi, Uniform}; | ||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods}; | ||
|
||
fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgAbi<'a, Ty>) -> bool | ||
where | ||
Ty: TyAndLayoutMethods<'a, C> + Copy, | ||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout, | ||
{ | ||
if val.layout.is_aggregate() { | ||
if let Some(unit) = val.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) { | ||
let size = val.layout.size; | ||
if unit.size == size { | ||
val.cast_to(Uniform { unit, total: size }); | ||
return true; | ||
} | ||
} | ||
} | ||
false | ||
} | ||
|
||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>) | ||
where | ||
Ty: TyAndLayoutMethods<'a, C> + Copy, | ||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout, | ||
{ | ||
ret.extend_integer_width_to(64); | ||
if ret.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, ret) { | ||
ret.make_indirect(); | ||
} | ||
} | ||
|
||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) | ||
where | ||
Ty: TyAndLayoutMethods<'a, C> + Copy, | ||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout, | ||
{ | ||
arg.extend_integer_width_to(64); | ||
if arg.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, arg) { | ||
arg.make_indirect_byval(); | ||
} | ||
} | ||
|
||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) | ||
where | ||
Ty: TyAndLayoutMethods<'a, C> + Copy, | ||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout, | ||
{ | ||
if !fn_abi.ret.is_ignore() { | ||
classify_ret(cx, &mut fn_abi.ret); | ||
} | ||
|
||
for arg in &mut fn_abi.args { | ||
if arg.is_ignore() { | ||
continue; | ||
} | ||
classify_arg(cx, arg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! A "bare wasm" target representing a WebAssembly output that makes zero | ||
//! assumptions about its environment. | ||
//! | ||
//! The `wasm64-unknown-unknown` target is intended to encapsulate use cases | ||
//! that do not rely on any imported functionality. The binaries generated are | ||
//! entirely self-contained by default when using the standard library. Although | ||
//! the standard library is available, most of it returns an error immediately | ||
//! (e.g. trying to create a TCP stream or something like that). | ||
|
||
use super::wasm_base; | ||
use super::{LinkerFlavor, LldFlavor, Target}; | ||
|
||
pub fn target() -> Target { | ||
let mut options = wasm_base::options(); | ||
options.os = "unknown".to_string(); | ||
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm); | ||
let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap(); | ||
|
||
// Make sure clang uses LLD as its linker and is configured appropriately | ||
// otherwise | ||
clang_args.push("--target=wasm64-unknown-unknown".to_string()); | ||
|
||
// For now this target just never has an entry symbol no matter the output | ||
// type, so unconditionally pass this. | ||
clang_args.push("-Wl,--no-entry".to_string()); | ||
options | ||
.pre_link_args | ||
.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm)) | ||
.unwrap() | ||
.push("--no-entry".to_string()); | ||
|
||
Target { | ||
llvm_target: "wasm64-unknown-unknown".to_string(), | ||
pointer_width: 64, | ||
data_layout: "e-m:e-p:64:64-i64:64-n32:64-S128".to_string(), | ||
arch: "wasm64".to_string(), | ||
options, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters