diff options
author | Ayke van Laethem <[email protected]> | 2023-03-16 20:10:00 +0100 |
---|---|---|
committer | Damian Gryski <[email protected]> | 2023-03-16 13:46:03 -0700 |
commit | 905269bf1150c63153c46145ae62e36d7df42e19 (patch) | |
tree | c0977327cf5cc59d3936abf65b7ed801ed0ca422 /transform | |
parent | e4f29ae2f95a188a39463599a7a56b82562158dc (diff) | |
download | tinygo-905269bf1150c63153c46145ae62e36d7df42e19.tar.gz tinygo-905269bf1150c63153c46145ae62e36d7df42e19.zip |
transform: update maps test to opaque pointers
Diffstat (limited to 'transform')
-rw-r--r-- | transform/testdata/maps.ll | 33 | ||||
-rw-r--r-- | transform/testdata/maps.out.ll | 26 |
2 files changed, 25 insertions, 34 deletions
diff --git a/transform/testdata/maps.ll b/transform/testdata/maps.ll index 0bf004246..78f6819da 100644 --- a/transform/testdata/maps.ll +++ b/transform/testdata/maps.ll @@ -1,28 +1,25 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" target triple = "armv7m-none-eabi" -%runtime.hashmap = type { %runtime.hashmap*, i8*, i32, i8, i8, i8 } - @answer = constant [6 x i8] c"answer" ; func(keySize, valueSize uint8, sizeHint uintptr) *runtime.hashmap -declare nonnull %runtime.hashmap* @runtime.hashmapMake(i8, i8, i32) +declare nonnull ptr @runtime.hashmapMake(i8, i8, i32) ; func(map[string]int, string, unsafe.Pointer) -declare void @runtime.hashmapStringSet(%runtime.hashmap* nocapture, i8*, i32, i8* nocapture readonly) +declare void @runtime.hashmapStringSet(ptr nocapture, ptr, i32, ptr nocapture readonly) ; func(map[string]int, string, unsafe.Pointer) -declare i1 @runtime.hashmapStringGet(%runtime.hashmap* nocapture, i8*, i32, i8* nocapture) +declare i1 @runtime.hashmapStringGet(ptr nocapture, ptr, i32, ptr nocapture) define void @testUnused() { ; create the map - %map = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0) + %map = call ptr @runtime.hashmapMake(i8 4, i8 4, i32 0) ; create the value to be stored %hashmap.value = alloca i32 - store i32 42, i32* %hashmap.value + store i32 42, ptr %hashmap.value ; store the value - %hashmap.value.bitcast = bitcast i32* %hashmap.value to i8* - call void @runtime.hashmapStringSet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value.bitcast) + call void @runtime.hashmapStringSet(ptr %map, ptr @answer, i32 6, ptr %hashmap.value) ret void } @@ -30,26 +27,24 @@ define void @testUnused() { ; return 42), but isn't at the moment. define i32 @testReadonly() { ; create the map - %map = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0) + %map = call ptr @runtime.hashmapMake(i8 4, i8 4, i32 0) ; create the value to be stored %hashmap.value = alloca i32 - store i32 42, i32* %hashmap.value + store i32 42, ptr %hashmap.value ; store the value - %hashmap.value.bitcast = bitcast i32* %hashmap.value to i8* - call void @runtime.hashmapStringSet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value.bitcast) + call void @runtime.hashmapStringSet(ptr %map, ptr @answer, i32 6, ptr %hashmap.value) ; load the value back %hashmap.value2 = alloca i32 - %hashmap.value2.bitcast = bitcast i32* %hashmap.value2 to i8* - %commaOk = call i1 @runtime.hashmapStringGet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value2.bitcast) - %loadedValue = load i32, i32* %hashmap.value2 + %commaOk = call i1 @runtime.hashmapStringGet(ptr %map, ptr @answer, i32 6, ptr %hashmap.value2) + %loadedValue = load i32, ptr %hashmap.value2 ret i32 %loadedValue } -define %runtime.hashmap* @testUsed() { - %1 = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0) - ret %runtime.hashmap* %1 +define ptr @testUsed() { + %1 = call ptr @runtime.hashmapMake(i8 4, i8 4, i32 0) + ret ptr %1 } diff --git a/transform/testdata/maps.out.ll b/transform/testdata/maps.out.ll index 81f9badab..1bd074395 100644 --- a/transform/testdata/maps.out.ll +++ b/transform/testdata/maps.out.ll @@ -1,34 +1,30 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" target triple = "armv7m-none-eabi" -%runtime.hashmap = type { %runtime.hashmap*, i8*, i32, i8, i8, i8 } - @answer = constant [6 x i8] c"answer" -declare nonnull %runtime.hashmap* @runtime.hashmapMake(i8, i8, i32) +declare nonnull ptr @runtime.hashmapMake(i8, i8, i32) -declare void @runtime.hashmapStringSet(%runtime.hashmap* nocapture, i8*, i32, i8* nocapture readonly) +declare void @runtime.hashmapStringSet(ptr nocapture, ptr, i32, ptr nocapture readonly) -declare i1 @runtime.hashmapStringGet(%runtime.hashmap* nocapture, i8*, i32, i8* nocapture) +declare i1 @runtime.hashmapStringGet(ptr nocapture, ptr, i32, ptr nocapture) define void @testUnused() { ret void } define i32 @testReadonly() { - %map = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0) + %map = call ptr @runtime.hashmapMake(i8 4, i8 4, i32 0) %hashmap.value = alloca i32, align 4 - store i32 42, i32* %hashmap.value, align 4 - %hashmap.value.bitcast = bitcast i32* %hashmap.value to i8* - call void @runtime.hashmapStringSet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value.bitcast) + store i32 42, ptr %hashmap.value, align 4 + call void @runtime.hashmapStringSet(ptr %map, ptr @answer, i32 6, ptr %hashmap.value) %hashmap.value2 = alloca i32, align 4 - %hashmap.value2.bitcast = bitcast i32* %hashmap.value2 to i8* - %commaOk = call i1 @runtime.hashmapStringGet(%runtime.hashmap* %map, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @answer, i32 0, i32 0), i32 6, i8* %hashmap.value2.bitcast) - %loadedValue = load i32, i32* %hashmap.value2, align 4 + %commaOk = call i1 @runtime.hashmapStringGet(ptr %map, ptr @answer, i32 6, ptr %hashmap.value2) + %loadedValue = load i32, ptr %hashmap.value2, align 4 ret i32 %loadedValue } -define %runtime.hashmap* @testUsed() { - %1 = call %runtime.hashmap* @runtime.hashmapMake(i8 4, i8 4, i32 0) - ret %runtime.hashmap* %1 +define ptr @testUsed() { + %1 = call ptr @runtime.hashmapMake(i8 4, i8 4, i32 0) + ret ptr %1 } |