< prev index next >

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

Print this page

        

*** 34,150 **** 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.memory.Types; public class StandardCallTest { public StandardCallTest() { } public void testInteger() { ! StandardCall sc = new StandardCall(); // 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++) { args[i] = NativeTypes.INT64; } ! CallingSequence recipe = sc.arrangeCall(null, ! Stream.of(args).map(LayoutType::layout).toArray(Layout[]::new)); 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()); ! 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 < 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()); } } public void testSse() { ! StandardCall sc = new StandardCall(); // 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++) { args[i] = NativeTypes.IEEE_FLOAT32; } ! CallingSequence recipe = sc.arrangeCall(null, ! Stream.of(args).map(LayoutType::layout).toArray(Layout[]::new)); 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()); ! 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 < 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()); } } public void testMixed() { ! StandardCall sc = new StandardCall(); // Fill GP registers + 2 on stack List<LayoutType<?>> args = new ArrayList<>(); ! for (int i = 0; i < Constants.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++) { args.add(NativeTypes.IEEE_FLOAT32); } ! CallingSequence recipe = sc.arrangeCall(null, ! args.stream().map(LayoutType::layout).toArray(Layout[]::new)); 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()); 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 < 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()); } ! 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 = 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()); } } /** * This is the example from the System V ABI AMD64 document --- 34,153 ---- 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.CallingSequenceBuilderImpl; ! import jdk.internal.foreign.abi.x64.sysv.SysVx64ABI; import jdk.internal.foreign.memory.Types; public class StandardCallTest { + public StandardCallTest() { } public void testInteger() { ! CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null); // Fill registers and spill over with 2 args on stack ! 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; } ! Stream.of(args).map(LayoutType::layout).forEach(sc::addArgument); ! CallingSequence recipe = sc.build(); assertEquals(false, recipe.returnsInMemory()); ! 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 < 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[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() { ! CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null); // Fill registers and spill over with 2 args on stack ! 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; } ! Stream.of(args).map(LayoutType::layout).forEach(sc::addArgument); ! ! CallingSequence recipe = sc.build(); assertEquals(false, recipe.returnsInMemory()); ! 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 < 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[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() { ! CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null); // Fill GP registers + 2 on stack List<LayoutType<?>> args = new ArrayList<>(); ! 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 < SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS + 2; i++) { args.add(NativeTypes.IEEE_FLOAT32); } ! args.stream().map(LayoutType::layout).forEach(sc::addArgument); ! ! CallingSequence recipe = sc.build(); assertEquals(false, recipe.returnsInMemory()); ! 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 < 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.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 < 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.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,230 **** 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); 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); // 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()); } /** * This is a varargs example from the System V ABI AMD64 document * --- 167,234 ---- 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 }; ! CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null); ! Stream.of(args).forEach(sc::addArgument); ! CallingSequence recipe = sc.build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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.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.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.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.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.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.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.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.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.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.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,281 **** Types.INT, Types.DOUBLE, Types.INT, Types.LONG_DOUBLE, Types.DOUBLE }; ! StandardCall sc = new StandardCall(); ! CallingSequence recipe = sc.arrangeCall(null, args); 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()); // 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()); // 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()); // 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()); // 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()); // 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()); } /** * struct s { --- 246,286 ---- Types.INT, Types.DOUBLE, Types.INT, Types.LONG_DOUBLE, Types.DOUBLE }; ! CallingSequenceBuilderImpl sc = new CallingSequenceBuilderImpl(null); ! Stream.of(args).forEach(sc::addArgument); ! CallingSequence recipe = sc.build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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.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.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.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).argument().layout()); ! assertEquals(0, recipe.bindings(StorageClass.VECTOR_ARGUMENT_REGISTER).get(1).offset()); } /** * struct s {
*** 287,307 **** * m(s); */ public void testStruct8() { Group structparm = Group.struct(Types.UNSIGNED.INT64); ! StandardCall sc = new StandardCall(); ! CallingSequence recipe = sc.arrangeCall(null, structparm); 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()); // 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()); } /** * struct s { * uint64_t u0, u1; --- 292,313 ---- * m(s); */ public void testStruct8() { Group structparm = Group.struct(Types.UNSIGNED.INT64); ! CallingSequence recipe = new CallingSequenceBuilderImpl(null) ! .addArgument(structparm) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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,336 **** * 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); 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()); // 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()); // 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()); } /** * struct s { * uint64_t u0, u1, u2; --- 318,343 ---- * m(s); */ public void testStruct16() { Group structparm = Group.struct(Types.UNSIGNED.INT64, Types.UNSIGNED.INT64); ! CallingSequence recipe = new CallingSequenceBuilderImpl(null) ! .addArgument(structparm) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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,369 **** * 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); 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()); // 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()); // 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()); // 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()); } /** * struct s { * uint64_t u0, u1, u2, u3; --- 348,377 ---- * m(s); */ public void testStruct24() { Group structparm = Group.struct(Types.UNSIGNED.INT64, Types.UNSIGNED.INT64, Types.UNSIGNED.INT64); ! CallingSequence recipe = new CallingSequenceBuilderImpl(null) ! .addArgument(structparm) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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.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,406 **** * m(s); */ public void testStruct32() { Layout structparm = Layout.of("[u64u64u64u64]"); ! StandardCall sc = new StandardCall(); ! CallingSequence recipe = sc.arrangeCall(null, structparm); 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()); // 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()); // 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()); // 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()); // 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()); } /** * typedef void (*f)(void); * --- 382,415 ---- * m(s); */ public void testStruct32() { Layout structparm = Layout.of("[u64u64u64u64]"); ! CallingSequence recipe = new CallingSequenceBuilderImpl(null) ! .addArgument(structparm) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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.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.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,449 **** * * m(f_impl); */ public void testFunctionType() { Layout arg = Layout.of("u64:()v"); ! CallingSequence recipe = new StandardCall().arrangeCall(null, arg); 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()); // 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()); } /** * void f(int64_t l0, float f0, __m256 m0); */ public void testMixedArgs() { ! CallingSequence recipe = new StandardCall().arrangeCall(null, ! Types.INT64, Types.FLOAT); 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()); // 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()); // 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()); } /** * struct s { * int64_t l0; --- 418,463 ---- * * m(f_impl); */ public void testFunctionType() { Layout arg = Layout.of("u64:()v"); ! ! CallingSequence recipe = new CallingSequenceBuilderImpl(null) ! .addArgument(arg) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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 CallingSequenceBuilderImpl(null) ! .addArgument(Types.INT64) ! .addArgument(Types.FLOAT) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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,476 **** * void f(struct s s1); */ public void testIntegerStruct() { Layout arg = Layout.of("[i64i64]"); ! CallingSequence recipe = new StandardCall().arrangeCall(null, arg); 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()); // 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()); // 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()); } static void assertEquals(long expected, long actual) { if (expected != actual) { throw new RuntimeException("expected: " + expected + " does not match actual: " + actual); --- 467,492 ---- * void f(struct s s1); */ public void testIntegerStruct() { Layout arg = Layout.of("[i64i64]"); ! CallingSequence recipe = new CallingSequenceBuilderImpl(null) ! .addArgument(arg) ! .build(); assertEquals(false, recipe.returnsInMemory()); ! 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.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.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 >