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(), | ||||
|                     ptr.name.len(), | ||||
|                 ), | ||||
|                 DebugTypeData::Array(array) => LLVMDIBuilderCreateArrayType( | ||||
|                     debug.builder, | ||||
|                     array.size_bits, | ||||
|                     array.align_bits, | ||||
|                     *debug.types.get(&array.element_type).unwrap(), | ||||
|                     Vec::new().as_mut_ptr(), | ||||
|                     0, | ||||
|                 ), | ||||
|                 DebugTypeData::Array(array) => { | ||||
|                     let subrange = | ||||
|                         LLVMDIBuilderGetOrCreateSubrange(debug.builder, 0, array.length as i64); | ||||
|                     let mut elements = vec![subrange]; | ||||
|                     LLVMDIBuilderCreateArrayType( | ||||
|                         debug.builder, | ||||
|                         array.size_bits, | ||||
|                         0, | ||||
|                         *debug.types.get(&array.element_type).unwrap(), | ||||
|                         elements.as_mut_ptr(), | ||||
|                         elements.len() as u32, | ||||
|                     ) | ||||
|                 } | ||||
|                 DebugTypeData::Struct(st) => { | ||||
|                     let mut elements = st | ||||
|                         .elements | ||||
| @ -509,7 +514,7 @@ impl DebugTypeHolder { | ||||
|                         debug.file_ref, | ||||
|                         st.location.line, | ||||
|                         st.size_bits, | ||||
|                         st.alignment, | ||||
|                         0, | ||||
|                         st.flags.as_llvm(), | ||||
|                         null_mut(), // derived from
 | ||||
|                         elements.as_mut_ptr(), | ||||
|  | ||||
| @ -292,10 +292,9 @@ impl Debug for DebugPointerType { | ||||
| 
 | ||||
| impl Debug for DebugArrayType { | ||||
|     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("align_bits", &self.align_bits) | ||||
|             .field("subscripts", &self.subscripts) | ||||
|             .finish() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -279,7 +279,7 @@ pub struct DebugArrayType { | ||||
|     pub size_bits: u64, | ||||
|     pub align_bits: u32, | ||||
|     pub element_type: DebugTypeValue, | ||||
|     pub subscripts: Vec<DebugTypeValue>, | ||||
|     pub length: u64, | ||||
| } | ||||
| 
 | ||||
| #[derive(Clone)] | ||||
|  | ||||
| @ -494,33 +494,27 @@ impl mir::Statement { | ||||
|                     .stack_values | ||||
|                     .insert(name.clone(), StackValue(stack_value, ty.clone())); | ||||
|                 if let Some(debug) = &scope.debug { | ||||
|                     match stack_value { | ||||
|                         StackValueKind::Immutable(_) => {} | ||||
|                         StackValueKind::Mutable(_) => { | ||||
|                             let location = self.1.into_debug(scope.tokens).unwrap(); | ||||
|                             let var = debug.info.metadata( | ||||
|                                 &debug.scope, | ||||
|                                 DebugMetadata::LocalVar(DebugLocalVariable { | ||||
|                                     name: name.clone(), | ||||
|                                     location, | ||||
|                                     ty: ty.get_debug_type(debug, scope), | ||||
|                                     always_preserve: true, | ||||
|                                     alignment: 32, | ||||
|                                     flags: DwarfFlags, | ||||
|                                 }), | ||||
|                             ); | ||||
|                             store.add_record( | ||||
|                                 &mut scope.block, | ||||
|                                 InstructionDebugRecordData { | ||||
|                                     variable: var, | ||||
|                                     location, | ||||
|                                     kind: DebugRecordKind::Declare(value.instr()), | ||||
|                                     scope: debug.scope, | ||||
|                                 }, | ||||
|                             ); | ||||
|                         } | ||||
|                         StackValueKind::Literal(_) => {} | ||||
|                     } | ||||
|                     let location = self.1.into_debug(scope.tokens).unwrap(); | ||||
|                     let var = debug.info.metadata( | ||||
|                         &debug.scope, | ||||
|                         DebugMetadata::LocalVar(DebugLocalVariable { | ||||
|                             name: name.clone(), | ||||
|                             location, | ||||
|                             ty: ty.get_debug_type(debug, scope), | ||||
|                             always_preserve: true, | ||||
|                             alignment: 32, | ||||
|                             flags: DwarfFlags, | ||||
|                         }), | ||||
|                     ); | ||||
|                     store.add_record( | ||||
|                         &mut scope.block, | ||||
|                         InstructionDebugRecordData { | ||||
|                             variable: var, | ||||
|                             location, | ||||
|                             kind: DebugRecordKind::Declare(value.instr()), | ||||
|                             scope: debug.scope, | ||||
|                         }, | ||||
|                     ); | ||||
|                 } | ||||
|                 None | ||||
|             } | ||||
| @ -971,6 +965,9 @@ impl TypeKind { | ||||
|                     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(), | ||||
|             }), | ||||
|             TypeKind::Array(type_kind, len) => DebugTypeData::Array(DebugArrayType { | ||||
|                 size_bits: type_kind.size_of() * len, | ||||
|                 align_bits: type_kind.alignment(), | ||||
|                 element_type: type_kind.get_debug_type_hard( | ||||
|             TypeKind::Ptr(inner) => DebugTypeData::Pointer(DebugPointerType { | ||||
|                 name, | ||||
|                 pointee: inner.get_debug_type_hard( | ||||
|                     scope, | ||||
|                     debug_info, | ||||
|                     debug_types, | ||||
| @ -1026,8 +1022,24 @@ impl TypeKind { | ||||
|                     types, | ||||
|                     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) => { | ||||
|                 let typedef = types.get(type_values.get(name).unwrap()).unwrap(); | ||||
| 
 | ||||
| @ -1082,7 +1094,7 @@ impl TypeKind { | ||||
|                     TypeKind::StringPtr => DwarfEncoding::Address, | ||||
|                     TypeKind::Array(_, _) => 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, | ||||
|             }), | ||||
|  | ||||
| @ -47,6 +47,7 @@ impl TypeKind { | ||||
|             TypeKind::StringPtr => 32, | ||||
|             TypeKind::Array(type_kind, len) => type_kind.size_of() * len, | ||||
|             TypeKind::CustomType(_) => 32, | ||||
|             TypeKind::Ptr(inner) => 32, | ||||
|             TypeKind::Vague(_) => panic!("Tried to sizeof a vague type!"), | ||||
|         } | ||||
|     } | ||||
| @ -68,6 +69,7 @@ impl TypeKind { | ||||
|             TypeKind::StringPtr => 32, | ||||
|             TypeKind::Array(type_kind, _) => type_kind.alignment(), | ||||
|             TypeKind::CustomType(_) => 32, | ||||
|             TypeKind::Ptr(type_kind) => 32, | ||||
|             TypeKind::Vague(_) => panic!("Tried to sizeof a vague type!"), | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -109,6 +109,8 @@ pub enum TypeKind { | ||||
|     Array(Box<TypeKind>, u64), | ||||
|     #[error("{0}")] | ||||
|     CustomType(String), | ||||
|     #[error("Ptr({0})")] | ||||
|     Ptr(Box<TypeKind>), | ||||
|     #[error(transparent)] | ||||
|     Vague(#[from] VagueType), | ||||
| } | ||||
|  | ||||
| @ -1,16 +1,7 @@ | ||||
| // Arithmetic, function calls and imports! | ||||
| 
 | ||||
| fn array() -> [[[u16; 4];1];1] { | ||||
|     return [[[10, 15, 7, 9]]]; | ||||
| } | ||||
| 
 | ||||
| fn main() -> u16 { | ||||
|     let mut list = array(); | ||||
|   let a = [ 5, 3, 2 ]; | ||||
| 
 | ||||
|     let a = [[[5, 3, 2]]]; | ||||
| 
 | ||||
|     list[0][0][2] = 19; | ||||
|     // let a = 1; | ||||
| 
 | ||||
|     return a[0][0][1]; | ||||
|   return a[1]; | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user