Rename llvm::Bool aliases to standard const case
This avoids the need for `#![allow(non_upper_case_globals)]`.
This commit is contained in:
@@ -12,7 +12,7 @@ use smallvec::SmallVec;
|
||||
|
||||
use crate::builder::SBuilder;
|
||||
use crate::declare::declare_simple_fn;
|
||||
use crate::llvm::{self, False, True, Type, Value};
|
||||
use crate::llvm::{self, FALSE, TRUE, Type, Value};
|
||||
use crate::{SimpleCx, attributes, debuginfo, llvm_util};
|
||||
|
||||
pub(crate) unsafe fn codegen(
|
||||
@@ -80,7 +80,7 @@ pub(crate) unsafe fn codegen(
|
||||
&cx,
|
||||
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
|
||||
&i8,
|
||||
&llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, False),
|
||||
&llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, FALSE),
|
||||
);
|
||||
|
||||
// __rust_no_alloc_shim_is_unstable_v2
|
||||
@@ -201,7 +201,7 @@ fn create_wrapper_function(
|
||||
.map(|(i, _)| llvm::get_param(llfn, i as c_uint))
|
||||
.collect::<Vec<_>>();
|
||||
let ret = bx.call(ty, callee, &args, None);
|
||||
llvm::LLVMSetTailCall(ret, True);
|
||||
llvm::LLVMSetTailCall(ret, TRUE);
|
||||
if output.is_some() {
|
||||
bx.ret(ret);
|
||||
} else {
|
||||
|
||||
@@ -1110,7 +1110,7 @@ fn embed_bitcode(
|
||||
|
||||
llvm::set_section(llglobal, bitcode_section_name(cgcx));
|
||||
llvm::set_linkage(llglobal, llvm::Linkage::PrivateLinkage);
|
||||
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
|
||||
llvm::LLVMSetGlobalConstant(llglobal, llvm::TRUE);
|
||||
|
||||
let llconst = common::bytes_in_context(llcx, &[]);
|
||||
let llglobal = llvm::add_global(llmod, common::val_ty(llconst), c"rustc.embedded.cmdline");
|
||||
|
||||
@@ -35,7 +35,7 @@ use crate::attributes;
|
||||
use crate::common::Funclet;
|
||||
use crate::context::{CodegenCx, FullCx, GenericCx, SCx};
|
||||
use crate::llvm::{
|
||||
self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, GEPNoWrapFlags, Metadata, ToLlvmBool, True,
|
||||
self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, GEPNoWrapFlags, Metadata, TRUE, ToLlvmBool,
|
||||
};
|
||||
use crate::type_::Type;
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
@@ -493,8 +493,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
unsafe {
|
||||
let add = llvm::LLVMBuildAdd(self.llbuilder, a, b, UNNAMED);
|
||||
if llvm::LLVMIsAInstruction(add).is_some() {
|
||||
llvm::LLVMSetNUW(add, True);
|
||||
llvm::LLVMSetNSW(add, True);
|
||||
llvm::LLVMSetNUW(add, TRUE);
|
||||
llvm::LLVMSetNSW(add, TRUE);
|
||||
}
|
||||
add
|
||||
}
|
||||
@@ -503,8 +503,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
unsafe {
|
||||
let sub = llvm::LLVMBuildSub(self.llbuilder, a, b, UNNAMED);
|
||||
if llvm::LLVMIsAInstruction(sub).is_some() {
|
||||
llvm::LLVMSetNUW(sub, True);
|
||||
llvm::LLVMSetNSW(sub, True);
|
||||
llvm::LLVMSetNUW(sub, TRUE);
|
||||
llvm::LLVMSetNSW(sub, TRUE);
|
||||
}
|
||||
sub
|
||||
}
|
||||
@@ -513,8 +513,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
unsafe {
|
||||
let mul = llvm::LLVMBuildMul(self.llbuilder, a, b, UNNAMED);
|
||||
if llvm::LLVMIsAInstruction(mul).is_some() {
|
||||
llvm::LLVMSetNUW(mul, True);
|
||||
llvm::LLVMSetNSW(mul, True);
|
||||
llvm::LLVMSetNUW(mul, TRUE);
|
||||
llvm::LLVMSetNSW(mul, TRUE);
|
||||
}
|
||||
mul
|
||||
}
|
||||
@@ -528,7 +528,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
// an instruction, so we need to check before setting the flag.
|
||||
// (See also `LLVMBuildNUWNeg` which also needs a check.)
|
||||
if llvm::LLVMIsAInstruction(or).is_some() {
|
||||
llvm::LLVMSetIsDisjoint(or, True);
|
||||
llvm::LLVMSetIsDisjoint(or, TRUE);
|
||||
}
|
||||
or
|
||||
}
|
||||
@@ -629,7 +629,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
fn volatile_load(&mut self, ty: &'ll Type, ptr: &'ll Value) -> &'ll Value {
|
||||
unsafe {
|
||||
let load = llvm::LLVMBuildLoad2(self.llbuilder, ty, ptr, UNNAMED);
|
||||
llvm::LLVMSetVolatile(load, llvm::True);
|
||||
llvm::LLVMSetVolatile(load, llvm::TRUE);
|
||||
load
|
||||
}
|
||||
}
|
||||
@@ -838,7 +838,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
if flags.contains(MemFlags::UNALIGNED) { 1 } else { align.bytes() as c_uint };
|
||||
llvm::LLVMSetAlignment(store, align);
|
||||
if flags.contains(MemFlags::VOLATILE) {
|
||||
llvm::LLVMSetVolatile(store, llvm::True);
|
||||
llvm::LLVMSetVolatile(store, llvm::TRUE);
|
||||
}
|
||||
if flags.contains(MemFlags::NONTEMPORAL) {
|
||||
// Make sure that the current target architectures supports "sane" non-temporal
|
||||
@@ -956,7 +956,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
let trunc = self.trunc(val, dest_ty);
|
||||
unsafe {
|
||||
if llvm::LLVMIsAInstruction(trunc).is_some() {
|
||||
llvm::LLVMSetNUW(trunc, True);
|
||||
llvm::LLVMSetNUW(trunc, TRUE);
|
||||
}
|
||||
}
|
||||
trunc
|
||||
@@ -968,7 +968,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
let trunc = self.trunc(val, dest_ty);
|
||||
unsafe {
|
||||
if llvm::LLVMIsAInstruction(trunc).is_some() {
|
||||
llvm::LLVMSetNSW(trunc, True);
|
||||
llvm::LLVMSetNSW(trunc, TRUE);
|
||||
}
|
||||
}
|
||||
trunc
|
||||
@@ -1223,7 +1223,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
let ty = self.type_struct(&[self.type_ptr(), self.type_i32()], false);
|
||||
let landing_pad = self.landing_pad(ty, pers_fn, 0);
|
||||
unsafe {
|
||||
llvm::LLVMSetCleanup(landing_pad, llvm::True);
|
||||
llvm::LLVMSetCleanup(landing_pad, llvm::TRUE);
|
||||
}
|
||||
(self.extract_value(landing_pad, 0), self.extract_value(landing_pad, 1))
|
||||
}
|
||||
@@ -1319,7 +1319,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
src,
|
||||
AtomicOrdering::from_generic(order),
|
||||
AtomicOrdering::from_generic(failure_order),
|
||||
llvm::False, // SingleThreaded
|
||||
llvm::FALSE, // SingleThreaded
|
||||
);
|
||||
llvm::LLVMSetWeak(value, weak.to_llvm_bool());
|
||||
let val = self.extract_value(value, 0);
|
||||
@@ -1346,7 +1346,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
dst,
|
||||
src,
|
||||
AtomicOrdering::from_generic(order),
|
||||
llvm::False, // SingleThreaded
|
||||
llvm::FALSE, // SingleThreaded
|
||||
)
|
||||
};
|
||||
if ret_ptr && self.val_ty(res) != self.type_ptr() {
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::builder::{Builder, PlaceRef, UNNAMED};
|
||||
use crate::context::SimpleCx;
|
||||
use crate::declare::declare_simple_fn;
|
||||
use crate::llvm;
|
||||
use crate::llvm::{Metadata, True, Type};
|
||||
use crate::llvm::{Metadata, TRUE, Type};
|
||||
use crate::value::Value;
|
||||
|
||||
pub(crate) fn adjust_activity_to_abi<'tcx>(
|
||||
@@ -293,7 +293,7 @@ pub(crate) fn generate_enzyme_call<'ll, 'tcx>(
|
||||
// ret double %0
|
||||
// }
|
||||
// ```
|
||||
let enzyme_ty = unsafe { llvm::LLVMFunctionType(ret_ty, ptr::null(), 0, True) };
|
||||
let enzyme_ty = unsafe { llvm::LLVMFunctionType(ret_ty, ptr::null(), 0, TRUE) };
|
||||
|
||||
// FIXME(ZuseZ4): the CC/Addr/Vis values are best effort guesses, we should look at tests and
|
||||
// think a bit more about what should go here.
|
||||
|
||||
@@ -20,7 +20,7 @@ use tracing::debug;
|
||||
use crate::consts::const_alloc_to_llvm;
|
||||
pub(crate) use crate::context::CodegenCx;
|
||||
use crate::context::{GenericCx, SCx};
|
||||
use crate::llvm::{self, BasicBlock, ConstantInt, False, Metadata, ToLlvmBool, True};
|
||||
use crate::llvm::{self, BasicBlock, ConstantInt, FALSE, Metadata, TRUE, ToLlvmBool};
|
||||
use crate::type_::Type;
|
||||
use crate::value::Value;
|
||||
|
||||
@@ -158,7 +158,7 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
|
||||
self.type_kind(t) == TypeKind::Integer,
|
||||
"only allows integer types in const_int"
|
||||
);
|
||||
unsafe { llvm::LLVMConstInt(t, i as u64, True) }
|
||||
unsafe { llvm::LLVMConstInt(t, i as u64, TRUE) }
|
||||
}
|
||||
|
||||
fn const_u8(&self, i: u8) -> &'ll Value {
|
||||
@@ -192,7 +192,7 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
|
||||
self.type_kind(t) == TypeKind::Integer,
|
||||
"only allows integer types in const_uint"
|
||||
);
|
||||
unsafe { llvm::LLVMConstInt(t, i, False) }
|
||||
unsafe { llvm::LLVMConstInt(t, i, FALSE) }
|
||||
}
|
||||
|
||||
fn const_uint_big(&self, t: &'ll Type, u: u128) -> &'ll Value {
|
||||
@@ -377,7 +377,7 @@ pub(crate) fn val_ty(v: &Value) -> &Type {
|
||||
pub(crate) fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
|
||||
unsafe {
|
||||
let ptr = bytes.as_ptr() as *const c_char;
|
||||
llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), True)
|
||||
llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), TRUE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -701,7 +701,7 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
|
||||
}
|
||||
|
||||
pub(crate) fn get_const_int(&self, ty: &'ll Type, val: u64) -> &'ll Value {
|
||||
unsafe { llvm::LLVMConstInt(ty, val, llvm::False) }
|
||||
unsafe { llvm::LLVMConstInt(ty, val, llvm::FALSE) }
|
||||
}
|
||||
|
||||
pub(crate) fn get_const_i64(&self, n: u64) -> &'ll Value {
|
||||
|
||||
@@ -72,7 +72,7 @@ pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
|
||||
.unwrap_or_else(|| bug!("symbol `{}` is already defined", section_var_name));
|
||||
llvm::set_section(section_var, c".debug_gdb_scripts");
|
||||
llvm::set_initializer(section_var, cx.const_bytes(section_contents));
|
||||
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
|
||||
llvm::LLVMSetGlobalConstant(section_var, llvm::TRUE);
|
||||
llvm::set_unnamed_address(section_var, llvm::UnnamedAddr::Global);
|
||||
llvm::set_linkage(section_var, llvm::Linkage::LinkOnceODRLinkage);
|
||||
// This should make sure that the whole section is not larger than
|
||||
|
||||
@@ -38,7 +38,7 @@ pub(crate) fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'l
|
||||
parent_scope,
|
||||
namespace_name_string.as_ptr(),
|
||||
namespace_name_string.len(),
|
||||
llvm::False, // ExportSymbols (only relevant for C++ anonymous namespaces)
|
||||
llvm::FALSE, // ExportSymbols (only relevant for C++ anonymous namespaces)
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//! the need for an extra cast from `*const u8` on the Rust side.
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use std::fmt::{self, Debug};
|
||||
use std::marker::PhantomData;
|
||||
@@ -42,8 +41,8 @@ pub(crate) struct Bool {
|
||||
value: c_int,
|
||||
}
|
||||
|
||||
pub(crate) const True: Bool = Bool::TRUE;
|
||||
pub(crate) const False: Bool = Bool::FALSE;
|
||||
pub(crate) const TRUE: Bool = Bool::TRUE;
|
||||
pub(crate) const FALSE: Bool = Bool::FALSE;
|
||||
|
||||
impl Bool {
|
||||
pub(crate) const TRUE: Self = Self { value: 1 };
|
||||
|
||||
@@ -15,7 +15,7 @@ use rustc_target::callconv::{CastTarget, FnAbi};
|
||||
use crate::abi::{FnAbiLlvmExt, LlvmType};
|
||||
use crate::context::{CodegenCx, GenericCx, SCx};
|
||||
pub(crate) use crate::llvm::Type;
|
||||
use crate::llvm::{False, Metadata, ToLlvmBool, True};
|
||||
use crate::llvm::{FALSE, Metadata, TRUE, ToLlvmBool};
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::value::Value;
|
||||
use crate::{common, llvm};
|
||||
@@ -141,7 +141,7 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
|
||||
}
|
||||
|
||||
pub(crate) fn type_variadic_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
|
||||
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, True) }
|
||||
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, TRUE) }
|
||||
}
|
||||
|
||||
pub(crate) fn type_i1(&self) -> &'ll Type {
|
||||
@@ -202,7 +202,7 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
|
||||
}
|
||||
|
||||
fn type_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
|
||||
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, False) }
|
||||
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, FALSE) }
|
||||
}
|
||||
|
||||
fn type_kind(&self, ty: &'ll Type) -> TypeKind {
|
||||
|
||||
Reference in New Issue
Block a user