Change "cton" to "clif".
This commit is contained in:
parent
27d90ab1d5
commit
7b5f4894f1
28
src/abi.rs
28
src/abi.rs
@ -16,7 +16,7 @@ impl PassMode {
|
||||
fn get_param_ty(self, fx: &FunctionCx<impl Backend>) -> Type {
|
||||
match self {
|
||||
PassMode::NoPass => unimplemented!("pass mode nopass"),
|
||||
PassMode::ByVal(cton_type) => cton_type,
|
||||
PassMode::ByVal(clif_type) => clif_type,
|
||||
PassMode::ByRef => fx.pointer_type,
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ fn get_pass_mode<'a, 'tcx: 'a>(
|
||||
} else {
|
||||
PassMode::ByRef
|
||||
}
|
||||
} else if let Some(ret_ty) = crate::common::cton_type_from_ty(tcx, ty) {
|
||||
} else if let Some(ret_ty) = crate::common::clif_type_from_ty(tcx, ty) {
|
||||
PassMode::ByVal(ret_ty)
|
||||
} else {
|
||||
if abi == Abi::C {
|
||||
@ -70,7 +70,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(
|
||||
pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
fn_ty: Ty<'tcx>,
|
||||
) -> Signature {
|
||||
@ -97,7 +97,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(
|
||||
let inputs = inputs
|
||||
.into_iter()
|
||||
.filter_map(|ty| match get_pass_mode(tcx, sig.abi, ty, false) {
|
||||
PassMode::ByVal(cton_ty) => Some(cton_ty),
|
||||
PassMode::ByVal(clif_ty) => Some(clif_ty),
|
||||
PassMode::NoPass => unimplemented!("pass mode nopass"),
|
||||
PassMode::ByRef => Some(pointer_ty(tcx)),
|
||||
});
|
||||
@ -178,7 +178,7 @@ pub fn get_function_name_and_sig<'a, 'tcx>(
|
||||
) -> (String, Signature) {
|
||||
assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types());
|
||||
let fn_ty = inst.ty(tcx);
|
||||
let sig = cton_sig_from_fn_ty(tcx, fn_ty);
|
||||
let sig = clif_sig_from_fn_ty(tcx, fn_ty);
|
||||
(tcx.symbol_name(inst).as_str().to_string(), sig)
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> {
|
||||
.into_iter()
|
||||
.map(|arg| {
|
||||
(
|
||||
self.cton_type(arg.layout().ty).unwrap(),
|
||||
self.clif_type(arg.layout().ty).unwrap(),
|
||||
arg.load_value(self),
|
||||
)
|
||||
})
|
||||
@ -250,7 +250,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> {
|
||||
}
|
||||
None
|
||||
} else {
|
||||
Some(self.cton_type(return_ty).unwrap())
|
||||
Some(self.clif_type(return_ty).unwrap())
|
||||
};
|
||||
if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) {
|
||||
CValue::ByVal(val, return_layout)
|
||||
@ -307,18 +307,18 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(
|
||||
|
||||
let mut ebb_params = Vec::new();
|
||||
for arg_ty in tupled_arg_tys.iter() {
|
||||
let cton_type =
|
||||
let clif_type =
|
||||
get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx);
|
||||
ebb_params.push(fx.bcx.append_ebb_param(start_ebb, cton_type));
|
||||
ebb_params.push(fx.bcx.append_ebb_param(start_ebb, clif_type));
|
||||
}
|
||||
|
||||
(local, ArgKind::Spread(ebb_params), arg_ty)
|
||||
} else {
|
||||
let cton_type =
|
||||
let clif_type =
|
||||
get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx);
|
||||
(
|
||||
local,
|
||||
ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, cton_type)),
|
||||
ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, clif_type)),
|
||||
arg_ty,
|
||||
)
|
||||
}
|
||||
@ -368,7 +368,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(
|
||||
.contains(crate::analyze::Flags::NOT_SSA)
|
||||
{
|
||||
fx.bcx
|
||||
.declare_var(mir_var(local), fx.cton_type(ty).unwrap());
|
||||
.declare_var(mir_var(local), fx.clif_type(ty).unwrap());
|
||||
match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) {
|
||||
PassMode::NoPass => unimplemented!("pass mode nopass"),
|
||||
PassMode::ByVal(_) => fx.bcx.def_var(mir_var(local), ebb_param),
|
||||
@ -434,7 +434,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(
|
||||
CPlace::from_stack_slot(fx, stack_slot, ty)
|
||||
} else {
|
||||
fx.bcx
|
||||
.declare_var(mir_var(local), fx.cton_type(ty).unwrap());
|
||||
.declare_var(mir_var(local), fx.clif_type(ty).unwrap());
|
||||
CPlace::Var(local, layout)
|
||||
};
|
||||
|
||||
@ -568,7 +568,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>(
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty));
|
||||
let sig = fx.bcx.import_signature(clif_sig_from_fn_ty(fx.tcx, fn_ty));
|
||||
let call_inst = if let Some(func_ref) = func_ref {
|
||||
fx.bcx.ins().call_indirect(sig, func_ref, &call_args)
|
||||
} else {
|
||||
|
@ -18,7 +18,7 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap
|
||||
not_ssa(&mut flag_map, RETURN_PLACE);
|
||||
|
||||
for (local, local_decl) in fx.mir.local_decls.iter_enumerated() {
|
||||
if fx.cton_type(local_decl.ty).is_none() {
|
||||
if fx.clif_type(local_decl.ty).is_none() {
|
||||
not_ssa(&mut flag_map, local);
|
||||
}
|
||||
}
|
||||
|
48
src/base.rs
48
src/base.rs
@ -110,9 +110,9 @@ fn trans_fn<'a, 'tcx: 'a>(
|
||||
// Step 7. Write function to file for debugging
|
||||
let mut writer = crate::pretty_clif::CommentWriter(fx.comments);
|
||||
|
||||
let mut cton = String::new();
|
||||
let mut clif = String::new();
|
||||
if cfg!(debug_assertions) {
|
||||
::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None)
|
||||
::cranelift::codegen::write::decorate_function(&mut writer, &mut clif, &func, None)
|
||||
.unwrap();
|
||||
let clif_file_name = format!(
|
||||
"{}/{}__{}.clif",
|
||||
@ -120,7 +120,7 @@ fn trans_fn<'a, 'tcx: 'a>(
|
||||
tcx.crate_name(LOCAL_CRATE),
|
||||
tcx.symbol_name(instance).as_str(),
|
||||
);
|
||||
if let Err(e) = ::std::fs::write(clif_file_name, cton.as_bytes()) {
|
||||
if let Err(e) = ::std::fs::write(clif_file_name, clif.as_bytes()) {
|
||||
tcx.sess.warn(&format!("err writing clif file: {:?}", e));
|
||||
}
|
||||
}
|
||||
@ -452,7 +452,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
}
|
||||
UnOp::Neg => match layout.ty.sty {
|
||||
ty::Int(_) => {
|
||||
let clif_ty = fx.cton_type(layout.ty).unwrap();
|
||||
let clif_ty = fx.clif_type(layout.ty).unwrap();
|
||||
let zero = fx.bcx.ins().iconst(clif_ty, 0);
|
||||
fx.bcx.ins().isub(zero, val)
|
||||
}
|
||||
@ -495,20 +495,20 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
| (ty::Uint(_), ty::Int(_))
|
||||
| (ty::Uint(_), ty::Uint(_)) => {
|
||||
let from = operand.load_value(fx);
|
||||
let res = crate::common::cton_intcast(
|
||||
let res = crate::common::clif_intcast(
|
||||
fx,
|
||||
from,
|
||||
fx.cton_type(to_ty).unwrap(),
|
||||
fx.clif_type(to_ty).unwrap(),
|
||||
false,
|
||||
);
|
||||
lval.write_cvalue(fx, CValue::ByVal(res, dest_layout));
|
||||
}
|
||||
(ty::Int(_), ty::Int(_)) | (ty::Int(_), ty::Uint(_)) => {
|
||||
let from = operand.load_value(fx);
|
||||
let res = crate::common::cton_intcast(
|
||||
let res = crate::common::clif_intcast(
|
||||
fx,
|
||||
from,
|
||||
fx.cton_type(to_ty).unwrap(),
|
||||
fx.clif_type(to_ty).unwrap(),
|
||||
true,
|
||||
);
|
||||
lval.write_cvalue(fx, CValue::ByVal(res, dest_layout));
|
||||
@ -527,7 +527,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
lval.write_cvalue(fx, CValue::ByVal(res, dest_layout));
|
||||
}
|
||||
(ty::Int(_), ty::Float(_)) => {
|
||||
let from_ty = fx.cton_type(from_ty).unwrap();
|
||||
let from_ty = fx.clif_type(from_ty).unwrap();
|
||||
let from = operand.load_value(fx);
|
||||
// FIXME missing encoding for fcvt_from_sint.f32.i8
|
||||
let from = if from_ty == types::I8 || from_ty == types::I16 {
|
||||
@ -535,12 +535,12 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
} else {
|
||||
from
|
||||
};
|
||||
let f_type = fx.cton_type(to_ty).unwrap();
|
||||
let f_type = fx.clif_type(to_ty).unwrap();
|
||||
let res = fx.bcx.ins().fcvt_from_sint(f_type, from);
|
||||
lval.write_cvalue(fx, CValue::ByVal(res, dest_layout));
|
||||
}
|
||||
(ty::Uint(_), ty::Float(_)) => {
|
||||
let from_ty = fx.cton_type(from_ty).unwrap();
|
||||
let from_ty = fx.clif_type(from_ty).unwrap();
|
||||
let from = operand.load_value(fx);
|
||||
// FIXME missing encoding for fcvt_from_uint.f32.i8
|
||||
let from = if from_ty == types::I8 || from_ty == types::I16 {
|
||||
@ -548,12 +548,12 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
} else {
|
||||
from
|
||||
};
|
||||
let f_type = fx.cton_type(to_ty).unwrap();
|
||||
let f_type = fx.clif_type(to_ty).unwrap();
|
||||
let res = fx.bcx.ins().fcvt_from_uint(f_type, from);
|
||||
lval.write_cvalue(fx, CValue::ByVal(res, dest_layout));
|
||||
}
|
||||
(ty::Bool, ty::Uint(_)) | (ty::Bool, ty::Int(_)) => {
|
||||
let to_ty = fx.cton_type(to_ty).unwrap();
|
||||
let to_ty = fx.clif_type(to_ty).unwrap();
|
||||
let from = operand.load_value(fx);
|
||||
let res = if to_ty != types::I8 {
|
||||
fx.bcx.ins().uextend(to_ty, from)
|
||||
@ -605,7 +605,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
Rvalue::NullaryOp(NullOp::Box, content_ty) => {
|
||||
use rustc::middle::lang_items::ExchangeMallocFnLangItem;
|
||||
|
||||
let usize_type = fx.cton_type(fx.tcx.types.usize).unwrap();
|
||||
let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap();
|
||||
let (size, align) = fx.layout_of(content_ty).size_and_align();
|
||||
let llsize = fx.bcx.ins().iconst(usize_type, size.bytes() as i64);
|
||||
let llalign = fx.bcx.ins().iconst(usize_type, align.abi() as i64);
|
||||
@ -690,7 +690,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
||||
layout::Int(_, signed) => signed,
|
||||
_ => false,
|
||||
};
|
||||
let val = cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), signed);
|
||||
let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed);
|
||||
return CValue::ByVal(val, dest_layout);
|
||||
}
|
||||
layout::Variants::NicheFilling {
|
||||
@ -699,8 +699,8 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
||||
niche_start,
|
||||
..
|
||||
} => {
|
||||
let niche_llty = fx.cton_type(discr_ty).unwrap();
|
||||
let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap();
|
||||
let niche_llty = fx.clif_type(discr_ty).unwrap();
|
||||
let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap();
|
||||
if niche_variants.start() == niche_variants.end() {
|
||||
let b = fx
|
||||
.bcx
|
||||
@ -709,11 +709,11 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
||||
let if_true = fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iconst(dest_cton_ty, *niche_variants.start() as u64 as i64);
|
||||
.iconst(dest_clif_ty, *niche_variants.start() as u64 as i64);
|
||||
let if_false = fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iconst(dest_cton_ty, dataful_variant as u64 as i64);
|
||||
.iconst(dest_clif_ty, dataful_variant as u64 as i64);
|
||||
let val = fx.bcx.ins().select(b, if_true, if_false);
|
||||
return CValue::ByVal(val, dest_layout);
|
||||
} else {
|
||||
@ -727,11 +727,11 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
||||
*niche_variants.end() as u64 as i64,
|
||||
);
|
||||
let if_true =
|
||||
cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), false);
|
||||
clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false);
|
||||
let if_false = fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iconst(dest_cton_ty, dataful_variant as u64 as i64);
|
||||
.iconst(dest_clif_ty, dataful_variant as u64 as i64);
|
||||
let val = fx.bcx.ins().select(b, if_true, if_false);
|
||||
return CValue::ByVal(val, dest_layout);
|
||||
}
|
||||
@ -748,10 +748,10 @@ macro_rules! binop_match {
|
||||
let ret_layout = $fx.layout_of($ret_ty);
|
||||
|
||||
// TODO HACK no encoding for icmp.i8
|
||||
use crate::common::cton_intcast;
|
||||
use crate::common::clif_intcast;
|
||||
let (lhs, rhs) = (
|
||||
cton_intcast($fx, $lhs, types::I64, $signed),
|
||||
cton_intcast($fx, $rhs, types::I64, $signed),
|
||||
clif_intcast($fx, $lhs, types::I64, $signed),
|
||||
clif_intcast($fx, $rhs, types::I64, $signed),
|
||||
);
|
||||
let b = $fx.bcx.ins().icmp(IntCC::$cc, lhs, rhs);
|
||||
|
||||
|
@ -19,7 +19,7 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type {
|
||||
}
|
||||
}
|
||||
|
||||
fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type {
|
||||
fn scalar_to_clif_type(tcx: TyCtxt, scalar: &Scalar) -> Type {
|
||||
match scalar.value.size(&tcx).bits() {
|
||||
8 => types::I8,
|
||||
16 => types::I16,
|
||||
@ -29,7 +29,7 @@ fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cton_type_from_ty<'a, 'tcx: 'a>(
|
||||
pub fn clif_type_from_ty<'a, 'tcx: 'a>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Option<types::Type> {
|
||||
@ -157,7 +157,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
{
|
||||
match self {
|
||||
CValue::ByRef(addr, layout) => {
|
||||
let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| {
|
||||
let clif_ty = fx.clif_type(layout.ty).unwrap_or_else(|| {
|
||||
if layout.ty.is_box()
|
||||
&& !fx
|
||||
.layout_of(layout.ty.builtin_deref(true).unwrap().ty)
|
||||
@ -169,7 +169,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
panic!("load_value of type {:?}", layout.ty);
|
||||
}
|
||||
});
|
||||
fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0)
|
||||
fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0)
|
||||
}
|
||||
CValue::ByVal(value, _layout) => value,
|
||||
CValue::ByValPair(_, _, _layout) => bug!("Please use load_value_pair for ByValPair"),
|
||||
@ -294,9 +294,9 @@ impl<'tcx> CValue<'tcx> {
|
||||
where
|
||||
'tcx: 'a,
|
||||
{
|
||||
let cton_ty = fx.cton_type(ty).unwrap();
|
||||
let clif_ty = fx.clif_type(ty).unwrap();
|
||||
let layout = fx.layout_of(ty);
|
||||
CValue::ByVal(fx.bcx.ins().iconst(cton_ty, const_val), layout)
|
||||
CValue::ByVal(fx.bcx.ins().iconst(clif_ty, const_val), layout)
|
||||
}
|
||||
|
||||
pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self {
|
||||
@ -506,9 +506,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
||||
let ptr =
|
||||
fx.bcx
|
||||
.ins()
|
||||
.load(scalar_to_cton_type(fx.tcx, a), MemFlags::new(), addr, 0);
|
||||
.load(scalar_to_clif_type(fx.tcx, a), MemFlags::new(), addr, 0);
|
||||
let extra = fx.bcx.ins().load(
|
||||
scalar_to_cton_type(fx.tcx, b),
|
||||
scalar_to_clif_type(fx.tcx, b),
|
||||
MemFlags::new(),
|
||||
addr,
|
||||
a.value.size(&fx.tcx).bytes() as u32 as i32,
|
||||
@ -567,7 +567,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cton_intcast<'a, 'tcx: 'a>(
|
||||
pub fn clif_intcast<'a, 'tcx: 'a>(
|
||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||
val: Value,
|
||||
to: Type,
|
||||
@ -664,8 +664,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn cton_type(&self, ty: Ty<'tcx>) -> Option<Type> {
|
||||
cton_type_from_ty(self.tcx, self.monomorphize(&ty))
|
||||
pub fn clif_type(&self, ty: Ty<'tcx>) -> Option<Type> {
|
||||
clif_type_from_ty(self.tcx, self.monomorphize(&ty))
|
||||
}
|
||||
|
||||
pub fn get_ebb(&self, bb: BasicBlock) -> Ebb {
|
||||
|
@ -59,7 +59,7 @@ macro_rules! intrinsic_match {
|
||||
|
||||
macro_rules! atomic_binop_return_old {
|
||||
($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) => {
|
||||
let clif_ty = $fx.cton_type($T).unwrap();
|
||||
let clif_ty = $fx.clif_type($T).unwrap();
|
||||
let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0);
|
||||
let new = $fx.bcx.ins().band(old, $src);
|
||||
$fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0);
|
||||
@ -70,7 +70,7 @@ macro_rules! atomic_binop_return_old {
|
||||
macro_rules! atomic_minmax {
|
||||
($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ret:ident) => {
|
||||
// Read old
|
||||
let clif_ty = $fx.cton_type($T).unwrap();
|
||||
let clif_ty = $fx.clif_type($T).unwrap();
|
||||
let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0);
|
||||
|
||||
// Compare
|
||||
@ -362,7 +362,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
|
||||
};
|
||||
_ if intrinsic.starts_with("atomic_xchg"), <T> (v ptr, c src) {
|
||||
// Read old
|
||||
let clif_ty = fx.cton_type(T).unwrap();
|
||||
let clif_ty = fx.clif_type(T).unwrap();
|
||||
let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0);
|
||||
ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T)));
|
||||
|
||||
@ -372,7 +372,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
|
||||
};
|
||||
_ if intrinsic.starts_with("atomic_cxchg"), <T> (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_*
|
||||
// Read old
|
||||
let clif_ty = fx.cton_type(T).unwrap();
|
||||
let clif_ty = fx.clif_type(T).unwrap();
|
||||
let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0);
|
||||
|
||||
// Compare
|
||||
|
Loading…
Reference in New Issue
Block a user