Get arrays to work in DI, huzzah
This commit is contained in:
		
							parent
							
								
									c1cc1d28de
								
							
						
					
					
						commit
						5f65d3438a
					
				
							
								
								
									
										1
									
								
								bps
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								bps
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | [{"Breakpoint":{"BKPTOptions":{"AutoContinue":false,"ConditionText":"","EnabledState":true,"IgnoreCount":0,"OneShotState":false},"BKPTResolver":{"Options":{"Column":0,"Exact":false,"FileName":"array.reid","Inlines":true,"LineNumber":6,"Offset":0,"SkipPrologue":true},"Type":"FileAndLine"},"Hardware":false,"SearchFilter":{"Options":{},"Type":"Unconstrained"}}},{"Breakpoint":{"BKPTOptions":{"AutoContinue":false,"ConditionText":"","EnabledState":true,"IgnoreCount":0,"OneShotState":true},"BKPTResolver":{"Options":{"Column":0,"Exact":false,"FileName":"/home/furret/dev/reid-llvm/reid_src/array.reid","Inlines":true,"LineNumber":4,"Offset":0,"SkipPrologue":true},"Type":"FileAndLine"},"Hardware":false,"SearchFilter":{"Options":{},"Type":"Unconstrained"}}}] | ||||||
| @ -487,14 +487,19 @@ impl DebugTypeHolder { | |||||||
|                     into_cstring(ptr.name.clone()).as_ptr(), |                     into_cstring(ptr.name.clone()).as_ptr(), | ||||||
|                     ptr.name.len(), |                     ptr.name.len(), | ||||||
|                 ), |                 ), | ||||||
|                 DebugTypeData::Array(array) => LLVMDIBuilderCreateArrayType( |                 DebugTypeData::Array(array) => { | ||||||
|                     debug.builder, |                     let subrange = | ||||||
|                     array.size_bits, |                         LLVMDIBuilderGetOrCreateSubrange(debug.builder, 0, array.length as i64); | ||||||
|                     array.align_bits, |                     let mut elements = vec![subrange]; | ||||||
|                     *debug.types.get(&array.element_type).unwrap(), |                     LLVMDIBuilderCreateArrayType( | ||||||
|                     Vec::new().as_mut_ptr(), |                         debug.builder, | ||||||
|                     0, |                         array.size_bits, | ||||||
|                 ), |                         0, | ||||||
|  |                         *debug.types.get(&array.element_type).unwrap(), | ||||||
|  |                         elements.as_mut_ptr(), | ||||||
|  |                         elements.len() as u32, | ||||||
|  |                     ) | ||||||
|  |                 } | ||||||
|                 DebugTypeData::Struct(st) => { |                 DebugTypeData::Struct(st) => { | ||||||
|                     let mut elements = st |                     let mut elements = st | ||||||
|                         .elements |                         .elements | ||||||
| @ -509,7 +514,7 @@ impl DebugTypeHolder { | |||||||
|                         debug.file_ref, |                         debug.file_ref, | ||||||
|                         st.location.line, |                         st.location.line, | ||||||
|                         st.size_bits, |                         st.size_bits, | ||||||
|                         st.alignment, |                         0, | ||||||
|                         st.flags.as_llvm(), |                         st.flags.as_llvm(), | ||||||
|                         null_mut(), // derived from
 |                         null_mut(), // derived from
 | ||||||
|                         elements.as_mut_ptr(), |                         elements.as_mut_ptr(), | ||||||
|  | |||||||
| @ -292,10 +292,9 @@ impl Debug for DebugPointerType { | |||||||
| 
 | 
 | ||||||
| impl Debug for DebugArrayType { | impl Debug for DebugArrayType { | ||||||
|     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||||||
|         f.debug_struct(&format!("Array<{:?}>", self.element_type)) |         f.debug_struct(&format!("Array<{:?}>[{}]", self.element_type, self.length)) | ||||||
|             .field("size_bits", &self.size_bits) |             .field("size_bits", &self.size_bits) | ||||||
|             .field("align_bits", &self.align_bits) |             .field("align_bits", &self.align_bits) | ||||||
|             .field("subscripts", &self.subscripts) |  | ||||||
|             .finish() |             .finish() | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -279,7 +279,7 @@ pub struct DebugArrayType { | |||||||
|     pub size_bits: u64, |     pub size_bits: u64, | ||||||
|     pub align_bits: u32, |     pub align_bits: u32, | ||||||
|     pub element_type: DebugTypeValue, |     pub element_type: DebugTypeValue, | ||||||
|     pub subscripts: Vec<DebugTypeValue>, |     pub length: u64, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Clone)] | #[derive(Clone)] | ||||||
|  | |||||||
| @ -494,33 +494,27 @@ impl mir::Statement { | |||||||
|                     .stack_values |                     .stack_values | ||||||
|                     .insert(name.clone(), StackValue(stack_value, ty.clone())); |                     .insert(name.clone(), StackValue(stack_value, ty.clone())); | ||||||
|                 if let Some(debug) = &scope.debug { |                 if let Some(debug) = &scope.debug { | ||||||
|                     match stack_value { |                     let location = self.1.into_debug(scope.tokens).unwrap(); | ||||||
|                         StackValueKind::Immutable(_) => {} |                     let var = debug.info.metadata( | ||||||
|                         StackValueKind::Mutable(_) => { |                         &debug.scope, | ||||||
|                             let location = self.1.into_debug(scope.tokens).unwrap(); |                         DebugMetadata::LocalVar(DebugLocalVariable { | ||||||
|                             let var = debug.info.metadata( |                             name: name.clone(), | ||||||
|                                 &debug.scope, |                             location, | ||||||
|                                 DebugMetadata::LocalVar(DebugLocalVariable { |                             ty: ty.get_debug_type(debug, scope), | ||||||
|                                     name: name.clone(), |                             always_preserve: true, | ||||||
|                                     location, |                             alignment: 32, | ||||||
|                                     ty: ty.get_debug_type(debug, scope), |                             flags: DwarfFlags, | ||||||
|                                     always_preserve: true, |                         }), | ||||||
|                                     alignment: 32, |                     ); | ||||||
|                                     flags: DwarfFlags, |                     store.add_record( | ||||||
|                                 }), |                         &mut scope.block, | ||||||
|                             ); |                         InstructionDebugRecordData { | ||||||
|                             store.add_record( |                             variable: var, | ||||||
|                                 &mut scope.block, |                             location, | ||||||
|                                 InstructionDebugRecordData { |                             kind: DebugRecordKind::Declare(value.instr()), | ||||||
|                                     variable: var, |                             scope: debug.scope, | ||||||
|                                     location, |                         }, | ||||||
|                                     kind: DebugRecordKind::Declare(value.instr()), |                     ); | ||||||
|                                     scope: debug.scope, |  | ||||||
|                                 }, |  | ||||||
|                             ); |  | ||||||
|                         } |  | ||||||
|                         StackValueKind::Literal(_) => {} |  | ||||||
|                     } |  | ||||||
|                 } |                 } | ||||||
|                 None |                 None | ||||||
|             } |             } | ||||||
| @ -971,6 +965,9 @@ impl TypeKind { | |||||||
|                     TypeDefinitionKind::Struct(_) => Type::Ptr(Box::new(custom_t)), |                     TypeDefinitionKind::Struct(_) => Type::Ptr(Box::new(custom_t)), | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             TypeKind::Ptr(type_kind) => { | ||||||
|  |                 Type::Ptr(Box::new(type_kind.get_type(type_vals, typedefs))) | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -1015,10 +1012,9 @@ impl TypeKind { | |||||||
|                 ), |                 ), | ||||||
|                 size_bits: self.size_of(), |                 size_bits: self.size_of(), | ||||||
|             }), |             }), | ||||||
|             TypeKind::Array(type_kind, len) => DebugTypeData::Array(DebugArrayType { |             TypeKind::Ptr(inner) => DebugTypeData::Pointer(DebugPointerType { | ||||||
|                 size_bits: type_kind.size_of() * len, |                 name, | ||||||
|                 align_bits: type_kind.alignment(), |                 pointee: inner.get_debug_type_hard( | ||||||
|                 element_type: type_kind.get_debug_type_hard( |  | ||||||
|                     scope, |                     scope, | ||||||
|                     debug_info, |                     debug_info, | ||||||
|                     debug_types, |                     debug_types, | ||||||
| @ -1026,8 +1022,24 @@ impl TypeKind { | |||||||
|                     types, |                     types, | ||||||
|                     tokens, |                     tokens, | ||||||
|                 ), |                 ), | ||||||
|                 subscripts: Vec::new(), |                 size_bits: self.size_of(), | ||||||
|             }), |             }), | ||||||
|  |             TypeKind::Array(type_kind, len) => { | ||||||
|  |                 let elem_ty = type_kind.get_debug_type_hard( | ||||||
|  |                     scope, | ||||||
|  |                     debug_info, | ||||||
|  |                     debug_types, | ||||||
|  |                     type_values, | ||||||
|  |                     types, | ||||||
|  |                     tokens, | ||||||
|  |                 ); | ||||||
|  |                 DebugTypeData::Array(DebugArrayType { | ||||||
|  |                     size_bits: type_kind.size_of() * len, | ||||||
|  |                     align_bits: type_kind.alignment(), | ||||||
|  |                     element_type: elem_ty, | ||||||
|  |                     length: *len, | ||||||
|  |                 }) | ||||||
|  |             } | ||||||
|             TypeKind::CustomType(name) => { |             TypeKind::CustomType(name) => { | ||||||
|                 let typedef = types.get(type_values.get(name).unwrap()).unwrap(); |                 let typedef = types.get(type_values.get(name).unwrap()).unwrap(); | ||||||
| 
 | 
 | ||||||
| @ -1082,7 +1094,7 @@ impl TypeKind { | |||||||
|                     TypeKind::StringPtr => DwarfEncoding::Address, |                     TypeKind::StringPtr => DwarfEncoding::Address, | ||||||
|                     TypeKind::Array(_, _) => DwarfEncoding::Address, |                     TypeKind::Array(_, _) => DwarfEncoding::Address, | ||||||
|                     TypeKind::CustomType(_) => DwarfEncoding::Address, |                     TypeKind::CustomType(_) => DwarfEncoding::Address, | ||||||
|                     TypeKind::Vague(_) => panic!("tried fetching debug-type for vague type!"), |                     _ => panic!("tried fetching debug-type for non-supported type!"), | ||||||
|                 }, |                 }, | ||||||
|                 flags: DwarfFlags, |                 flags: DwarfFlags, | ||||||
|             }), |             }), | ||||||
|  | |||||||
| @ -47,6 +47,7 @@ impl TypeKind { | |||||||
|             TypeKind::StringPtr => 32, |             TypeKind::StringPtr => 32, | ||||||
|             TypeKind::Array(type_kind, len) => type_kind.size_of() * len, |             TypeKind::Array(type_kind, len) => type_kind.size_of() * len, | ||||||
|             TypeKind::CustomType(_) => 32, |             TypeKind::CustomType(_) => 32, | ||||||
|  |             TypeKind::Ptr(inner) => 32, | ||||||
|             TypeKind::Vague(_) => panic!("Tried to sizeof a vague type!"), |             TypeKind::Vague(_) => panic!("Tried to sizeof a vague type!"), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -68,6 +69,7 @@ impl TypeKind { | |||||||
|             TypeKind::StringPtr => 32, |             TypeKind::StringPtr => 32, | ||||||
|             TypeKind::Array(type_kind, _) => type_kind.alignment(), |             TypeKind::Array(type_kind, _) => type_kind.alignment(), | ||||||
|             TypeKind::CustomType(_) => 32, |             TypeKind::CustomType(_) => 32, | ||||||
|  |             TypeKind::Ptr(type_kind) => 32, | ||||||
|             TypeKind::Vague(_) => panic!("Tried to sizeof a vague type!"), |             TypeKind::Vague(_) => panic!("Tried to sizeof a vague type!"), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -109,6 +109,8 @@ pub enum TypeKind { | |||||||
|     Array(Box<TypeKind>, u64), |     Array(Box<TypeKind>, u64), | ||||||
|     #[error("{0}")] |     #[error("{0}")] | ||||||
|     CustomType(String), |     CustomType(String), | ||||||
|  |     #[error("Ptr({0})")] | ||||||
|  |     Ptr(Box<TypeKind>), | ||||||
|     #[error(transparent)] |     #[error(transparent)] | ||||||
|     Vague(#[from] VagueType), |     Vague(#[from] VagueType), | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,16 +1,7 @@ | |||||||
| // Arithmetic, function calls and imports! | // Arithmetic, function calls and imports! | ||||||
| 
 | 
 | ||||||
| fn array() -> [[[u16; 4];1];1] { |  | ||||||
|     return [[[10, 15, 7, 9]]]; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| fn main() -> u16 { | fn main() -> u16 { | ||||||
|     let mut list = array(); |   let a = [ 5, 3, 2 ]; | ||||||
| 
 | 
 | ||||||
|     let a = [[[5, 3, 2]]]; |   return a[1]; | ||||||
| 
 |  | ||||||
|     list[0][0][2] = 19; |  | ||||||
|     // let a = 1; |  | ||||||
| 
 |  | ||||||
|     return a[0][0][1]; |  | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user