Auto merge of #37347 - srinivasreddy:llvm, r=eddyb

run rustfmt on librustc_llvm folder
This commit is contained in:
bors 2016-10-23 05:17:01 -07:00 committed by GitHub
commit 1bc7f8f49f
4 changed files with 312 additions and 506 deletions

View File

@ -22,22 +22,21 @@ fn main() {
let target = env::var("TARGET").expect("TARGET was not set");
let llvm_config = env::var_os("LLVM_CONFIG")
.map(PathBuf::from)
.unwrap_or_else(|| {
if let Some(dir) = env::var_os("CARGO_TARGET_DIR")
.map(PathBuf::from) {
let to_test = dir.parent()
.unwrap()
.parent()
.unwrap()
.join(&target)
.join("llvm/bin/llvm-config");
if Command::new(&to_test).output().is_ok() {
return to_test;
}
}
PathBuf::from("llvm-config")
});
.map(PathBuf::from)
.unwrap_or_else(|| {
if let Some(dir) = env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
let to_test = dir.parent()
.unwrap()
.parent()
.unwrap()
.join(&target)
.join("llvm/bin/llvm-config");
if Command::new(&to_test).output().is_ok() {
return to_test;
}
}
PathBuf::from("llvm-config")
});
println!("cargo:rerun-if-changed={}", llvm_config.display());
@ -66,8 +65,8 @@ fn main() {
let host = env::var("HOST").expect("HOST was not set");
let is_crossed = target != host;
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz",
"jsbackend"];
let optional_components =
["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", "jsbackend"];
// FIXME: surely we don't need all these components, right? Stuff like mcjit
// or interpreter the compiler itself never uses.
@ -149,7 +148,7 @@ fn main() {
// that off
lib.trim_right_matches(".lib")
} else {
continue
continue;
};
// Don't need or want this library, but LLVM's CMake build system
@ -158,7 +157,7 @@ fn main() {
// library and it otherwise may just pull in extra dependencies on
// libedit which we don't want
if name == "LLVMLineEditor" {
continue
continue;
}
let kind = if name.starts_with("LLVM") {
@ -179,7 +178,7 @@ fn main() {
cmd.arg("--ldflags");
for lib in output(&mut cmd).split_whitespace() {
if lib.starts_with("-LIBPATH:") {
println!("cargo:rustc-link-search=native={}", &lib[9..]);
println!("cargo:rustc-link-search=native={}", &lib[9..]);
} else if is_crossed {
if lib.starts_with("-L") {
println!("cargo:rustc-link-search=native={}",

View File

@ -33,8 +33,7 @@ pub enum OptimizationDiagnosticKind {
impl OptimizationDiagnosticKind {
pub fn describe(self) -> &'static str {
match self {
OptimizationRemark |
OptimizationRemarkOther => "remark",
OptimizationRemark | OptimizationRemarkOther => "remark",
OptimizationMissed => "missed",
OptimizationAnalysis => "analysis",
OptimizationAnalysisFPCommute => "floating-point",
@ -130,18 +129,14 @@ impl Diagnostic {
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di))
}
Dk::OptimizationRemarkAnalysisFPCommute => {
Optimization(OptimizationDiagnostic::unpack(
OptimizationAnalysisFPCommute, di))
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysisFPCommute, di))
}
Dk::OptimizationRemarkAnalysisAliasing => {
Optimization(OptimizationDiagnostic::unpack(
OptimizationAnalysisAliasing, di))
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysisAliasing, di))
}
Dk::OptimizationFailure => {
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
}

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,9 @@
#![feature(concat_idents)]
extern crate libc;
#[macro_use] #[no_link] extern crate rustc_bitflags;
#[macro_use]
#[no_link]
extern crate rustc_bitflags;
pub use self::IntPredicate::*;
pub use self::RealPredicate::*;
@ -68,7 +70,7 @@ impl LLVMRustResult {
#[derive(Copy, Clone, Default, Debug)]
pub struct Attributes {
regular: Attribute,
dereferenceable_bytes: u64
dereferenceable_bytes: u64,
}
impl Attributes {
@ -96,10 +98,7 @@ impl Attributes {
unsafe {
self.regular.apply_llfn(idx, llfn);
if self.dereferenceable_bytes != 0 {
LLVMRustAddDereferenceableAttr(
llfn,
idx.as_uint(),
self.dereferenceable_bytes);
LLVMRustAddDereferenceableAttr(llfn, idx.as_uint(), self.dereferenceable_bytes);
}
}
}
@ -108,27 +107,23 @@ impl Attributes {
unsafe {
self.regular.apply_callsite(idx, callsite);
if self.dereferenceable_bytes != 0 {
LLVMRustAddDereferenceableCallSiteAttr(
callsite,
idx.as_uint(),
self.dereferenceable_bytes);
LLVMRustAddDereferenceableCallSiteAttr(callsite,
idx.as_uint(),
self.dereferenceable_bytes);
}
}
}
}
pub fn AddFunctionAttrStringValue(
llfn: ValueRef,
idx: AttributePlace,
attr: &'static str,
value: &'static str
) {
pub fn AddFunctionAttrStringValue(llfn: ValueRef,
idx: AttributePlace,
attr: &'static str,
value: &'static str) {
unsafe {
LLVMRustAddFunctionAttrStringValue(
llfn,
idx.as_uint(),
attr.as_ptr() as *const _,
value.as_ptr() as *const _)
LLVMRustAddFunctionAttrStringValue(llfn,
idx.as_uint(),
attr.as_ptr() as *const _,
value.as_ptr() as *const _)
}
}
@ -233,44 +228,30 @@ pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
impl Attribute {
pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
unsafe {
LLVMRustAddFunctionAttribute(
llfn, idx.as_uint(), self.bits())
}
unsafe { LLVMRustAddFunctionAttribute(llfn, idx.as_uint(), self.bits()) }
}
pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) {
unsafe {
LLVMRustAddCallSiteAttribute(
callsite, idx.as_uint(), self.bits())
}
unsafe { LLVMRustAddCallSiteAttribute(callsite, idx.as_uint(), self.bits()) }
}
pub fn unapply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
unsafe {
LLVMRustRemoveFunctionAttributes(
llfn, idx.as_uint(), self.bits())
}
unsafe { LLVMRustRemoveFunctionAttributes(llfn, idx.as_uint(), self.bits()) }
}
pub fn toggle_llfn(&self,
idx: AttributePlace,
llfn: ValueRef,
set: bool)
{
pub fn toggle_llfn(&self, idx: AttributePlace, llfn: ValueRef, set: bool) {
if set {
self.apply_llfn(idx, llfn);
} else {
self.unapply_llfn(idx, llfn);
}
}
}
/* Memory-managed interface to target data. */
// Memory-managed interface to target data.
pub struct TargetData {
pub lltd: TargetDataRef
pub lltd: TargetDataRef,
}
impl Drop for TargetData {
@ -283,12 +264,10 @@ impl Drop for TargetData {
pub fn mk_target_data(string_rep: &str) -> TargetData {
let string_rep = CString::new(string_rep).unwrap();
TargetData {
lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
}
TargetData { lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) } }
}
/* Memory-managed interface to object files. */
// Memory-managed interface to object files.
pub struct ObjectFile {
pub llof: ObjectFileRef,
@ -301,12 +280,10 @@ impl ObjectFile {
let llof = LLVMCreateObjectFile(llmb);
if llof as isize == 0 {
// LLVMCreateObjectFile took ownership of llmb
return None
return None;
}
Some(ObjectFile {
llof: llof,
})
Some(ObjectFile { llof: llof })
}
}
}
@ -319,10 +296,10 @@ impl Drop for ObjectFile {
}
}
/* Memory-managed interface to section iterators. */
// Memory-managed interface to section iterators.
pub struct SectionIter {
pub llsi: SectionIteratorRef
pub llsi: SectionIteratorRef,
}
impl Drop for SectionIter {
@ -334,11 +311,7 @@ impl Drop for SectionIter {
}
pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
unsafe {
SectionIter {
llsi: LLVMGetSections(llof)
}
}
unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
}
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
@ -361,15 +334,16 @@ pub fn get_params(llfn: ValueRef) -> Vec<ValueRef> {
}
}
pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
pub fn build_string<F>(f: F) -> Option<String>
where F: FnOnce(RustStringRef)
{
let mut buf = RefCell::new(Vec::new());
f(&mut buf as RustStringRepr as RustStringRef);
String::from_utf8(buf.into_inner()).ok()
}
pub unsafe fn twine_to_string(tr: TwineRef) -> String {
build_string(|s| LLVMRustWriteTwineToString(tr, s))
.expect("got a non-UTF8 Twine from LLVM")
build_string(|s| LLVMRustWriteTwineToString(tr, s)).expect("got a non-UTF8 Twine from LLVM")
}
pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
@ -462,9 +436,7 @@ impl OperandBundleDef {
pub fn new(name: &str, vals: &[ValueRef]) -> OperandBundleDef {
let name = CString::new(name).unwrap();
let def = unsafe {
LLVMRustBuildOperandBundleDef(name.as_ptr(),
vals.as_ptr(),
vals.len() as c_uint)
LLVMRustBuildOperandBundleDef(name.as_ptr(), vals.as_ptr(), vals.len() as c_uint)
};
OperandBundleDef { inner: def }
}