@@ -200,7 +200,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
200200 fn check_ptr_call < ' b > ( & mut self , _typ : & str , func_ptr : RValue < ' gcc > , args : & ' b [ RValue < ' gcc > ] ) -> Cow < ' b , [ RValue < ' gcc > ] > {
201201 let mut all_args_match = true ;
202202 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" ) ;
204204 for ( index, arg) in args. iter ( ) . enumerate ( ) . take ( gcc_func. get_param_count ( ) ) {
205205 let param = gcc_func. get_param_type ( index) ;
206206 if param != arg. get_type ( ) {
@@ -277,7 +277,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
277277
278278 // gccjit requires to use the result of functions, even when it's not used.
279279 // 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" ) ;
281281 let mut return_type = gcc_func. get_return_type ( ) ;
282282 let current_block = self . current_block . borrow ( ) . expect ( "block" ) ;
283283 let void_type = self . context . new_type :: < ( ) > ( ) ;
@@ -810,7 +810,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
810810 let atomic_load = self . context . get_builtin_function ( & format ! ( "__atomic_load_{}" , size. bytes( ) ) ) ;
811811 let ordering = self . context . new_rvalue_from_int ( self . i32_type , order. to_gcc ( ) ) ;
812812
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 ( ) ;
814817 let ptr = self . context . new_cast ( None , ptr, volatile_const_void_ptr_type) ;
815818 self . context . new_call ( None , atomic_load, & [ ptr, ordering] )
816819 }
@@ -935,7 +938,9 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
935938 // TODO(antoyo): handle alignment.
936939 let atomic_store = self . context . get_builtin_function ( & format ! ( "__atomic_store_{}" , size. bytes( ) ) ) ;
937940 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 ( ) ;
939944 let ptr = self . context . new_cast ( None , ptr, volatile_const_void_ptr_type) ;
940945
941946 // 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> {
975980 assert_eq ! ( idx as usize as u64 , idx) ;
976981 let value = ptr. dereference ( None ) . to_rvalue ( ) ;
977982
978- if value_type. is_array ( ) . is_some ( ) {
983+ if value_type. dyncast_array ( ) . is_some ( ) {
979984 let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
980985 let element = self . context . new_array_access ( None , value, index) ;
981986 element. get_address ( None )
982987 }
983- else if let Some ( vector_type) = value_type. is_vector ( ) {
988+ else if let Some ( vector_type) = value_type. dyncast_vector ( ) {
984989 let array_type = vector_type. get_element_type ( ) . make_pointer ( ) ;
985990 let array = self . bitcast ( ptr, array_type) ;
986991 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> {
10031008
10041009 fn sext ( & mut self , value : RValue < ' gcc > , dest_ty : Type < ' gcc > ) -> RValue < ' gcc > {
10051010 // 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 ( ) {
10071012 // TODO(antoyo): nothing to do as it is only for LLVM?
10081013 return value;
10091014 }
@@ -1075,7 +1080,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
10751080 let right_type = rhs. get_type ( ) ;
10761081 if left_type != right_type {
10771082 // 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 ( ) {
10791084 lhs = self . context . new_cast ( None , lhs, self . usize_type . make_pointer ( ) ) ;
10801085 rhs = self . context . new_cast ( None , rhs, self . usize_type . make_pointer ( ) ) ;
10811086 }
@@ -1183,12 +1188,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11831188 assert_eq ! ( idx as usize as u64 , idx) ;
11841189 let value_type = aggregate_value. get_type ( ) ;
11851190
1186- if value_type. is_array ( ) . is_some ( ) {
1191+ if value_type. dyncast_array ( ) . is_some ( ) {
11871192 let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
11881193 let element = self . context . new_array_access ( None , aggregate_value, index) ;
11891194 element. get_address ( None )
11901195 }
1191- else if value_type. is_vector ( ) . is_some ( ) {
1196+ else if value_type. dyncast_vector ( ) . is_some ( ) {
11921197 panic ! ( ) ;
11931198 }
11941199 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> {
12151220 let value_type = aggregate_value. get_type ( ) ;
12161221
12171222 let lvalue =
1218- if value_type. is_array ( ) . is_some ( ) {
1223+ if value_type. dyncast_array ( ) . is_some ( ) {
12191224 let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
12201225 self . context . new_array_access ( None , aggregate_value, index)
12211226 }
1222- else if value_type. is_vector ( ) . is_some ( ) {
1227+ else if value_type. dyncast_vector ( ) . is_some ( ) {
12231228 panic ! ( ) ;
12241229 }
12251230 else if let Some ( pointer_type) = value_type. get_pointee ( ) {
0 commit comments