ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP)
}
-pub struct OperandBundleDef<'a, Value : 'a> {
+pub struct OperandBundleDef<'a, Value: 'a> {
pub name: &'a str,
pub val: Value
}
type Context = &'ll llvm::Context;
}
-impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx> {
+impl<'ll, 'tcx: 'll> CommonMethods for CodegenCx<'ll, 'tcx> {
// LLVM constant constructors.
fn c_null(&self, t: &'ll Type) -> &'ll Value {
&self.c_struct_in_context(&self.llcx, elts, packed)
}
- fn c_array(ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
+ fn c_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
unsafe {
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
}
}
- fn c_vector(elts: &[&'ll Value]) -> &'ll Value {
+ fn c_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
unsafe {
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
}
&self.c_bytes_in_context(&self.llcx, bytes)
}
- fn const_get_elt(v: &'ll Value, idx: u64) -> &'ll Value {
+ fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
unsafe {
assert_eq!(idx as c_uint as u64, idx);
let us = &[idx as c_uint];
}
}
- fn const_get_real(v: &'ll Value) -> Option<(f64, bool)> {
+ fn const_get_real(&self, v: &'ll Value) -> Option<(f64, bool)> {
unsafe {
- if Self::is_const_real(v) {
+ if self.is_const_real(v) {
let mut loses_info: llvm::Bool = ::std::mem::uninitialized();
let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info);
let loses_info = if loses_info == 1 { true } else { false };
}
}
- fn const_to_uint(v: &'ll Value) -> u64 {
+ fn const_to_uint(&self, v: &'ll Value) -> u64 {
unsafe {
llvm::LLVMConstIntGetZExtValue(v)
}
}
- fn is_const_integral(v: &'ll Value) -> bool {
+ fn is_const_integral(&self, v: &'ll Value) -> bool {
unsafe {
llvm::LLVMIsAConstantInt(v).is_some()
}
}
- fn is_const_real(v: &'ll Value) -> bool {
+ fn is_const_real(&self, v: &'ll Value) -> bool {
unsafe {
llvm::LLVMIsAConstantFP(v).is_some()
}
}
- fn const_to_opt_u128(v: &'ll Value, sign_ext: bool) -> Option<u128> {
+ fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
unsafe {
- if Self::is_const_integral(v) {
+ if self.is_const_integral(v) {
let (mut lo, mut hi) = (0u64, 0u64);
let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
&mut hi, &mut lo);
}
}
-impl<'ll, 'tcx : 'll> CommonWriteMethods for CodegenCx<'ll, 'tcx> {
+pub fn val_ty(v: &'ll Value) -> &'ll Type {
+ unsafe {
+ llvm::LLVMTypeOf(v)
+ }
+}
+
+pub fn c_bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
+ unsafe {
+ let ptr = bytes.as_ptr() as *const c_char;
+ return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True);
+ }
+}
+
+pub fn c_struct_in_context(
+ llcx: &'a llvm::Context,
+ elts: &[&'a Value],
+ packed: bool,
+) -> &'a Value {
+ unsafe {
+ llvm::LLVMConstStructInContext(llcx,
+ elts.as_ptr(), elts.len() as c_uint,
+ packed as Bool)
+ }
+}
+
+impl<'ll, 'tcx: 'll> CommonWriteMethods for CodegenCx<'ll, 'tcx> {
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
- unsafe {
- llvm::LLVMTypeOf(v)
- }
+ val_ty(v)
}
fn c_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
- unsafe {
- let ptr = bytes.as_ptr() as *const c_char;
- return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True);
- }
+ c_bytes_in_context(llcx, bytes)
}
fn c_struct_in_context(
elts: &[&'a Value],
packed: bool,
) -> &'a Value {
- unsafe {
- llvm::LLVMConstStructInContext(llcx,
- elts.as_ptr(), elts.len() as c_uint,
- packed as Bool)
- }
+ c_struct_in_context(llcx, elts, packed)
}
}