github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/engine/wazevo/backend/regalloc/reg_test.go (about)

     1  package regalloc
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/bananabytelabs/wazero/internal/engine/wazevo/ssa"
     7  	"github.com/bananabytelabs/wazero/internal/testing/require"
     8  )
     9  
    10  func TestRegTypeOf(t *testing.T) {
    11  	require.Equal(t, RegTypeInt, RegTypeOf(ssa.TypeI32))
    12  	require.Equal(t, RegTypeInt, RegTypeOf(ssa.TypeI64))
    13  	require.Equal(t, RegTypeFloat, RegTypeOf(ssa.TypeF32))
    14  	require.Equal(t, RegTypeFloat, RegTypeOf(ssa.TypeF64))
    15  }
    16  
    17  func TestVReg_String(t *testing.T) {
    18  	require.Equal(t, "v0?", VReg(0).String())
    19  	require.Equal(t, "v100?", VReg(100).String())
    20  	require.Equal(t, "r5", FromRealReg(5, RegTypeInt).String())
    21  }
    22  
    23  func Test_FromRealReg(t *testing.T) {
    24  	r := FromRealReg(5, RegTypeInt)
    25  	require.Equal(t, RealReg(5), r.RealReg())
    26  	require.Equal(t, VRegID(5), r.ID())
    27  }