remove "@split" tag

The default is to split word arrays. If you need your word array to not be split, use @nosplit on the array.
This commit is contained in:
Irmen de Jong
2025-10-05 15:56:23 +02:00
parent 3e1386a987
commit 4ed92d71a7
16 changed files with 45 additions and 70 deletions

View File

@@ -1038,7 +1038,7 @@ _doplot beq +
; y*40 lookup table. Pretty compact because it all fits in a word and we only need 240 y positions.
; a y*80 lookup table would be very large (lo,mid,hi for 480 values...)
uword[240] @split @shared times40 = [
uword[240] @shared times40 = [
0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 440, 480, 520, 560, 600,
640, 680, 720, 760, 800, 840, 880, 920, 960, 1000, 1040, 1080, 1120, 1160,
1200, 1240, 1280, 1320, 1360, 1400, 1440, 1480, 1520, 1560, 1600, 1640, 1680,

View File

@@ -1090,8 +1090,8 @@ internal class AstChecker(private val program: Program,
}
if(decl.datatype.isPointerArray) {
if(decl.splitwordarray!= SplitWish.SPLIT)
errors.err("pointer arrays can only be @split", decl.position)
if(decl.splitwordarray==SplitWish.NOSPLIT)
errors.err("pointer arrays can only be split", decl.position)
}
if(decl.datatype.isStructInstance && decl.origin!=VarDeclOrigin.SUBROUTINEPARAM) {

View File

@@ -71,12 +71,11 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
// check splitting of word arrays
if(decl.splitwordarray != SplitWish.DONTCARE && !decl.datatype.isWordArray && !decl.datatype.isPointerArray) {
if(decl.origin != VarDeclOrigin.ARRAYLITERAL)
errors.err("@split and @nosplit are for word or pointer arrays only", decl.position)
errors.err("@nosplit is for word or pointer arrays only", decl.position)
}
if(decl.datatype.isWordArray) {
var changeDataType: DataType?
var changeSplit: SplitWish = decl.splitwordarray
when(decl.splitwordarray) {
SplitWish.DONTCARE -> {
changeDataType = if(decl.datatype.isSplitWordArray) null else {
@@ -86,16 +85,6 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
else
DataType.arrayFor(eltDt.base)
}
changeSplit = SplitWish.SPLIT
}
SplitWish.SPLIT -> {
changeDataType = if(decl.datatype.isSplitWordArray) null else {
val eltDt = decl.datatype.elementType()
if(eltDt.isPointer)
TODO("convert array of pointers to split words array type")
else
DataType.arrayFor(eltDt.base)
}
}
SplitWish.NOSPLIT -> {
changeDataType = if(decl.datatype.isSplitWordArray && !decl.datatype.elementType().isPointer)
@@ -109,7 +98,7 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
value = ArrayLiteral(InferredTypes.knownFor(changeDataType), value.value, value.position)
}
val newDecl = VarDecl(decl.type, decl.origin, changeDataType, decl.zeropage,
changeSplit, decl.arraysize, decl.name, decl.names,
decl.splitwordarray, decl.arraysize, decl.name, decl.names,
value, decl.sharedWithAsm, decl.alignment, decl.dirty, decl.position)
return listOf(IAstModification.ReplaceNode(decl, newDecl, parent))
}

View File

@@ -145,7 +145,7 @@ internal class VerifyFunctionArgTypes(val program: Program, val options: Compila
if(addrOf!=null) {
val identType = addrOf.identifier?.inferType(program)?.getOrUndef()
if(identType?.isSplitWordArray==true) {
return Pair("argument ${mismatch + 1} type mismatch, was: $actual (because arg is a @split word array) expected: $expected", call.args[mismatch].position)
return Pair("argument ${mismatch + 1} type mismatch, was: $actual (because arg is a split word array) expected: $expected", call.args[mismatch].position)
}
}
}

View File

@@ -1951,7 +1951,7 @@ main {
val src="""
main {
sub start() {
uword[10] @split @shared splitarray
uword[10] @shared splitarray
uword[10] @nosplit @shared nosplitarray
^^uword ptr1 = &&splitarray
@@ -1992,9 +1992,9 @@ main {
errors.errors.size shouldBe 3
errors.warnings.size shouldBe 0
errors.infos.size shouldBe 0
errors.errors[0] shouldContain "pointer arrays can only be @split"
errors.errors[1] shouldContain "was: ^^ubyte (because arg is a @split word array) expected: ^^main.Node"
errors.errors[2] shouldContain "was: ^^ubyte (because arg is a @split word array) expected: ^^main.Node"
errors.errors[0] shouldContain "pointer arrays can only be split"
errors.errors[1] shouldContain "was: ^^ubyte (because arg is a split word array) expected: ^^main.Node"
errors.errors[2] shouldContain "was: ^^ubyte (because arg is a split word array) expected: ^^main.Node"
}
test("passing split array of structpointers to a subroutine in various forms should be param type ptr to ubyte (the lsb part of the split array)") {
@@ -2005,7 +2005,7 @@ main {
}
sub start() {
^^Node[10] @split nodearray
^^Node[10] nodearray
func(&&nodearray)
func(&nodearray)
func(nodearray)

View File

@@ -1129,30 +1129,26 @@ thing {
}
}
test("pointer arrays are always split") {
test("pointer arrays are split by default") {
val src="""
%option enable_floats
main {
sub start() {
^^bool[10] @split @shared barray
^^word[10] @split @shared warray
^^float[10] @split @shared farray
^^bool[10] @shared barrayns
^^word[10] @shared warrayns
^^float[10] @shared farrayns
^^bool[10] @shared barray
^^word[10] @shared warray
^^float[10] @shared farray
}
}"""
val result = compileText(VMTarget(), optimize=false, src, outputDir, writeAssembly=false)!!
val st = result.compilerAst.entrypoint.statements
st.size shouldBe 7
st.size shouldBe 4
val decls = st.filterIsInstance<VarDecl>()
decls.size shouldBe 6
decls.size shouldBe 3
decls.all { it.datatype.sub!=null } shouldBe true
decls.all { it.datatype.isPointerArray } shouldBe true
decls.all { it.datatype.isPointerArray } shouldBe true
decls.all { it.datatype.isSplitWordArray } shouldBe true
}
test("on..call in nested scope compiles correctly with temp variable introduced") {

View File

@@ -80,8 +80,8 @@ def make_test_array(datatype, comparison: C):
numbers = testnumbers[datatype]
print(" sub test_cmp_array() {")
print(f""" {datatype} @shared x
{datatype}[] @split values = [0, 0]
{datatype}[] @split sources = [0, 0]
{datatype}[] values = [0, 0]
{datatype}[] sources = [0, 0]
success = 0""")
expected = 0
test_index = 0

View File

@@ -36,9 +36,9 @@ main {{
test_is_var()
txt.print("\\n!=var: ")
test_not_var()
txt.print("\\n==array[] @split: ")
txt.print("\\n==array[] split: ")
test_is_array_splitw()
txt.print("\\n!=array[] @split: ")
txt.print("\\n!=array[] split: ")
test_not_array_splitw()
txt.print("\\n==expr: ")
test_is_expr()
@@ -97,7 +97,7 @@ nonzero_values = {
def make_test_is_zero(datatype):
print(f"""
sub test_is_zero() {{
{datatype}[] @split sources = [9999, 9999]
{datatype}[] sources = [9999, 9999]
success = 0
sources[1]={zero_values[datatype]}
@@ -155,7 +155,7 @@ skip4:
def make_test_not_zero(datatype):
print(f"""
sub test_not_zero() {{
{datatype}[] @split sources = [9999, 9999]
{datatype}[] sources = [9999, 9999]
success = 0
sources[1]={nonzero_values[datatype]}
@@ -229,7 +229,7 @@ testnumbers = {
def make_test_is_number(datatype, equals):
numbers = testnumbers[datatype]
print(" sub test_is_number() {" if equals else " sub test_not_number() {")
print(f""" {datatype}[] @split sources = [9999, 9999]
print(f""" {datatype}[] sources = [9999, 9999]
success = 0""")
expected = 0
test_index = 0
@@ -286,8 +286,8 @@ skip{test_index}b:
def make_test_is_var(datatype, equals):
numbers = testnumbers[datatype]
print(" sub test_is_var() {" if equals else " sub test_not_var() {")
print(f""" {datatype}[] @split sources = [9999, 9999]
{datatype}[] @split values = [8888,8888]
print(f""" {datatype}[] sources = [9999, 9999]
{datatype}[] values = [8888,8888]
success = 0""")
expected = 0
test_index = 0
@@ -346,8 +346,8 @@ def make_test_is_array(datatype, equals):
numbers = testnumbers[datatype]
print(" sub test_is_array_splitw() {" if equals else " sub test_not_array_splitw() {")
print(f"""
{datatype}[] @split values = [9999, 8888]
{datatype}[] @split sources = [9999, 8888]
{datatype}[] values = [9999, 8888]
{datatype}[] sources = [9999, 8888]
success = 0""")
expected = 0
test_index = 0
@@ -441,7 +441,7 @@ skip{test_index}d:
def make_test_is_expr(datatype, equals):
numbers = testnumbers[datatype]
print(" sub test_is_expr() {" if equals else " sub test_not_expr() {")
print(f""" {datatype}[] @split sources = [9999, 9999]
print(f""" {datatype}[] sources = [9999, 9999]
cx16.r4 = 1
cx16.r5 = 1
success = 0""")