Rename CallConv::Native to CallConv::SystemV. (#291)
To keep cross-compiling straightforward, Cretonne shouldn't have any behavior that depends on the host. This renames the "Native" calling convention to "SystemV", which has a defined meaning for each target, so that it's clear that the calling convention doesn't change depending on what host Cretonne is running on.
This commit is contained in:
@@ -343,10 +343,11 @@ impl fmt::Display for ExtFuncData {
|
||||
/// determined by a `(TargetIsa, CallConv)` tuple.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum CallConv {
|
||||
/// The C calling convention.
|
||||
/// The System V-style calling convention.
|
||||
///
|
||||
/// This is the native calling convention that a C compiler would use on the platform.
|
||||
Native,
|
||||
/// This is the System V-style calling convention that a C compiler would
|
||||
/// use on many platforms.
|
||||
SystemV,
|
||||
|
||||
/// A JIT-compiled WebAssembly function in the SpiderMonkey VM.
|
||||
SpiderWASM,
|
||||
@@ -356,7 +357,7 @@ impl fmt::Display for CallConv {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::CallConv::*;
|
||||
f.write_str(match *self {
|
||||
Native => "native",
|
||||
SystemV => "system_v",
|
||||
SpiderWASM => "spiderwasm",
|
||||
})
|
||||
}
|
||||
@@ -368,7 +369,7 @@ impl FromStr for CallConv {
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
use self::CallConv::*;
|
||||
match s {
|
||||
"native" => Ok(Native),
|
||||
"system_v" => Ok(SystemV),
|
||||
"spiderwasm" => Ok(SpiderWASM),
|
||||
_ => Err(()),
|
||||
}
|
||||
@@ -410,7 +411,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn call_conv() {
|
||||
for &cc in &[CallConv::Native, CallConv::SpiderWASM] {
|
||||
for &cc in &[CallConv::SystemV, CallConv::SpiderWASM] {
|
||||
assert_eq!(Ok(cc), cc.to_string().parse())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ impl Function {
|
||||
|
||||
/// Clear all data structures in this function.
|
||||
pub fn clear(&mut self) {
|
||||
self.signature.clear(ir::CallConv::Native);
|
||||
self.signature.clear(ir::CallConv::SystemV);
|
||||
self.stack_slots.clear();
|
||||
self.global_vars.clear();
|
||||
self.heaps.clear();
|
||||
@@ -99,9 +99,9 @@ impl Function {
|
||||
self.srclocs.clear();
|
||||
}
|
||||
|
||||
/// Create a new empty, anonymous function with a native calling convention.
|
||||
/// Create a new empty, anonymous function with a SystemV calling convention.
|
||||
pub fn new() -> Self {
|
||||
Self::with_name_signature(ExternalName::default(), Signature::new(CallConv::Native))
|
||||
Self::with_name_signature(ExternalName::default(), Signature::new(CallConv::SystemV))
|
||||
}
|
||||
|
||||
/// Creates a jump table in the function, to be used by `br_table` instructions.
|
||||
|
||||
@@ -171,7 +171,7 @@ pub fn callee_saved_registers(flags: &shared_settings::Flags) -> &'static [RU] {
|
||||
|
||||
pub fn prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> result::CtonResult {
|
||||
match func.signature.call_conv {
|
||||
ir::CallConv::Native => native_prologue_epilogue(func, isa),
|
||||
ir::CallConv::SystemV => system_v_prologue_epilogue(func, isa),
|
||||
ir::CallConv::SpiderWASM => spiderwasm_prologue_epilogue(func, isa),
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ pub fn spiderwasm_prologue_epilogue(
|
||||
}
|
||||
|
||||
/// Insert a System V-compatible prologue and epilogue.
|
||||
pub fn native_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> result::CtonResult {
|
||||
pub fn system_v_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> result::CtonResult {
|
||||
// The original 32-bit x86 ELF ABI had a 4-byte aligned stack pointer, but
|
||||
// newer versions use a 16-byte aligned stack pointer.
|
||||
let stack_align = 16;
|
||||
@@ -242,17 +242,17 @@ pub fn native_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> res
|
||||
// Set up the cursor and insert the prologue
|
||||
let entry_ebb = func.layout.entry_block().expect("missing entry block");
|
||||
let mut pos = EncCursor::new(func, isa).at_first_insertion_point(entry_ebb);
|
||||
insert_native_prologue(&mut pos, local_stack_size, csr_type, csrs);
|
||||
insert_system_v_prologue(&mut pos, local_stack_size, csr_type, csrs);
|
||||
|
||||
// Reset the cursor and insert the epilogue
|
||||
let mut pos = pos.at_position(CursorPosition::Nowhere);
|
||||
insert_native_epilogues(&mut pos, local_stack_size, csr_type, csrs);
|
||||
insert_system_v_epilogues(&mut pos, local_stack_size, csr_type, csrs);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Insert the prologue for a given function.
|
||||
fn insert_native_prologue(
|
||||
fn insert_system_v_prologue(
|
||||
pos: &mut EncCursor,
|
||||
stack_size: i64,
|
||||
csr_type: ir::types::Type,
|
||||
@@ -286,7 +286,7 @@ fn insert_native_prologue(
|
||||
}
|
||||
|
||||
/// Find all `return` instructions and insert epilogues before them.
|
||||
fn insert_native_epilogues(
|
||||
fn insert_system_v_epilogues(
|
||||
pos: &mut EncCursor,
|
||||
stack_size: i64,
|
||||
csr_type: ir::types::Type,
|
||||
@@ -296,14 +296,14 @@ fn insert_native_epilogues(
|
||||
pos.goto_last_inst(ebb);
|
||||
if let Some(inst) = pos.current_inst() {
|
||||
if pos.func.dfg[inst].opcode().is_return() {
|
||||
insert_native_epilogue(inst, stack_size, pos, csr_type, csrs);
|
||||
insert_system_v_epilogue(inst, stack_size, pos, csr_type, csrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Insert an epilogue given a specific `return` instruction.
|
||||
fn insert_native_epilogue(
|
||||
fn insert_system_v_epilogue(
|
||||
inst: ir::Inst,
|
||||
stack_size: i64,
|
||||
pos: &mut EncCursor,
|
||||
|
||||
@@ -44,8 +44,8 @@ fn find_funcref(libcall: ir::LibCall, func: &ir::Function) -> Option<ir::FuncRef
|
||||
|
||||
/// Create a funcref for `libcall` with a signature matching `inst`.
|
||||
fn make_funcref(libcall: ir::LibCall, inst: ir::Inst, func: &mut ir::Function) -> ir::FuncRef {
|
||||
// Start with a native calling convention. We'll give the ISA a chance to change it.
|
||||
let mut sig = ir::Signature::new(ir::CallConv::Native);
|
||||
// Start with a system_v calling convention. We'll give the ISA a chance to change it.
|
||||
let mut sig = ir::Signature::new(ir::CallConv::SystemV);
|
||||
for &v in func.dfg.inst_args(inst) {
|
||||
sig.params.push(ir::AbiParam::new(func.dfg.value_type(v)));
|
||||
}
|
||||
|
||||
@@ -465,34 +465,34 @@ mod tests {
|
||||
#[test]
|
||||
fn basic() {
|
||||
let mut f = Function::new();
|
||||
assert_eq!(f.to_string(), "function u0:0() native {\n}\n");
|
||||
assert_eq!(f.to_string(), "function u0:0() system_v {\n}\n");
|
||||
|
||||
f.name = ExternalName::testcase("foo");
|
||||
assert_eq!(f.to_string(), "function %foo() native {\n}\n");
|
||||
assert_eq!(f.to_string(), "function %foo() system_v {\n}\n");
|
||||
|
||||
f.create_stack_slot(StackSlotData::new(StackSlotKind::ExplicitSlot, 4));
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n}\n"
|
||||
"function %foo() system_v {\n ss0 = explicit_slot 4\n}\n"
|
||||
);
|
||||
|
||||
let ebb = f.dfg.make_ebb();
|
||||
f.layout.append_ebb(ebb);
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n\nebb0:\n}\n"
|
||||
"function %foo() system_v {\n ss0 = explicit_slot 4\n\nebb0:\n}\n"
|
||||
);
|
||||
|
||||
f.dfg.append_ebb_param(ebb, types::I8);
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n\nebb0(v0: i8):\n}\n"
|
||||
"function %foo() system_v {\n ss0 = explicit_slot 4\n\nebb0(v0: i8):\n}\n"
|
||||
);
|
||||
|
||||
f.dfg.append_ebb_param(ebb, types::F32.by(4).unwrap());
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n\nebb0(v0: i8, v1: f32x4):\n}\n"
|
||||
"function %foo() system_v {\n ss0 = explicit_slot 4\n\nebb0(v0: i8, v1: f32x4):\n}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user