@@ -200,7 +200,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
200
200
fn check_ptr_call < ' b > ( & mut self , _typ : & str , func_ptr : RValue < ' gcc > , args : & ' b [ RValue < ' gcc > ] ) -> Cow < ' b , [ RValue < ' gcc > ] > {
201
201
let mut all_args_match = true ;
202
202
let mut param_types = vec ! [ ] ;
203
- let gcc_func = func_ptr. get_type ( ) . is_function_ptr_type ( ) . expect ( "function ptr" ) ;
203
+ let gcc_func = func_ptr. get_type ( ) . dyncast_function_ptr_type ( ) . expect ( "function ptr" ) ;
204
204
for ( index, arg) in args. iter ( ) . enumerate ( ) . take ( gcc_func. get_param_count ( ) ) {
205
205
let param = gcc_func. get_param_type ( index) ;
206
206
if param != arg. get_type ( ) {
@@ -277,7 +277,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
277
277
278
278
// gccjit requires to use the result of functions, even when it's not used.
279
279
// That's why we assign the result to a local or call add_eval().
280
- let gcc_func = func_ptr. get_type ( ) . is_function_ptr_type ( ) . expect ( "function ptr" ) ;
280
+ let gcc_func = func_ptr. get_type ( ) . dyncast_function_ptr_type ( ) . expect ( "function ptr" ) ;
281
281
let mut return_type = gcc_func. get_return_type ( ) ;
282
282
let current_block = self . current_block . borrow ( ) . expect ( "block" ) ;
283
283
let void_type = self . context . new_type :: < ( ) > ( ) ;
@@ -810,7 +810,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
810
810
let atomic_load = self . context . get_builtin_function ( & format ! ( "__atomic_load_{}" , size. bytes( ) ) ) ;
811
811
let ordering = self . context . new_rvalue_from_int ( self . i32_type , order. to_gcc ( ) ) ;
812
812
813
- let volatile_const_void_ptr_type = self . context . new_type :: < * mut ( ) > ( ) . make_const ( ) . make_volatile ( ) ;
813
+ let volatile_const_void_ptr_type = self . context . new_type :: < ( ) > ( )
814
+ . make_const ( )
815
+ . make_volatile ( )
816
+ . make_pointer ( ) ;
814
817
let ptr = self . context . new_cast ( None , ptr, volatile_const_void_ptr_type) ;
815
818
self . context . new_call ( None , atomic_load, & [ ptr, ordering] )
816
819
}
@@ -935,7 +938,9 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
935
938
// TODO(antoyo): handle alignment.
936
939
let atomic_store = self . context . get_builtin_function ( & format ! ( "__atomic_store_{}" , size. bytes( ) ) ) ;
937
940
let ordering = self . context . new_rvalue_from_int ( self . i32_type , order. to_gcc ( ) ) ;
938
- let volatile_const_void_ptr_type = self . context . new_type :: < * mut ( ) > ( ) . make_const ( ) . make_volatile ( ) ;
941
+ let volatile_const_void_ptr_type = self . context . new_type :: < ( ) > ( )
942
+ . make_volatile ( )
943
+ . make_pointer ( ) ;
939
944
let ptr = self . context . new_cast ( None , ptr, volatile_const_void_ptr_type) ;
940
945
941
946
// FIXME(antoyo): fix libgccjit to allow comparing an integer type with an aligned integer type because
@@ -975,12 +980,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
975
980
assert_eq ! ( idx as usize as u64 , idx) ;
976
981
let value = ptr. dereference ( None ) . to_rvalue ( ) ;
977
982
978
- if value_type. is_array ( ) . is_some ( ) {
983
+ if value_type. dyncast_array ( ) . is_some ( ) {
979
984
let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
980
985
let element = self . context . new_array_access ( None , value, index) ;
981
986
element. get_address ( None )
982
987
}
983
- else if let Some ( vector_type) = value_type. is_vector ( ) {
988
+ else if let Some ( vector_type) = value_type. dyncast_vector ( ) {
984
989
let array_type = vector_type. get_element_type ( ) . make_pointer ( ) ;
985
990
let array = self . bitcast ( ptr, array_type) ;
986
991
let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
@@ -1003,7 +1008,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1003
1008
1004
1009
fn sext ( & mut self , value : RValue < ' gcc > , dest_ty : Type < ' gcc > ) -> RValue < ' gcc > {
1005
1010
// TODO(antoyo): check that it indeed sign extend the value.
1006
- if dest_ty. is_vector ( ) . is_some ( ) {
1011
+ if dest_ty. dyncast_vector ( ) . is_some ( ) {
1007
1012
// TODO(antoyo): nothing to do as it is only for LLVM?
1008
1013
return value;
1009
1014
}
@@ -1075,7 +1080,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1075
1080
let right_type = rhs. get_type ( ) ;
1076
1081
if left_type != right_type {
1077
1082
// NOTE: because libgccjit cannot compare function pointers.
1078
- if left_type. is_function_ptr_type ( ) . is_some ( ) && right_type. is_function_ptr_type ( ) . is_some ( ) {
1083
+ if left_type. dyncast_function_ptr_type ( ) . is_some ( ) && right_type. dyncast_function_ptr_type ( ) . is_some ( ) {
1079
1084
lhs = self . context . new_cast ( None , lhs, self . usize_type . make_pointer ( ) ) ;
1080
1085
rhs = self . context . new_cast ( None , rhs, self . usize_type . make_pointer ( ) ) ;
1081
1086
}
@@ -1183,12 +1188,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1183
1188
assert_eq ! ( idx as usize as u64 , idx) ;
1184
1189
let value_type = aggregate_value. get_type ( ) ;
1185
1190
1186
- if value_type. is_array ( ) . is_some ( ) {
1191
+ if value_type. dyncast_array ( ) . is_some ( ) {
1187
1192
let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
1188
1193
let element = self . context . new_array_access ( None , aggregate_value, index) ;
1189
1194
element. get_address ( None )
1190
1195
}
1191
- else if value_type. is_vector ( ) . is_some ( ) {
1196
+ else if value_type. dyncast_vector ( ) . is_some ( ) {
1192
1197
panic ! ( ) ;
1193
1198
}
1194
1199
else if let Some ( pointer_type) = value_type. get_pointee ( ) {
@@ -1215,11 +1220,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1215
1220
let value_type = aggregate_value. get_type ( ) ;
1216
1221
1217
1222
let lvalue =
1218
- if value_type. is_array ( ) . is_some ( ) {
1223
+ if value_type. dyncast_array ( ) . is_some ( ) {
1219
1224
let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
1220
1225
self . context . new_array_access ( None , aggregate_value, index)
1221
1226
}
1222
- else if value_type. is_vector ( ) . is_some ( ) {
1227
+ else if value_type. dyncast_vector ( ) . is_some ( ) {
1223
1228
panic ! ( ) ;
1224
1229
}
1225
1230
else if let Some ( pointer_type) = value_type. get_pointee ( ) {
0 commit comments