Merge commit '1411a98352
' into sync_cg_clif-2021-12-31
This commit is contained in:
commit
b799d6e0a5
18 changed files with 245 additions and 209 deletions
|
@ -1,5 +1,4 @@
|
|||
use std::convert::TryFrom;
|
||||
use std::convert::TryInto;
|
||||
|
||||
use gccjit::LValue;
|
||||
use gccjit::{Block, CType, RValue, Type, ToRValue};
|
||||
|
@ -44,7 +43,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
let string = self.context.new_string_literal(&*string);
|
||||
let sym = self.generate_local_symbol_name("str");
|
||||
let global = self.declare_private_global(&sym, self.val_ty(string));
|
||||
global.global_set_initializer_value(string);
|
||||
global.global_set_initializer_rvalue(string);
|
||||
global
|
||||
// TODO(antoyo): set linkage.
|
||||
}
|
||||
|
@ -79,7 +78,7 @@ pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) ->
|
|||
bytes.iter()
|
||||
.map(|&byte| context.new_rvalue_from_int(byte_type, byte as i32))
|
||||
.collect();
|
||||
context.new_rvalue_from_array(None, typ, &elements)
|
||||
context.new_array_constructor(None, typ, &elements)
|
||||
}
|
||||
|
||||
pub fn type_is_pointer<'gcc>(typ: Type<'gcc>) -> bool {
|
||||
|
@ -120,13 +119,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
|
||||
fn const_uint_big(&self, typ: Type<'gcc>, num: u128) -> RValue<'gcc> {
|
||||
let num64: Result<i64, _> = num.try_into();
|
||||
if let Ok(num) = num64 {
|
||||
// FIXME(antoyo): workaround for a bug where libgccjit is expecting a constant.
|
||||
// The operations >> 64 and | low are making the normal case a non-constant.
|
||||
return self.context.new_rvalue_from_long(typ, num as i64);
|
||||
}
|
||||
|
||||
if num >> 64 != 0 {
|
||||
// FIXME(antoyo): use a new function new_rvalue_from_unsigned_long()?
|
||||
let low = self.context.new_rvalue_from_long(self.u64_type, num as u64 as i64);
|
||||
|
@ -193,7 +185,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
// TODO(antoyo): cache the type? It's anonymous, so probably not.
|
||||
let typ = self.type_struct(&fields, packed);
|
||||
let struct_type = typ.is_struct().expect("struct type");
|
||||
self.context.new_rvalue_from_struct(None, struct_type, values)
|
||||
self.context.new_struct_constructor(None, struct_type.as_type(), None, values)
|
||||
}
|
||||
|
||||
fn const_to_opt_uint(&self, _v: RValue<'gcc>) -> Option<u64> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue