mirror of
				https://github.com/irmen/prog8.git
				synced 2025-10-31 15:16:13 +00:00 
			
		
		
		
	pointer types should just be uwords in IR
This commit is contained in:
		| @@ -1,7 +1,6 @@ | |||||||
| TODO | TODO | ||||||
| ==== | ==== | ||||||
|  |  | ||||||
| don't write pointer types into P8IR files, just write uword as the type? (actually breaks the VARIABLESWITHINIT now that zp vars get initialized to 0 again;  all the pointer examples won't compile anymore) |  | ||||||
| fix ^^Node nodes  /  cx16.r0L = nodes[2].weight    (TODO("IR datatype for struct instances") | fix ^^Node nodes  /  cx16.r0L = nodes[2].weight    (TODO("IR datatype for struct instances") | ||||||
| fix bool bb2 = bptr[2]^^   ... peekbool(bptr[2]) gives a arg 1 type error... just omit peekbool() here? | fix bool bb2 = bptr[2]^^   ... peekbool(bptr[2]) gives a arg 1 type error... just omit peekbool() here? | ||||||
| fix countries[2]^^ = 0  compiler crash | fix countries[2]^^ = 0  compiler crash | ||||||
| @@ -122,6 +121,7 @@ Future Things and Ideas | |||||||
| IR/VM | IR/VM | ||||||
| ----- | ----- | ||||||
| - possible to use LOADFIELD/STOREFIELD instructions more? | - possible to use LOADFIELD/STOREFIELD instructions more? | ||||||
|  | - pointer dt's are all reduced to just an uword (in the irTypeString method) - is this okay or could it be beneficial to reintroduce the actual pointer type information? See commit fcda2dd92d0ec64d24dad05018a3cd6aef2fed84 | ||||||
| - change the instruction format so an indirect register (a pointer) can be used more often, at least for the inplace assignment operators that operate on pointer | - change the instruction format so an indirect register (a pointer) can be used more often, at least for the inplace assignment operators that operate on pointer | ||||||
| - getting it in shape for code generation...: the IR file should be able to encode every detail about a prog8 program (the VM doesn't have to actually be able to run all of it though!) | - getting it in shape for code generation...: the IR file should be able to encode every detail about a prog8 program (the VM doesn't have to actually be able to run all of it though!) | ||||||
| - fix call() return value handling (... what's wrong with it again?) | - fix call() return value handling (... what's wrong with it again?) | ||||||
|   | |||||||
| @@ -73,8 +73,8 @@ class IRFileWriter(private val irProgram: IRProgram, outfileOverride: Path?) { | |||||||
|                     is IRAsmSubroutine -> { |                     is IRAsmSubroutine -> { | ||||||
|                         val clobbers = child.clobbers.joinToString(",") |                         val clobbers = child.clobbers.joinToString(",") | ||||||
|                         val returns = child.returns.joinToString(",") { ret -> |                         val returns = child.returns.joinToString(",") { ret -> | ||||||
|                             if (ret.reg.registerOrPair != null) "${ret.reg.registerOrPair}:${ret.dt.toString().lowercase()}" |                             if (ret.reg.registerOrPair != null) "${ret.reg.registerOrPair}:${ret.dt.irTypeString(null)}" | ||||||
|                             else "${ret.reg.statusflag}:${ret.dt.toString().lowercase()}" |                             else "${ret.reg.statusflag}:${ret.dt.irTypeString(null)}" | ||||||
|                         } |                         } | ||||||
|                         xml.writeStartElement("ASMSUB") |                         xml.writeStartElement("ASMSUB") | ||||||
|                         xml.writeAttribute("NAME", child.label) |                         xml.writeAttribute("NAME", child.label) | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import prog8.right | |||||||
|  |  | ||||||
| fun DataType.irTypeString(length: UInt?): String { | fun DataType.irTypeString(length: UInt?): String { | ||||||
|     val lengthStr = if(length==0u) "" else length.toString() |     val lengthStr = if(length==0u) "" else length.toString() | ||||||
|  |     // note: pointer types are all reduced to just an uword (untyped pointer / address) | ||||||
|     return when (this.base) { |     return when (this.base) { | ||||||
|         BaseDataType.BOOL -> "bool" |         BaseDataType.BOOL -> "bool" | ||||||
|         BaseDataType.UBYTE -> "ubyte" |         BaseDataType.UBYTE -> "ubyte" | ||||||
| @@ -17,24 +18,14 @@ fun DataType.irTypeString(length: UInt?): String { | |||||||
|         BaseDataType.LONG -> "long" |         BaseDataType.LONG -> "long" | ||||||
|         BaseDataType.FLOAT -> "float" |         BaseDataType.FLOAT -> "float" | ||||||
|         BaseDataType.STR -> "ubyte[$lengthStr]"             // here string doesn't exist as a seperate datatype anymore |         BaseDataType.STR -> "ubyte[$lengthStr]"             // here string doesn't exist as a seperate datatype anymore | ||||||
|         BaseDataType.POINTER -> { |         BaseDataType.POINTER -> "uword" | ||||||
|             if(sub!=null) |         BaseDataType.ARRAY_POINTER -> "uword" | ||||||
|                 "^${sub!!.name.lowercase()}" |  | ||||||
|             else |  | ||||||
|                 "^${subType!!.scopedNameString}" |  | ||||||
|         } |  | ||||||
|         BaseDataType.STRUCT_INSTANCE -> { |         BaseDataType.STRUCT_INSTANCE -> { | ||||||
|             if(sub!=null) |             if(sub!=null) | ||||||
|                 sub!!.name.lowercase() |                 sub!!.name.lowercase() | ||||||
|             else |             else | ||||||
|                 subType!!.scopedNameString |                 subType!!.scopedNameString | ||||||
|         } |         } | ||||||
|         BaseDataType.ARRAY_POINTER -> { |  | ||||||
|             if(sub!=null) |  | ||||||
|                 "^${sub!!.name.lowercase()}[$lengthStr]" |  | ||||||
|             else |  | ||||||
|                 "^${subType!!.scopedNameString}[$lengthStr]" |  | ||||||
|         } |  | ||||||
|         BaseDataType.ARRAY -> { |         BaseDataType.ARRAY -> { | ||||||
|             when(this.sub) { |             when(this.sub) { | ||||||
|                 BaseDataType.UBYTE -> "ubyte[$lengthStr]" |                 BaseDataType.UBYTE -> "ubyte[$lengthStr]" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user