summaryrefslogtreecommitdiff
path: root/src/librustc_trans/trans/builder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_trans/trans/builder.rs')
-rw-r--r--src/librustc_trans/trans/builder.rs89
1 files changed, 31 insertions, 58 deletions
diff --git a/src/librustc_trans/trans/builder.rs b/src/librustc_trans/trans/builder.rs
index 3b4a67cb089..7f8e8393e8c 100644
--- a/src/librustc_trans/trans/builder.rs
+++ b/src/librustc_trans/trans/builder.rs
@@ -11,13 +11,14 @@
#![allow(dead_code)] // FFI wrappers
use llvm;
-use llvm::{CallConv, AtomicBinOp, AtomicOrdering, SynchronizationScope, AsmDialect, AttrBuilder};
+use llvm::{AtomicBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef};
use llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef};
use trans::base;
use trans::common::*;
use trans::machine::llalign_of_pref;
use trans::type_::Type;
+use trans::value::Value;
use util::nodemap::FnvHashMap;
use libc::{c_uint, c_char};
@@ -164,33 +165,28 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
args: &[ValueRef],
then: BasicBlockRef,
catch: BasicBlockRef,
- bundle: Option<&OperandBundleDef>,
- attributes: Option<AttrBuilder>)
+ bundle: Option<&OperandBundleDef>)
-> ValueRef {
self.count_insn("invoke");
- debug!("Invoke {} with args ({})",
- self.ccx.tn().val_to_string(llfn),
+ debug!("Invoke {:?} with args ({})",
+ Value(llfn),
args.iter()
- .map(|&v| self.ccx.tn().val_to_string(v))
+ .map(|&v| format!("{:?}", Value(v)))
.collect::<Vec<String>>()
.join(", "));
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(0 as *mut _);
unsafe {
- let v = llvm::LLVMRustBuildInvoke(self.llbuilder,
- llfn,
- args.as_ptr(),
- args.len() as c_uint,
- then,
- catch,
- bundle,
- noname());
- if let Some(a) = attributes {
- a.apply_callsite(v);
- }
- v
+ llvm::LLVMRustBuildInvoke(self.llbuilder,
+ llfn,
+ args.as_ptr(),
+ args.len() as c_uint,
+ then,
+ catch,
+ bundle,
+ noname())
}
}
@@ -497,9 +493,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
pub fn store(&self, val: ValueRef, ptr: ValueRef) -> ValueRef {
- debug!("Store {} -> {}",
- self.ccx.tn().val_to_string(val),
- self.ccx.tn().val_to_string(ptr));
+ debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
assert!(!self.llbuilder.is_null());
self.count_insn("store");
unsafe {
@@ -508,9 +502,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
pub fn volatile_store(&self, val: ValueRef, ptr: ValueRef) -> ValueRef {
- debug!("Store {} -> {}",
- self.ccx.tn().val_to_string(val),
- self.ccx.tn().val_to_string(ptr));
+ debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
assert!(!self.llbuilder.is_null());
self.count_insn("store.volatile");
unsafe {
@@ -521,9 +513,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
pub fn atomic_store(&self, val: ValueRef, ptr: ValueRef, order: AtomicOrdering) {
- debug!("Store {} -> {}",
- self.ccx.tn().val_to_string(val),
- self.ccx.tn().val_to_string(ptr));
+ debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
self.count_insn("store.atomic");
unsafe {
let ty = Type::from_ref(llvm::LLVMTypeOf(ptr));
@@ -780,7 +770,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
comment_text.as_ptr(), noname(), False,
False)
};
- self.call(asm, &[], None, None);
+ self.call(asm, &[], None);
}
}
@@ -796,28 +786,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
else { llvm::False };
let argtys = inputs.iter().map(|v| {
- debug!("Asm Input Type: {}", self.ccx.tn().val_to_string(*v));
+ debug!("Asm Input Type: {:?}", Value(*v));
val_ty(*v)
}).collect::<Vec<_>>();
- debug!("Asm Output Type: {}", self.ccx.tn().type_to_string(output));
+ debug!("Asm Output Type: {:?}", output);
let fty = Type::func(&argtys[..], &output);
unsafe {
let v = llvm::LLVMInlineAsm(
fty.to_ref(), asm, cons, volatile, alignstack, dia as c_uint);
- self.call(v, inputs, None, None)
+ self.call(v, inputs, None)
}
}
pub fn call(&self, llfn: ValueRef, args: &[ValueRef],
- bundle: Option<&OperandBundleDef>,
- attributes: Option<AttrBuilder>) -> ValueRef {
+ bundle: Option<&OperandBundleDef>) -> ValueRef {
self.count_insn("call");
- debug!("Call {} with args ({})",
- self.ccx.tn().val_to_string(llfn),
+ debug!("Call {:?} with args ({})",
+ Value(llfn),
args.iter()
- .map(|&v| self.ccx.tn().val_to_string(v))
+ .map(|&v| format!("{:?}", Value(v)))
.collect::<Vec<String>>()
.join(", "));
@@ -838,11 +827,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if expected_ty != actual_ty {
self.ccx.sess().bug(
&format!(
- "Type mismatch in function call of {}. Expected {} for param {}, got {}",
- self.ccx.tn().val_to_string(llfn),
- self.ccx.tn().type_to_string(expected_ty),
- i,
- self.ccx.tn().type_to_string(actual_ty)));
+ "Type mismatch in function call of {:?}. \
+ Expected {:?} for param {}, got {:?}",
+ Value(llfn),
+ expected_ty, i, actual_ty));
}
}
@@ -850,26 +838,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(0 as *mut _);
unsafe {
- let v = llvm::LLVMRustBuildCall(self.llbuilder, llfn, args.as_ptr(),
- args.len() as c_uint, bundle,
- noname());
- if let Some(a) = attributes {
- a.apply_callsite(v);
- }
- v
+ llvm::LLVMRustBuildCall(self.llbuilder, llfn, args.as_ptr(),
+ args.len() as c_uint, bundle, noname())
}
}
- pub fn call_with_conv(&self, llfn: ValueRef, args: &[ValueRef],
- conv: CallConv,
- bundle: Option<&OperandBundleDef>,
- attributes: Option<AttrBuilder>) -> ValueRef {
- self.count_insn("callwithconv");
- let v = self.call(llfn, args, bundle, attributes);
- llvm::SetInstructionCallConv(v, conv);
- v
- }
-
pub fn select(&self, cond: ValueRef, then_val: ValueRef, else_val: ValueRef) -> ValueRef {
self.count_insn("select");
unsafe {