Legalize libcall signatures.
Explicitly legalize signatures created for libcalls.
This commit is contained in:
@@ -3,6 +3,7 @@ test legalizer
|
|||||||
; Pre-SSE 4.1, we need to use runtime library calls for floating point rounding operations.
|
; Pre-SSE 4.1, we need to use runtime library calls for floating point rounding operations.
|
||||||
set is_64bit
|
set is_64bit
|
||||||
set is_pic
|
set is_pic
|
||||||
|
set call_conv=system_v
|
||||||
isa x86
|
isa x86
|
||||||
|
|
||||||
function %floor(f32) -> f32 {
|
function %floor(f32) -> f32 {
|
||||||
@@ -11,6 +12,6 @@ ebb0(v0: f32):
|
|||||||
return v1
|
return v1
|
||||||
}
|
}
|
||||||
; check: function %floor(f32 [%xmm0]) -> f32 [%xmm0] fast {
|
; check: function %floor(f32 [%xmm0]) -> f32 [%xmm0] fast {
|
||||||
; check: sig0 = (f32) -> f32 fast
|
; check: sig0 = (f32 [%xmm0]) -> f32 [%xmm0] system_v
|
||||||
; check: fn0 = %FloorF32 sig0
|
; check: fn0 = %FloorF32 sig0
|
||||||
; check: v1 = call fn0(v0)
|
; check: v1 = call fn0(v0)
|
||||||
|
|||||||
@@ -4,9 +4,15 @@ test compile
|
|||||||
set is_64bit=0
|
set is_64bit=0
|
||||||
isa x86 haswell
|
isa x86 haswell
|
||||||
|
|
||||||
|
set is_64bit=0
|
||||||
|
isa x86 baseline
|
||||||
|
|
||||||
set is_64bit=1
|
set is_64bit=1
|
||||||
isa x86 haswell
|
isa x86 haswell
|
||||||
|
|
||||||
|
set is_64bit=1
|
||||||
|
isa x86 baseline
|
||||||
|
|
||||||
; Constants.
|
; Constants.
|
||||||
|
|
||||||
function %f32_const() -> f32 {
|
function %f32_const() -> f32 {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ test compile
|
|||||||
set is_64bit=1
|
set is_64bit=1
|
||||||
isa x86 haswell
|
isa x86 haswell
|
||||||
|
|
||||||
|
set is_64bit=1
|
||||||
|
isa x86 baseline
|
||||||
|
|
||||||
; Constants.
|
; Constants.
|
||||||
|
|
||||||
function %f64_const() -> f64 {
|
function %f64_const() -> f64 {
|
||||||
|
|||||||
@@ -4,9 +4,15 @@ test compile
|
|||||||
set is_64bit=0
|
set is_64bit=0
|
||||||
isa x86 haswell
|
isa x86 haswell
|
||||||
|
|
||||||
|
set is_64bit=0
|
||||||
|
isa x86 baseline
|
||||||
|
|
||||||
set is_64bit=1
|
set is_64bit=1
|
||||||
isa x86 haswell
|
isa x86 haswell
|
||||||
|
|
||||||
|
set is_64bit=1
|
||||||
|
isa x86 baseline
|
||||||
|
|
||||||
; Constants.
|
; Constants.
|
||||||
|
|
||||||
function %i32_const() -> i32 {
|
function %i32_const() -> i32 {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ test compile
|
|||||||
set is_64bit=1
|
set is_64bit=1
|
||||||
isa x86 haswell
|
isa x86 haswell
|
||||||
|
|
||||||
|
set is_64bit=1
|
||||||
|
isa x86 baseline
|
||||||
|
|
||||||
; Constants.
|
; Constants.
|
||||||
|
|
||||||
function %i64_const() -> i64 {
|
function %i64_const() -> i64 {
|
||||||
|
|||||||
@@ -33,11 +33,9 @@ use std::vec::Vec;
|
|||||||
/// change the entry block arguments, calls, or return instructions, so this can leave the function
|
/// change the entry block arguments, calls, or return instructions, so this can leave the function
|
||||||
/// in a state with type discrepancies.
|
/// in a state with type discrepancies.
|
||||||
pub fn legalize_signatures(func: &mut Function, isa: &TargetIsa) {
|
pub fn legalize_signatures(func: &mut Function, isa: &TargetIsa) {
|
||||||
isa.legalize_signature(&mut func.signature, true);
|
legalize_signature(&mut func.signature, true, isa);
|
||||||
func.signature.compute_argument_bytes();
|
|
||||||
for sig_data in func.dfg.signatures.values_mut() {
|
for sig_data in func.dfg.signatures.values_mut() {
|
||||||
isa.legalize_signature(sig_data, false);
|
legalize_signature(sig_data, false, isa);
|
||||||
sig_data.compute_argument_bytes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(entry) = func.layout.entry_block() {
|
if let Some(entry) = func.layout.entry_block() {
|
||||||
@@ -46,6 +44,20 @@ pub fn legalize_signatures(func: &mut Function, isa: &TargetIsa) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Legalize the libcall signature, which we may generate on the fly after
|
||||||
|
/// `legalize_signatures` has been called.
|
||||||
|
pub fn legalize_libcall_signature(signature: &mut Signature, isa: &TargetIsa) {
|
||||||
|
legalize_signature(signature, false, isa);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Legalize the given signature.
|
||||||
|
///
|
||||||
|
/// `current` is true if this is the signature for the current function.
|
||||||
|
fn legalize_signature(signature: &mut Signature, current: bool, isa: &TargetIsa) {
|
||||||
|
isa.legalize_signature(signature, current);
|
||||||
|
signature.compute_argument_bytes();
|
||||||
|
}
|
||||||
|
|
||||||
/// Legalize the entry block parameters after `func`'s signature has been legalized.
|
/// Legalize the entry block parameters after `func`'s signature has been legalized.
|
||||||
///
|
///
|
||||||
/// The legalized signature may contain more parameters than the original signature, and the
|
/// The legalized signature may contain more parameters than the original signature, and the
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use ir;
|
use ir;
|
||||||
use ir::{get_libcall_funcref, InstBuilder};
|
use ir::{get_libcall_funcref, InstBuilder};
|
||||||
use isa::TargetIsa;
|
use isa::TargetIsa;
|
||||||
|
use legalizer::boundary::legalize_libcall_signature;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
/// Try to expand `inst` as a library call, returning true is successful.
|
/// Try to expand `inst` as a library call, returning true is successful.
|
||||||
@@ -21,7 +22,10 @@ pub fn expand_as_libcall(inst: ir::Inst, func: &mut ir::Function, isa: &TargetIs
|
|||||||
let funcref = get_libcall_funcref(libcall, func, inst, isa);
|
let funcref = get_libcall_funcref(libcall, func, inst, isa);
|
||||||
func.dfg.replace(inst).call(funcref, &args);
|
func.dfg.replace(inst).call(funcref, &args);
|
||||||
|
|
||||||
// TODO: ask the ISA to legalize the signature.
|
// Ask the ISA to legalize the signature.
|
||||||
|
let fn_data = &func.dfg.ext_funcs[funcref];
|
||||||
|
let sig_data = &mut func.dfg.signatures[fn_data.signature];
|
||||||
|
legalize_libcall_signature(sig_data, isa);
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user