< prev index next >

test/jdk/java/foreign/abi/x64/sysv/StandardCallTest.java

Print this page

        

@@ -34,117 +34,120 @@
 import java.util.List;
 import java.util.stream.Stream;
 
 import jdk.internal.foreign.abi.CallingSequence;
 import jdk.internal.foreign.abi.StorageClass;
-import jdk.internal.foreign.abi.x64.sysv.Constants;
-import jdk.internal.foreign.abi.x64.sysv.StandardCall;
+import jdk.internal.foreign.abi.x64.sysv.CallingSequenceBuilderImpl;
+import jdk.internal.foreign.abi.x64.sysv.SysVx64ABI;
 import jdk.internal.foreign.memory.Types;
 
 public class StandardCallTest {
+
     public StandardCallTest() {
     }
 
     public void testInteger() {
-        StandardCall sc = new StandardCall();
+        CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null);
 
         // Fill registers and spill over with 2 args on stack
-        LayoutType<?> args[] = new LayoutType<?>[Constants.MAX_INTEGER_ARGUMENT_REGISTERS + 2];
-        for (int i = 0; i < Constants.MAX_INTEGER_ARGUMENT_REGISTERS + 2; i++) {
+        LayoutType<?> args[] = new LayoutType<?>[SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS + 2];
+        for (int i = 0; i < SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS + 2; i++) {
             args[i] = NativeTypes.INT64;
         }
 
-        CallingSequence recipe = sc.arrangeCall(null,
-                Stream.of(args).map(LayoutType::layout).toArray(Layout[]::new));
+        Stream.of(args).map(LayoutType::layout).forEach(sc::addArgument);
+        CallingSequence recipe = sc.build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(Constants.MAX_INTEGER_ARGUMENT_REGISTERS, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(2, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(2, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
-        for (int i = 0; i < Constants.MAX_INTEGER_ARGUMENT_REGISTERS; i++) {
-            assertEquals(args[i].layout(), recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).getOffset());
+        for (int i = 0; i < SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS; i++) {
+            assertEquals(args[i].layout(), recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).offset());
         }
 
         for (int i = 0; i < 2; i++) {
-            assertEquals(args[Constants.MAX_INTEGER_ARGUMENT_REGISTERS + i].layout(),
-                    recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getOffset());
+            assertEquals(args[SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS + i].layout(),
+                    recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).offset());
         }
     }
 
     public void testSse() {
-        StandardCall sc = new StandardCall();
+        CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null);
 
         // Fill registers and spill over with 2 args on stack
-        LayoutType<?> args[] = new LayoutType<?>[Constants.MAX_VECTOR_ARGUMENT_REGISTERS + 2];
-        for (int i = 0; i < Constants.MAX_VECTOR_ARGUMENT_REGISTERS + 2; i++) {
+        LayoutType<?> args[] = new LayoutType<?>[SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS + 2];
+        for (int i = 0; i < SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS + 2; i++) {
             args[i] = NativeTypes.IEEE_FLOAT32;
         }
 
-        CallingSequence recipe = sc.arrangeCall(null,
-                Stream.of(args).map(LayoutType::layout).toArray(Layout[]::new));
+        Stream.of(args).map(LayoutType::layout).forEach(sc::addArgument);
+
+        CallingSequence recipe = sc.build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(Constants.MAX_VECTOR_ARGUMENT_REGISTERS, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(2, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(2, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
-        for (int i = 0; i < Constants.MAX_VECTOR_ARGUMENT_REGISTERS; i++) {
-            assertEquals(args[i].layout(), recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).getOffset());
+        for (int i = 0; i < SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS; i++) {
+            assertEquals(args[i].layout(), recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).offset());
         }
 
         for (int i = 0; i < 2; i++) {
-            assertEquals(args[Constants.MAX_VECTOR_ARGUMENT_REGISTERS + i].layout(),
-                    recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getOffset());
+            assertEquals(args[SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS + i].layout(),
+                    recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).offset());
         }
     }
 
      public void testMixed() {
-        StandardCall sc = new StandardCall();
+        CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null);
 
         // Fill GP registers + 2 on stack
         List<LayoutType<?>> args = new ArrayList<>();
-        for (int i = 0; i < Constants.MAX_INTEGER_ARGUMENT_REGISTERS + 2; i++) {
+        for (int i = 0; i < SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS + 2; i++) {
             args.add(NativeTypes.INT64);
         }
 
         // Fill SSE registers + 2 on stack
-        for (int i = 0; i < Constants.MAX_VECTOR_ARGUMENT_REGISTERS + 2; i++) {
+        for (int i = 0; i < SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS + 2; i++) {
             args.add(NativeTypes.IEEE_FLOAT32);
         }
 
-        CallingSequence recipe = sc.arrangeCall(null,
-                args.stream().map(LayoutType::layout).toArray(Layout[]::new));
+        args.stream().map(LayoutType::layout).forEach(sc::addArgument);
+
+        CallingSequence recipe = sc.build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(Constants.MAX_INTEGER_ARGUMENT_REGISTERS, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(Constants.MAX_VECTOR_ARGUMENT_REGISTERS, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(4, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(4, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         int arg = 0;
-        for (int i = 0; i < Constants.MAX_INTEGER_ARGUMENT_REGISTERS; i++, arg++) {
-            assertEquals(args.get(arg).layout(), recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).getOffset());
+        for (int i = 0; i < SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS; i++, arg++) {
+            assertEquals(args.get(arg).layout(), recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(i).offset());
         }
 
         for (int i = 0; i < 2; i++, arg++) {
-            assertEquals(args.get(arg).layout(), recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getOffset());
+            assertEquals(args.get(arg).layout(), recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).offset());
         }
 
-        for (int i = 0; i < Constants.MAX_VECTOR_ARGUMENT_REGISTERS; i++, arg++) {
-            assertEquals(args.get(arg).layout(), recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).getOffset());
+        for (int i = 0; i < SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS; i++, arg++) {
+            assertEquals(args.get(arg).layout(), recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(i).offset());
         }
 
         for (int i = 2; i < 4; i++, arg++) {
-            assertEquals(args.get(arg).layout(), recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getMember().getType());
-            assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).getOffset());
+            assertEquals(args.get(arg).layout(), recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).argument().layout());
+            assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(i).offset());
         }
     }
 
     /**
      * This is the example from the System V ABI AMD64 document

@@ -164,67 +167,68 @@
     public void testAbiExample() {
         Layout[] args = { Types.INT32, Types.INT32, Group.struct(Types.INT32, Types.INT32, Types.DOUBLE),
                 Types.INT32, Types.INT32, Types.LONG_DOUBLE, Types.DOUBLE,
                 Types.DOUBLE, Types.INT32, Types.INT32, Types.INT32 };
 
-        StandardCall sc = new StandardCall();
-        CallingSequence recipe = sc.arrangeCall(null, args);
+        CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null);
+        Stream.of(args).forEach(sc::addArgument);
+        CallingSequence recipe = sc.build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(6, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(3, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(4, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(6, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(3, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(4, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // e
-        assertEquals(args[0], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(args[0], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
 
         // f
-        assertEquals(args[1], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getOffset());
+        assertEquals(args[1], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).offset());
 
         // s.a & s.b
-        assertEquals(args[2], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(2).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(2).getOffset());
+        assertEquals(args[2], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(2).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(2).offset());
 
         // s.d
-        assertEquals(args[2], recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(args[2], recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).offset());
 
         // g
-        assertEquals(args[3], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(3).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(3).getOffset());
+        assertEquals(args[3], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(3).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(3).offset());
 
         // h
-        assertEquals(args[4], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(4).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(4).getOffset());
+        assertEquals(args[4], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(4).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(4).offset());
 
         // ld
-        assertEquals(args[5], recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getOffset());
-        assertEquals(args[5], recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getOffset());
+        assertEquals(args[5], recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).offset());
+        assertEquals(args[5], recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).offset());
 
         // m
-        assertEquals(args[6], recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).getOffset());
+        assertEquals(args[6], recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).offset());
 
         // n
-        assertEquals(args[7], recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(2).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(2).getOffset());
+        assertEquals(args[7], recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(2).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(2).offset());
 
         // i
-        assertEquals(args[8], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(5).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(5).getOffset());
+        assertEquals(args[8], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(5).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(5).offset());
 
         // j
-        assertEquals(args[9], recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).getOffset());
+        assertEquals(args[9], recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).offset());
 
         // k
-        assertEquals(args[10], recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).getOffset());
+        assertEquals(args[10], recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).offset());
     }
 
     /**
      * This is a varargs example from the System V ABI AMD64 document
      *

@@ -242,40 +246,41 @@
                 Types.INT,
                 Types.DOUBLE,
                 Types.INT,
                 Types.LONG_DOUBLE,
                 Types.DOUBLE };
-        StandardCall sc = new StandardCall();
-        CallingSequence recipe = sc.arrangeCall(null, args);
+        CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null);
+        Stream.of(args).forEach(sc::addArgument);
+        CallingSequence recipe = sc.build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(2, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(2, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(2, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(2, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(2, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(2, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
 
         // a
-        assertEquals(args[0], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(args[0], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
 
         // m
-        assertEquals(args[1], recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(args[1], recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).offset());
 
         // b
-        assertEquals(args[2], recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getOffset());
+        assertEquals(args[2], recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).offset());
 
         // ld
-        assertEquals(args[3], recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getOffset());
-        assertEquals(args[3], recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getOffset());
+        assertEquals(args[3], recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).offset());
+        assertEquals(args[3], recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).offset());
 
         // n
-        assertEquals(args[4], recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).getOffset());
+        assertEquals(args[4], recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).offset());
     }
 
 
     /**
      * struct s {

@@ -287,21 +292,22 @@
      * m(s);
      */
     public void testStruct8() {
         Group structparm = Group.struct(Types.UNSIGNED.INT64);
 
-        StandardCall sc = new StandardCall();
-        CallingSequence recipe = sc.arrangeCall(null, structparm);
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(structparm)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(1, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(1, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // s.u0
-        assertEquals(structparm, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
     }
 
     /**
      * struct s {
      *   uint64_t u0, u1;

@@ -312,25 +318,26 @@
      * m(s);
      */
     public void testStruct16() {
         Group structparm = Group.struct(Types.UNSIGNED.INT64, Types.UNSIGNED.INT64);
 
-        StandardCall sc = new StandardCall();
-        CallingSequence recipe = sc.arrangeCall(null, structparm);
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(structparm)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(2, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(2, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // s.u0
-        assertEquals(structparm, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
 
         // s.u1
-        assertEquals(structparm, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).offset());
     }
 
     /**
      * struct s {
      *   uint64_t u0, u1, u2;

@@ -341,29 +348,30 @@
      * m(s);
      */
     public void testStruct24() {
         Group structparm = Group.struct(Types.UNSIGNED.INT64, Types.UNSIGNED.INT64, Types.UNSIGNED.INT64);
 
-        StandardCall sc = new StandardCall();
-        CallingSequence recipe = sc.arrangeCall(null, structparm);
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(structparm)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(3, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(3, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // s.u0
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).offset());
 
         // s.u1
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).offset());
 
         // s.u2
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).getMember().getType());
-        assertEquals(16, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).argument().layout());
+        assertEquals(16, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).offset());
     }
 
     /**
      * struct s {
      *   uint64_t u0, u1, u2, u3;

@@ -374,33 +382,34 @@
      * m(s);
      */
     public void testStruct32() {
         Layout structparm = Layout.of("[u64u64u64u64]");
 
-        StandardCall sc = new StandardCall();
-        CallingSequence recipe = sc.arrangeCall(null, structparm);
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(structparm)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(4, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(4, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // s.u0
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(0).offset());
 
         // s.u1
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(1).offset());
 
         // s.u2
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).getMember().getType());
-        assertEquals(16, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).argument().layout());
+        assertEquals(16, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(2).offset());
 
         // s.u3
-        assertEquals(structparm, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).getMember().getType());
-        assertEquals(24, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).getOffset());
+        assertEquals(structparm, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).argument().layout());
+        assertEquals(24, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).get(3).offset());
     }
 
     /**
      * typedef void (*f)(void);
      *

@@ -409,41 +418,46 @@
      *
      * m(f_impl);
      */
     public void testFunctionType() {
         Layout arg = Layout.of("u64:()v");
-        CallingSequence recipe = new StandardCall().arrangeCall(null, arg);
+
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(arg)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(1, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(1, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // s.u0
-        assertEquals(arg, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(arg, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
     }
 
     /**
      * void f(int64_t l0, float f0, __m256 m0);
      */
     public void testMixedArgs() {
-        CallingSequence recipe = new StandardCall().arrangeCall(null,
-                Types.INT64, Types.FLOAT);
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(Types.INT64)
+                .addArgument(Types.FLOAT)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(1, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(1, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(1, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(1, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // l0
-        assertEquals(Types.INT64, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(Types.INT64, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
 
         // f0
-        assertEquals(Types.FLOAT, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(Types.FLOAT, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(0).offset());
     }
 
     /**
      * struct s {
      *    int64_t l0;

@@ -453,24 +467,26 @@
      * void f(struct s s1);
      */
     public void testIntegerStruct() {
         Layout arg = Layout.of("[i64i64]");
 
-        CallingSequence recipe = new StandardCall().arrangeCall(null, arg);
+        CallingSequence recipe = new CallingSequenceBuilderImpl(null)
+                .addArgument(arg)
+                .build();
 
         assertEquals(false, recipe.returnsInMemory());
-        assertEquals(2, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
-        assertEquals(0, recipe.getBindings(StorageClass.STACK_ARGUMENT_SLOT).size());
+        assertEquals(2, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).size());
+        assertEquals(0, recipe.bindings(StorageClass.STACK_ARGUMENT_SLOT).size());
 
         // s.l0
-        assertEquals(arg, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getMember().getType());
-        assertEquals(0, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).getOffset());
+        assertEquals(arg, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).argument().layout());
+        assertEquals(0, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(0).offset());
 
         // s.l1
-        assertEquals(arg, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getMember().getType());
-        assertEquals(8, recipe.getBindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).getOffset());
+        assertEquals(arg, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).argument().layout());
+        assertEquals(8, recipe.bindings(StorageClass.INTEGER_ARGUMENT_REGISTER).get(1).offset());
     }
 
     static void assertEquals(long expected, long actual) {
         if (expected != actual) {
             throw new RuntimeException("expected: " + expected + " does not match actual: " + actual);
< prev index next >