@@ -10,41 +10,29 @@ import (
10
10
"tinygo.org/x/go-llvm"
11
11
)
12
12
13
- // constants for hashmap algorithms; must match src/runtime/hashmap.go
14
- const (
15
- hashmapAlgorithmBinary = iota
16
- hashmapAlgorithmString
17
- hashmapAlgorithmInterface
18
- )
19
-
20
13
// createMakeMap creates a new map object (runtime.hashmap) by allocating and
21
14
// initializing an appropriately sized object.
22
15
func (b * builder ) createMakeMap (expr * ssa.MakeMap ) (llvm.Value , error ) {
23
16
mapType := expr .Type ().Underlying ().(* types.Map )
24
17
keyType := mapType .Key ().Underlying ()
25
18
llvmValueType := b .getLLVMType (mapType .Elem ().Underlying ())
26
19
var llvmKeyType llvm.Type
27
- var alg uint64 // must match values in src/runtime/hashmap.go
28
20
if t , ok := keyType .(* types.Basic ); ok && t .Info ()& types .IsString != 0 {
29
21
// String keys.
30
22
llvmKeyType = b .getLLVMType (keyType )
31
- alg = hashmapAlgorithmString
32
23
} else if hashmapIsBinaryKey (keyType ) {
33
24
// Trivially comparable keys.
34
25
llvmKeyType = b .getLLVMType (keyType )
35
- alg = hashmapAlgorithmBinary
36
26
} else {
37
27
// All other keys. Implemented as map[interface{}]valueType for ease of
38
28
// implementation.
39
29
llvmKeyType = b .getLLVMRuntimeType ("_interface" )
40
- alg = hashmapAlgorithmInterface
41
30
}
42
31
keySize := b .targetData .TypeAllocSize (llvmKeyType )
43
32
valueSize := b .targetData .TypeAllocSize (llvmValueType )
44
33
llvmKeySize := llvm .ConstInt (b .ctx .Int8Type (), keySize , false )
45
34
llvmValueSize := llvm .ConstInt (b .ctx .Int8Type (), valueSize , false )
46
35
sizeHint := llvm .ConstInt (b .uintptrType , 8 , false )
47
- algEnum := llvm .ConstInt (b .ctx .Int8Type (), alg , false )
48
36
if expr .Reserve != nil {
49
37
sizeHint = b .getValue (expr .Reserve )
50
38
var err error
@@ -53,7 +41,7 @@ func (b *builder) createMakeMap(expr *ssa.MakeMap) (llvm.Value, error) {
53
41
return llvm.Value {}, err
54
42
}
55
43
}
56
- hashmap := b .createRuntimeCall ("hashmapMake" , []llvm.Value {llvmKeySize , llvmValueSize , sizeHint , algEnum }, "" )
44
+ hashmap := b .createRuntimeCall ("hashmapMake" , []llvm.Value {llvmKeySize , llvmValueSize , sizeHint }, "" )
57
45
return hashmap , nil
58
46
}
59
47
0 commit comments