mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
Auto merge of #61299 - eddyb:nicer-llvm-builder, r=rkruppe
rustc_codegen_llvm: a couple builder niceties. r? @nagisa cc @sunfishcode @rkruppe
This commit is contained in:
commit
aa5bd03892
@ -20,6 +20,7 @@ use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef};
|
|||||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||||
use rustc_target::spec::{HasTargetSpec, Target};
|
use rustc_target::spec::{HasTargetSpec, Target};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::ffi::CStr;
|
||||||
use std::ops::{Deref, Range};
|
use std::ops::{Deref, Range};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::iter::TrustedLen;
|
use std::iter::TrustedLen;
|
||||||
@ -39,12 +40,15 @@ impl Drop for Builder<'a, 'll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a really awful way to get a zero-length c-string, but better (and a
|
// FIXME(eddyb) use a checked constructor when they become `const fn`.
|
||||||
// lot more efficient) than doing str::as_c_str("", ...) every time.
|
const EMPTY_C_STR: &CStr = unsafe {
|
||||||
fn noname() -> *const c_char {
|
CStr::from_bytes_with_nul_unchecked(b"\0")
|
||||||
static CNULL: c_char = 0;
|
};
|
||||||
&CNULL
|
|
||||||
}
|
/// Empty string, to be used where LLVM expects an instruction name, indicating
|
||||||
|
/// that the instruction is to be left unnamed (i.e. numbered, in textual IR).
|
||||||
|
// FIXME(eddyb) pass `&CStr` directly to FFI once it's a thin pointer.
|
||||||
|
const UNNAMED: *const c_char = EMPTY_C_STR.as_ptr();
|
||||||
|
|
||||||
impl BackendTypes for Builder<'_, 'll, 'tcx> {
|
impl BackendTypes for Builder<'_, 'll, 'tcx> {
|
||||||
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
|
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
|
||||||
@ -100,6 +104,16 @@ impl HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||||||
type CodegenCx = CodegenCx<'ll, 'tcx>;
|
type CodegenCx = CodegenCx<'ll, 'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! builder_methods_for_value_instructions {
|
||||||
|
($($name:ident($($arg:ident),*) => $llvm_capi:ident),+ $(,)?) => {
|
||||||
|
$(fn $name(&mut self, $($arg: &'ll Value),*) -> &'ll Value {
|
||||||
|
unsafe {
|
||||||
|
llvm::$llvm_capi(self.llbuilder, $($arg,)* UNNAMED)
|
||||||
|
}
|
||||||
|
})*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
fn new_block<'b>(
|
fn new_block<'b>(
|
||||||
cx: &'a CodegenCx<'ll, 'tcx>,
|
cx: &'a CodegenCx<'ll, 'tcx>,
|
||||||
@ -217,7 +231,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
then,
|
then,
|
||||||
catch,
|
catch,
|
||||||
bundle,
|
bundle,
|
||||||
noname())
|
UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,186 +241,72 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arithmetic */
|
builder_methods_for_value_instructions! {
|
||||||
fn add(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
add(a, b) => LLVMBuildAdd,
|
||||||
unsafe {
|
fadd(a, b) => LLVMBuildFAdd,
|
||||||
llvm::LLVMBuildAdd(self.llbuilder, lhs, rhs, noname())
|
sub(a, b) => LLVMBuildSub,
|
||||||
}
|
fsub(a, b) => LLVMBuildFSub,
|
||||||
}
|
mul(a, b) => LLVMBuildMul,
|
||||||
|
fmul(a, b) => LLVMBuildFMul,
|
||||||
fn fadd(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
udiv(a, b) => LLVMBuildUDiv,
|
||||||
unsafe {
|
exactudiv(a, b) => LLVMBuildExactUDiv,
|
||||||
llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, noname())
|
sdiv(a, b) => LLVMBuildSDiv,
|
||||||
}
|
exactsdiv(a, b) => LLVMBuildExactSDiv,
|
||||||
|
fdiv(a, b) => LLVMBuildFDiv,
|
||||||
|
urem(a, b) => LLVMBuildURem,
|
||||||
|
srem(a, b) => LLVMBuildSRem,
|
||||||
|
frem(a, b) => LLVMBuildFRem,
|
||||||
|
shl(a, b) => LLVMBuildShl,
|
||||||
|
lshr(a, b) => LLVMBuildLShr,
|
||||||
|
ashr(a, b) => LLVMBuildAShr,
|
||||||
|
and(a, b) => LLVMBuildAnd,
|
||||||
|
or(a, b) => LLVMBuildOr,
|
||||||
|
xor(a, b) => LLVMBuildXor,
|
||||||
|
neg(x) => LLVMBuildNeg,
|
||||||
|
fneg(x) => LLVMBuildFNeg,
|
||||||
|
not(x) => LLVMBuildNot,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fadd_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn fadd_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, noname());
|
let instr = llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, UNNAMED);
|
||||||
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sub(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildSub(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fsub(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fsub_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn fsub_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, noname());
|
let instr = llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, UNNAMED);
|
||||||
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mul(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildMul(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fmul(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fmul_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn fmul_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, noname());
|
let instr = llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, UNNAMED);
|
||||||
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn udiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildUDiv(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn exactudiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildExactUDiv(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sdiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildSDiv(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn exactsdiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildExactSDiv(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fdiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fdiv_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn fdiv_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, noname());
|
let instr = llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, UNNAMED);
|
||||||
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn urem(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildURem(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn srem(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildSRem(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn frem(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn frem_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn frem_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, noname());
|
let instr = llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, UNNAMED);
|
||||||
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shl(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildShl(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lshr(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildLShr(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ashr(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildAShr(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn and(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildAnd(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn or(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildOr(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn xor(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildXor(self.llbuilder, lhs, rhs, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn neg(&mut self, v: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildNeg(self.llbuilder, v, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fneg(&mut self, v: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildFNeg(self.llbuilder, v, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn not(&mut self, v: &'ll Value) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
llvm::LLVMBuildNot(self.llbuilder, v, noname())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn checked_binop(
|
fn checked_binop(
|
||||||
&mut self,
|
&mut self,
|
||||||
oop: OverflowOp,
|
oop: OverflowOp,
|
||||||
@ -492,7 +392,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
fn dynamic_alloca(&mut self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value {
|
fn dynamic_alloca(&mut self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let alloca = if name.is_empty() {
|
let alloca = if name.is_empty() {
|
||||||
llvm::LLVMBuildAlloca(self.llbuilder, ty, noname())
|
llvm::LLVMBuildAlloca(self.llbuilder, ty, UNNAMED)
|
||||||
} else {
|
} else {
|
||||||
let name = SmallCStr::new(name);
|
let name = SmallCStr::new(name);
|
||||||
llvm::LLVMBuildAlloca(self.llbuilder, ty,
|
llvm::LLVMBuildAlloca(self.llbuilder, ty,
|
||||||
@ -510,7 +410,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
align: Align) -> &'ll Value {
|
align: Align) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let alloca = if name.is_empty() {
|
let alloca = if name.is_empty() {
|
||||||
llvm::LLVMBuildArrayAlloca(self.llbuilder, ty, len, noname())
|
llvm::LLVMBuildArrayAlloca(self.llbuilder, ty, len, UNNAMED)
|
||||||
} else {
|
} else {
|
||||||
let name = SmallCStr::new(name);
|
let name = SmallCStr::new(name);
|
||||||
llvm::LLVMBuildArrayAlloca(self.llbuilder, ty, len,
|
llvm::LLVMBuildArrayAlloca(self.llbuilder, ty, len,
|
||||||
@ -523,7 +423,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
|
|
||||||
fn load(&mut self, ptr: &'ll Value, align: Align) -> &'ll Value {
|
fn load(&mut self, ptr: &'ll Value, align: Align) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname());
|
let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, UNNAMED);
|
||||||
llvm::LLVMSetAlignment(load, align.bytes() as c_uint);
|
llvm::LLVMSetAlignment(load, align.bytes() as c_uint);
|
||||||
load
|
load
|
||||||
}
|
}
|
||||||
@ -531,7 +431,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
|
|
||||||
fn volatile_load(&mut self, ptr: &'ll Value) -> &'ll Value {
|
fn volatile_load(&mut self, ptr: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname());
|
let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, UNNAMED);
|
||||||
llvm::LLVMSetVolatile(load, llvm::True);
|
llvm::LLVMSetVolatile(load, llvm::True);
|
||||||
load
|
load
|
||||||
}
|
}
|
||||||
@ -547,7 +447,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
let load = llvm::LLVMRustBuildAtomicLoad(
|
let load = llvm::LLVMRustBuildAtomicLoad(
|
||||||
self.llbuilder,
|
self.llbuilder,
|
||||||
ptr,
|
ptr,
|
||||||
noname(),
|
UNNAMED,
|
||||||
AtomicOrdering::from_generic(order),
|
AtomicOrdering::from_generic(order),
|
||||||
);
|
);
|
||||||
// LLVM requires the alignment of atomic loads to be at least the size of the type.
|
// LLVM requires the alignment of atomic loads to be at least the size of the type.
|
||||||
@ -750,88 +650,88 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
fn gep(&mut self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value {
|
fn gep(&mut self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildGEP(self.llbuilder, ptr, indices.as_ptr(),
|
llvm::LLVMBuildGEP(self.llbuilder, ptr, indices.as_ptr(),
|
||||||
indices.len() as c_uint, noname())
|
indices.len() as c_uint, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inbounds_gep(&mut self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value {
|
fn inbounds_gep(&mut self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildInBoundsGEP(
|
llvm::LLVMBuildInBoundsGEP(
|
||||||
self.llbuilder, ptr, indices.as_ptr(), indices.len() as c_uint, noname())
|
self.llbuilder, ptr, indices.as_ptr(), indices.len() as c_uint, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn struct_gep(&mut self, ptr: &'ll Value, idx: u64) -> &'ll Value {
|
fn struct_gep(&mut self, ptr: &'ll Value, idx: u64) -> &'ll Value {
|
||||||
assert_eq!(idx as c_uint as u64, idx);
|
assert_eq!(idx as c_uint as u64, idx);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildStructGEP(self.llbuilder, ptr, idx as c_uint, noname())
|
llvm::LLVMBuildStructGEP(self.llbuilder, ptr, idx as c_uint, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Casts */
|
/* Casts */
|
||||||
fn trunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn trunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildTrunc(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildTrunc(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn sext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildSExt(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildSExt(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fptoui(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn fptoui(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildFPToUI(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildFPToUI(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildFPToSI(self.llbuilder, val, dest_ty,noname())
|
llvm::LLVMBuildFPToSI(self.llbuilder, val, dest_ty,UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uitofp(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn uitofp(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildUIToFP(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildUIToFP(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sitofp(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn sitofp(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildSIToFP(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildSIToFP(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fptrunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn fptrunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildFPTrunc(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildFPTrunc(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fpext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn fpext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildFPExt(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildFPExt(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ptrtoint(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn ptrtoint(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildPtrToInt(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildPtrToInt(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inttoptr(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn inttoptr(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildIntToPtr(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildIntToPtr(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bitcast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn bitcast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildBitCast(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildBitCast(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +744,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
|
|
||||||
fn pointercast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn pointercast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildPointerCast(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildPointerCast(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -852,13 +752,13 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
fn icmp(&mut self, op: IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn icmp(&mut self, op: IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
let op = llvm::IntPredicate::from_generic(op);
|
let op = llvm::IntPredicate::from_generic(op);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildICmp(self.llbuilder, op as c_uint, lhs, rhs, noname())
|
llvm::LLVMBuildICmp(self.llbuilder, op as c_uint, lhs, rhs, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fcmp(&mut self, op: RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
fn fcmp(&mut self, op: RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildFCmp(self.llbuilder, op as c_uint, lhs, rhs, noname())
|
llvm::LLVMBuildFCmp(self.llbuilder, op as c_uint, lhs, rhs, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,20 +826,20 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
else_val: &'ll Value,
|
else_val: &'ll Value,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildSelect(self.llbuilder, cond, then_val, else_val, noname())
|
llvm::LLVMBuildSelect(self.llbuilder, cond, then_val, else_val, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value {
|
fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildVAArg(self.llbuilder, list, ty, noname())
|
llvm::LLVMBuildVAArg(self.llbuilder, list, ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_element(&mut self, vec: &'ll Value, idx: &'ll Value) -> &'ll Value {
|
fn extract_element(&mut self, vec: &'ll Value, idx: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildExtractElement(self.llbuilder, vec, idx, noname())
|
llvm::LLVMBuildExtractElement(self.llbuilder, vec, idx, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,7 +856,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
fn extract_value(&mut self, agg_val: &'ll Value, idx: u64) -> &'ll Value {
|
fn extract_value(&mut self, agg_val: &'ll Value, idx: u64) -> &'ll Value {
|
||||||
assert_eq!(idx as c_uint as u64, idx);
|
assert_eq!(idx as c_uint as u64, idx);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildExtractValue(self.llbuilder, agg_val, idx as c_uint, noname())
|
llvm::LLVMBuildExtractValue(self.llbuilder, agg_val, idx as c_uint, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,7 +865,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
assert_eq!(idx as c_uint as u64, idx);
|
assert_eq!(idx as c_uint as u64, idx);
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildInsertValue(self.llbuilder, agg_val, elt, idx as c_uint,
|
llvm::LLVMBuildInsertValue(self.llbuilder, agg_val, elt, idx as c_uint,
|
||||||
noname())
|
UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +873,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
num_clauses: usize) -> &'ll Value {
|
num_clauses: usize) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn,
|
llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn,
|
||||||
num_clauses as c_uint, noname())
|
num_clauses as c_uint, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,14 +1043,14 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||||||
llfn,
|
llfn,
|
||||||
args.as_ptr() as *const &llvm::Value,
|
args.as_ptr() as *const &llvm::Value,
|
||||||
args.len() as c_uint,
|
args.len() as c_uint,
|
||||||
bundle, noname()
|
bundle, UNNAMED
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, noname())
|
llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1232,7 +1132,7 @@ impl Builder<'a, 'll, 'tcx> {
|
|||||||
idx: &'ll Value,
|
idx: &'ll Value,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildInsertElement(self.llbuilder, vec, elt, idx, noname())
|
llvm::LLVMBuildInsertElement(self.llbuilder, vec, elt, idx, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1243,7 +1143,7 @@ impl Builder<'a, 'll, 'tcx> {
|
|||||||
mask: &'ll Value,
|
mask: &'ll Value,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildShuffleVector(self.llbuilder, v1, v2, mask, noname())
|
llvm::LLVMBuildShuffleVector(self.llbuilder, v1, v2, mask, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,7 +1285,7 @@ impl Builder<'a, 'll, 'tcx> {
|
|||||||
|
|
||||||
pub fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value {
|
pub fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildVAArg(self.llbuilder, list, ty, noname())
|
llvm::LLVMBuildVAArg(self.llbuilder, list, ty, UNNAMED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1408,7 +1308,7 @@ impl Builder<'a, 'll, 'tcx> {
|
|||||||
fn phi(&mut self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value {
|
fn phi(&mut self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value {
|
||||||
assert_eq!(vals.len(), bbs.len());
|
assert_eq!(vals.len(), bbs.len());
|
||||||
let phi = unsafe {
|
let phi = unsafe {
|
||||||
llvm::LLVMBuildPhi(self.llbuilder, ty, noname())
|
llvm::LLVMBuildPhi(self.llbuilder, ty, UNNAMED)
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMAddIncoming(phi, vals.as_ptr(),
|
llvm::LLVMAddIncoming(phi, vals.as_ptr(),
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
#![feature(const_cstr_unchecked)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(custom_attribute)]
|
#![feature(custom_attribute)]
|
||||||
#![feature(extern_types)]
|
#![feature(extern_types)]
|
||||||
|
Loading…
Reference in New Issue
Block a user