@@ -10,41 +10,29 @@ import (
1010 "tinygo.org/x/go-llvm"
1111)
1212
13- // constants for hashmap algorithms; must match src/runtime/hashmap.go
14- const (
15- hashmapAlgorithmBinary = iota
16- hashmapAlgorithmString
17- hashmapAlgorithmInterface
18- )
19-
2013// createMakeMap creates a new map object (runtime.hashmap) by allocating and
2114// initializing an appropriately sized object.
2215func (b * builder ) createMakeMap (expr * ssa.MakeMap ) (llvm.Value , error ) {
2316 mapType := expr .Type ().Underlying ().(* types.Map )
2417 keyType := mapType .Key ().Underlying ()
2518 llvmValueType := b .getLLVMType (mapType .Elem ().Underlying ())
2619 var llvmKeyType llvm.Type
27- var alg uint64 // must match values in src/runtime/hashmap.go
2820 if t , ok := keyType .(* types.Basic ); ok && t .Info ()& types .IsString != 0 {
2921 // String keys.
3022 llvmKeyType = b .getLLVMType (keyType )
31- alg = hashmapAlgorithmString
3223 } else if hashmapIsBinaryKey (keyType ) {
3324 // Trivially comparable keys.
3425 llvmKeyType = b .getLLVMType (keyType )
35- alg = hashmapAlgorithmBinary
3626 } else {
3727 // All other keys. Implemented as map[interface{}]valueType for ease of
3828 // implementation.
3929 llvmKeyType = b .getLLVMRuntimeType ("_interface" )
40- alg = hashmapAlgorithmInterface
4130 }
4231 keySize := b .targetData .TypeAllocSize (llvmKeyType )
4332 valueSize := b .targetData .TypeAllocSize (llvmValueType )
4433 llvmKeySize := llvm .ConstInt (b .ctx .Int8Type (), keySize , false )
4534 llvmValueSize := llvm .ConstInt (b .ctx .Int8Type (), valueSize , false )
4635 sizeHint := llvm .ConstInt (b .uintptrType , 8 , false )
47- algEnum := llvm .ConstInt (b .ctx .Int8Type (), alg , false )
4836 if expr .Reserve != nil {
4937 sizeHint = b .getValue (expr .Reserve )
5038 var err error
@@ -53,7 +41,7 @@ func (b *builder) createMakeMap(expr *ssa.MakeMap) (llvm.Value, error) {
5341 return llvm.Value {}, err
5442 }
5543 }
56- hashmap := b .createRuntimeCall ("hashmapMake" , []llvm.Value {llvmKeySize , llvmValueSize , sizeHint , algEnum }, "" )
44+ hashmap := b .createRuntimeCall ("hashmapMake" , []llvm.Value {llvmKeySize , llvmValueSize , sizeHint }, "" )
5745 return hashmap , nil
5846}
5947
0 commit comments