Auto merge of #37347 - srinivasreddy:llvm, r=eddyb
run rustfmt on librustc_llvm folder
This commit is contained in:
commit
1bc7f8f49f
|
@ -24,8 +24,7 @@ fn main() {
|
||||||
let llvm_config = env::var_os("LLVM_CONFIG")
|
let llvm_config = env::var_os("LLVM_CONFIG")
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
if let Some(dir) = env::var_os("CARGO_TARGET_DIR")
|
if let Some(dir) = env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
|
||||||
.map(PathBuf::from) {
|
|
||||||
let to_test = dir.parent()
|
let to_test = dir.parent()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.parent()
|
.parent()
|
||||||
|
@ -66,8 +65,8 @@ fn main() {
|
||||||
let host = env::var("HOST").expect("HOST was not set");
|
let host = env::var("HOST").expect("HOST was not set");
|
||||||
let is_crossed = target != host;
|
let is_crossed = target != host;
|
||||||
|
|
||||||
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz",
|
let optional_components =
|
||||||
"jsbackend"];
|
["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", "jsbackend"];
|
||||||
|
|
||||||
// FIXME: surely we don't need all these components, right? Stuff like mcjit
|
// FIXME: surely we don't need all these components, right? Stuff like mcjit
|
||||||
// or interpreter the compiler itself never uses.
|
// or interpreter the compiler itself never uses.
|
||||||
|
@ -149,7 +148,7 @@ fn main() {
|
||||||
// that off
|
// that off
|
||||||
lib.trim_right_matches(".lib")
|
lib.trim_right_matches(".lib")
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't need or want this library, but LLVM's CMake build system
|
// 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
|
// library and it otherwise may just pull in extra dependencies on
|
||||||
// libedit which we don't want
|
// libedit which we don't want
|
||||||
if name == "LLVMLineEditor" {
|
if name == "LLVMLineEditor" {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let kind = if name.starts_with("LLVM") {
|
let kind = if name.starts_with("LLVM") {
|
||||||
|
|
|
@ -33,8 +33,7 @@ pub enum OptimizationDiagnosticKind {
|
||||||
impl OptimizationDiagnosticKind {
|
impl OptimizationDiagnosticKind {
|
||||||
pub fn describe(self) -> &'static str {
|
pub fn describe(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
OptimizationRemark |
|
OptimizationRemark | OptimizationRemarkOther => "remark",
|
||||||
OptimizationRemarkOther => "remark",
|
|
||||||
OptimizationMissed => "missed",
|
OptimizationMissed => "missed",
|
||||||
OptimizationAnalysis => "analysis",
|
OptimizationAnalysis => "analysis",
|
||||||
OptimizationAnalysisFPCommute => "floating-point",
|
OptimizationAnalysisFPCommute => "floating-point",
|
||||||
|
@ -130,18 +129,14 @@ impl Diagnostic {
|
||||||
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di))
|
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Dk::OptimizationRemarkAnalysisFPCommute => {
|
Dk::OptimizationRemarkAnalysisFPCommute => {
|
||||||
Optimization(OptimizationDiagnostic::unpack(
|
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysisFPCommute, di))
|
||||||
OptimizationAnalysisFPCommute, di))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dk::OptimizationRemarkAnalysisAliasing => {
|
Dk::OptimizationRemarkAnalysisAliasing => {
|
||||||
Optimization(OptimizationDiagnostic::unpack(
|
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysisAliasing, di))
|
||||||
OptimizationAnalysisAliasing, di))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Dk::OptimizationFailure => {
|
Dk::OptimizationFailure => {
|
||||||
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
|
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,9 @@
|
||||||
#![feature(concat_idents)]
|
#![feature(concat_idents)]
|
||||||
|
|
||||||
extern crate libc;
|
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::IntPredicate::*;
|
||||||
pub use self::RealPredicate::*;
|
pub use self::RealPredicate::*;
|
||||||
|
@ -68,7 +70,7 @@ impl LLVMRustResult {
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
pub struct Attributes {
|
pub struct Attributes {
|
||||||
regular: Attribute,
|
regular: Attribute,
|
||||||
dereferenceable_bytes: u64
|
dereferenceable_bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Attributes {
|
impl Attributes {
|
||||||
|
@ -96,10 +98,7 @@ impl Attributes {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.regular.apply_llfn(idx, llfn);
|
self.regular.apply_llfn(idx, llfn);
|
||||||
if self.dereferenceable_bytes != 0 {
|
if self.dereferenceable_bytes != 0 {
|
||||||
LLVMRustAddDereferenceableAttr(
|
LLVMRustAddDereferenceableAttr(llfn, idx.as_uint(), self.dereferenceable_bytes);
|
||||||
llfn,
|
|
||||||
idx.as_uint(),
|
|
||||||
self.dereferenceable_bytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,8 +107,7 @@ impl Attributes {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.regular.apply_callsite(idx, callsite);
|
self.regular.apply_callsite(idx, callsite);
|
||||||
if self.dereferenceable_bytes != 0 {
|
if self.dereferenceable_bytes != 0 {
|
||||||
LLVMRustAddDereferenceableCallSiteAttr(
|
LLVMRustAddDereferenceableCallSiteAttr(callsite,
|
||||||
callsite,
|
|
||||||
idx.as_uint(),
|
idx.as_uint(),
|
||||||
self.dereferenceable_bytes);
|
self.dereferenceable_bytes);
|
||||||
}
|
}
|
||||||
|
@ -117,15 +115,12 @@ impl Attributes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AddFunctionAttrStringValue(
|
pub fn AddFunctionAttrStringValue(llfn: ValueRef,
|
||||||
llfn: ValueRef,
|
|
||||||
idx: AttributePlace,
|
idx: AttributePlace,
|
||||||
attr: &'static str,
|
attr: &'static str,
|
||||||
value: &'static str
|
value: &'static str) {
|
||||||
) {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
LLVMRustAddFunctionAttrStringValue(
|
LLVMRustAddFunctionAttrStringValue(llfn,
|
||||||
llfn,
|
|
||||||
idx.as_uint(),
|
idx.as_uint(),
|
||||||
attr.as_ptr() as *const _,
|
attr.as_ptr() as *const _,
|
||||||
value.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 {
|
impl Attribute {
|
||||||
pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
pub fn apply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
||||||
unsafe {
|
unsafe { LLVMRustAddFunctionAttribute(llfn, idx.as_uint(), self.bits()) }
|
||||||
LLVMRustAddFunctionAttribute(
|
|
||||||
llfn, idx.as_uint(), self.bits())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) {
|
pub fn apply_callsite(&self, idx: AttributePlace, callsite: ValueRef) {
|
||||||
unsafe {
|
unsafe { LLVMRustAddCallSiteAttribute(callsite, idx.as_uint(), self.bits()) }
|
||||||
LLVMRustAddCallSiteAttribute(
|
|
||||||
callsite, idx.as_uint(), self.bits())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unapply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
pub fn unapply_llfn(&self, idx: AttributePlace, llfn: ValueRef) {
|
||||||
unsafe {
|
unsafe { LLVMRustRemoveFunctionAttributes(llfn, idx.as_uint(), self.bits()) }
|
||||||
LLVMRustRemoveFunctionAttributes(
|
|
||||||
llfn, idx.as_uint(), self.bits())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_llfn(&self,
|
pub fn toggle_llfn(&self, idx: AttributePlace, llfn: ValueRef, set: bool) {
|
||||||
idx: AttributePlace,
|
|
||||||
llfn: ValueRef,
|
|
||||||
set: bool)
|
|
||||||
{
|
|
||||||
if set {
|
if set {
|
||||||
self.apply_llfn(idx, llfn);
|
self.apply_llfn(idx, llfn);
|
||||||
} else {
|
} else {
|
||||||
self.unapply_llfn(idx, llfn);
|
self.unapply_llfn(idx, llfn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory-managed interface to target data. */
|
// Memory-managed interface to target data.
|
||||||
|
|
||||||
pub struct TargetData {
|
pub struct TargetData {
|
||||||
pub lltd: TargetDataRef
|
pub lltd: TargetDataRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for TargetData {
|
impl Drop for TargetData {
|
||||||
|
@ -283,12 +264,10 @@ impl Drop for TargetData {
|
||||||
|
|
||||||
pub fn mk_target_data(string_rep: &str) -> TargetData {
|
pub fn mk_target_data(string_rep: &str) -> TargetData {
|
||||||
let string_rep = CString::new(string_rep).unwrap();
|
let string_rep = CString::new(string_rep).unwrap();
|
||||||
TargetData {
|
TargetData { lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) } }
|
||||||
lltd: unsafe { LLVMCreateTargetData(string_rep.as_ptr()) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory-managed interface to object files. */
|
// Memory-managed interface to object files.
|
||||||
|
|
||||||
pub struct ObjectFile {
|
pub struct ObjectFile {
|
||||||
pub llof: ObjectFileRef,
|
pub llof: ObjectFileRef,
|
||||||
|
@ -301,12 +280,10 @@ impl ObjectFile {
|
||||||
let llof = LLVMCreateObjectFile(llmb);
|
let llof = LLVMCreateObjectFile(llmb);
|
||||||
if llof as isize == 0 {
|
if llof as isize == 0 {
|
||||||
// LLVMCreateObjectFile took ownership of llmb
|
// LLVMCreateObjectFile took ownership of llmb
|
||||||
return None
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(ObjectFile {
|
Some(ObjectFile { llof: llof })
|
||||||
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 struct SectionIter {
|
||||||
pub llsi: SectionIteratorRef
|
pub llsi: SectionIteratorRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for SectionIter {
|
impl Drop for SectionIter {
|
||||||
|
@ -334,11 +311,7 @@ impl Drop for SectionIter {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
|
pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
|
||||||
unsafe {
|
unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
|
||||||
SectionIter {
|
|
||||||
llsi: LLVMGetSections(llof)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
|
/// 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());
|
let mut buf = RefCell::new(Vec::new());
|
||||||
f(&mut buf as RustStringRepr as RustStringRef);
|
f(&mut buf as RustStringRepr as RustStringRef);
|
||||||
String::from_utf8(buf.into_inner()).ok()
|
String::from_utf8(buf.into_inner()).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn twine_to_string(tr: TwineRef) -> String {
|
pub unsafe fn twine_to_string(tr: TwineRef) -> String {
|
||||||
build_string(|s| LLVMRustWriteTwineToString(tr, s))
|
build_string(|s| LLVMRustWriteTwineToString(tr, s)).expect("got a non-UTF8 Twine from LLVM")
|
||||||
.expect("got a non-UTF8 Twine from LLVM")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
|
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 {
|
pub fn new(name: &str, vals: &[ValueRef]) -> OperandBundleDef {
|
||||||
let name = CString::new(name).unwrap();
|
let name = CString::new(name).unwrap();
|
||||||
let def = unsafe {
|
let def = unsafe {
|
||||||
LLVMRustBuildOperandBundleDef(name.as_ptr(),
|
LLVMRustBuildOperandBundleDef(name.as_ptr(), vals.as_ptr(), vals.len() as c_uint)
|
||||||
vals.as_ptr(),
|
|
||||||
vals.len() as c_uint)
|
|
||||||
};
|
};
|
||||||
OperandBundleDef { inner: def }
|
OperandBundleDef { inner: def }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue