use middle::trans::common::*;
use middle::trans::machine::llalign_of_pref;
use middle::trans::type_::Type;
-use collections::HashMap;
+use std::collections::HashMap;
use libc::{c_uint, c_ulonglong, c_char};
-use std::strbuf::StrBuf;
+use std::string::String;
use syntax::codemap::Span;
pub struct Builder<'a> {
// This is a really awful way to get a zero-length c-string, but better (and a
// lot more efficient) than doing str::as_c_str("", ...) every time.
-pub fn noname() -> *c_char {
+pub fn noname() -> *const c_char {
static cnull: c_char = 0;
- &cnull as *c_char
+ &cnull as *const c_char
}
impl<'a> Builder<'a> {
// Pass 2: concat strings for each elt, skipping
// forwards over any cycles by advancing to rightmost
// occurrence of each element in path.
- let mut s = StrBuf::from_str(".");
+ let mut s = String::from_str(".");
i = 0u;
while i < len {
i = *mm.get(&v[i]);
args: &[ValueRef],
then: BasicBlockRef,
catch: BasicBlockRef,
- attributes: &[(uint, lib::llvm::Attribute)])
+ attributes: &[(uint, u64)])
-> ValueRef {
self.count_insn("invoke");
+
+ debug!("Invoke {} with args ({})",
+ self.ccx.tn.val_to_str(llfn),
+ args.iter()
+ .map(|&v| self.ccx.tn.val_to_str(v))
+ .collect::<Vec<String>>()
+ .connect(", "));
+
unsafe {
let v = llvm::LLVMBuildInvoke(self.llbuilder,
llfn,
catch,
noname());
for &(idx, attr) in attributes.iter() {
- llvm::LLVMAddInstrAttribute(v, idx as c_uint, attr as c_uint);
+ llvm::LLVMAddCallSiteAttribute(v, idx as c_uint, attr);
}
v
}
}
}
- pub fn global_string(&self, _str: *c_char) -> ValueRef {
+ pub fn global_string(&self, _str: *const c_char) -> ValueRef {
self.count_insn("globalstring");
unsafe {
llvm::LLVMBuildGlobalString(self.llbuilder, _str, noname())
}
}
- pub fn global_string_ptr(&self, _str: *c_char) -> ValueRef {
+ pub fn global_string_ptr(&self, _str: *const c_char) -> ValueRef {
self.count_insn("globalstringptr");
unsafe {
llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _str, noname())
pub fn add_comment(&self, text: &str) {
if self.ccx.sess().asm_comments() {
let sanitized = text.replace("$", "");
- let comment_text = format!("\\# {}", sanitized.replace("\n", "\n\t# "));
+ let comment_text = format!("{} {}", "#",
+ sanitized.replace("\n", "\n\t# "));
self.count_insn("inlineasm");
let asm = comment_text.as_slice().with_c_str(|c| {
unsafe {
}
}
- pub fn inline_asm_call(&self, asm: *c_char, cons: *c_char,
+ pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
inputs: &[ValueRef], output: Type,
volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef {
}
pub fn call(&self, llfn: ValueRef, args: &[ValueRef],
- attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
+ attributes: &[(uint, u64)]) -> ValueRef {
self.count_insn("call");
debug!("Call {} with args ({})",
self.ccx.tn.val_to_str(llfn),
args.iter()
.map(|&v| self.ccx.tn.val_to_str(v))
- .collect::<Vec<StrBuf>>()
+ .collect::<Vec<String>>()
.connect(", "));
unsafe {
let v = llvm::LLVMBuildCall(self.llbuilder, llfn, args.as_ptr(),
args.len() as c_uint, noname());
for &(idx, attr) in attributes.iter() {
- llvm::LLVMAddInstrAttribute(v, idx as c_uint, attr as c_uint);
+ llvm::LLVMAddCallSiteAttribute(v, idx as c_uint, attr);
}
v
}
}
pub fn call_with_conv(&self, llfn: ValueRef, args: &[ValueRef],
- conv: CallConv, attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
+ conv: CallConv, attributes: &[(uint, u64)]) -> ValueRef {
self.count_insn("callwithconv");
let v = self.call(llfn, args, attributes);
lib::llvm::SetInstructionCallConv(v, conv);