From ebcbd54f61c1e66c6dbfd083461ac25bd462811f Mon Sep 17 00:00:00 2001 From: Tyler McMullen Date: Mon, 4 Dec 2017 11:15:26 -0800 Subject: [PATCH] Add 'compile' test and confirm the pro/epilogue is added. Fix regression this revealed. --- .../isa/intel/prologue-epilogue.cton | 43 ++++++++++--------- lib/cretonne/src/isa/intel/abi.rs | 9 ++-- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/cranelift/filetests/isa/intel/prologue-epilogue.cton b/cranelift/filetests/isa/intel/prologue-epilogue.cton index 75eb62f1d4..edbe90cbc5 100644 --- a/cranelift/filetests/isa/intel/prologue-epilogue.cton +++ b/cranelift/filetests/isa/intel/prologue-epilogue.cton @@ -1,25 +1,28 @@ -test binemit +test compile set is_64bit set is_compressed isa intel haswell -function %foo(f64 [%xmm0], i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12]) -> i64 csr [%r12], i64 csr [%rbx], i64 fp [%rbp] { - ss0 = local 168, offset 0 - ss1 = incoming_arg 32, offset -32 - -ebb0(v0: f64 [%xmm0], v1: i64 [%rbp], v2: i64 [%rbx], v3: i64 [%r12]): - x86_push v1 ; bin: 55 - copy_special %rsp -> %rbp ; bin: 48 89 e5 - x86_push v2 ; bin: 53 - x86_push v3 ; bin: 41 54 - adjust_sp_imm -168 ; bin: 48 81 c4 ffffff58 - - ; ... function body ... - - - adjust_sp_imm 168 ; bin: 48 81 c4 000000a8 - [-,%r12] v100 = x86_pop.i64 ; bin: 41 5c - [-,%rbx] v101 = x86_pop.i64 ; bin: 5b - [-,%rbp] v102 = x86_pop.i64 ; bin: 5d - return v100, v101, v102 +function %foo() { +ebb0: + return } + +; check: function %foo(i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15]) -> i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15] native { +; nextln: ss0 = incoming_arg 48, offset -48 +; check: ebb0(v0: i64 [%rbp], v1: i64 [%rbx], v2: i64 [%r12], v3: i64 [%r13], v4: i64 [%r14], v5: i64 [%r15]): +; nextln: x86_push v0 +; nextln: copy_special %rsp -> %rbp +; nextln: x86_push v1 +; nextln: x86_push v2 +; nextln: x86_push v3 +; nextln: x86_push v4 +; nextln: x86_push v5 +; nextln: v11 = x86_pop.i64 +; nextln: v10 = x86_pop.i64 +; nextln: v9 = x86_pop.i64 +; nextln: v8 = x86_pop.i64 +; nextln: v7 = x86_pop.i64 +; nextln: v6 = x86_pop.i64 +; nextln: return v6, v7, v8, v9, v10, v11 +; nextln: } \ No newline at end of file diff --git a/lib/cretonne/src/isa/intel/abi.rs b/lib/cretonne/src/isa/intel/abi.rs index 1a6aa0aeff..89c24787f6 100644 --- a/lib/cretonne/src/isa/intel/abi.rs +++ b/lib/cretonne/src/isa/intel/abi.rs @@ -10,7 +10,7 @@ use ir::{AbiParam, ArgumentPurpose, ArgumentLoc, ArgumentExtension, CallConv, In use ir::immediates::Imm64; use stack_layout::layout_stack; use std::i32; -use cursor::{Cursor, EncCursor}; +use cursor::{Cursor, EncCursor, CursorPosition}; use result; @@ -204,11 +204,13 @@ pub fn prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> result::Ct func.signature.returns.push(csr_arg); } - // Finally, insert the prologue and epilogues + // 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_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_epilogues(&mut pos, local_stack_size, csr_type, csrs); Ok(()) @@ -263,7 +265,6 @@ fn insert_epilogues( } } } - } /// Insert an epilogue given a specific `return` instruction.