Search in sources :

Example 6 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class AMD64NodeMatchRules method subMemory.

@MatchRule("(Sub value Read=access)")
@MatchRule("(Sub value FloatingRead=access)")
public ComplexMatchResult subMemory(ValueNode value, LIRLowerableAccess access) {
    OperandSize size = getMemorySize(access);
    if (size.isXmmType()) {
        TargetDescription target = getLIRGeneratorTool().target();
        boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
        if (isAvx) {
            return binaryRead(AVXOp.SUB, size, value, access);
        } else {
            return binaryRead(SSEOp.SUB, size, value, access);
        }
    } else {
        return binaryRead(SUB.getRMOpcode(size), size, value, access);
    }
}
Also used : TargetDescription(jdk.vm.ci.code.TargetDescription) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize) MatchRule(org.graalvm.compiler.core.match.MatchRule)

Example 7 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class AMD64NodeMatchRules method addMemory.

@MatchRule("(Add value Read=access)")
@MatchRule("(Add value FloatingRead=access)")
public ComplexMatchResult addMemory(ValueNode value, LIRLowerableAccess access) {
    OperandSize size = getMemorySize(access);
    if (size.isXmmType()) {
        TargetDescription target = getLIRGeneratorTool().target();
        boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
        if (isAvx) {
            return binaryRead(AVXOp.ADD, size, value, access);
        } else {
            return binaryRead(SSEOp.ADD, size, value, access);
        }
    } else {
        return binaryRead(ADD.getRMOpcode(size), size, value, access);
    }
}
Also used : TargetDescription(jdk.vm.ci.code.TargetDescription) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize) MatchRule(org.graalvm.compiler.core.match.MatchRule)

Example 8 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class BitOpsTest method tzcntlMemTest.

@Test
public void tzcntlMemTest() {
    if (tzcntSupported) {
        CodeGenTest test = new CodeGenTest() {

            @Override
            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
                AMD64Assembler asm = new AMD64Assembler(target);
                Register ret = registerConfig.getReturnRegister(JavaKind.Int);
                try {
                    Field f = IntField.class.getDeclaredField("x");
                    AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) UNSAFE.objectFieldOffset(f));
                    TZCNT.emit(asm, DWORD, ret, arg);
                    asm.ret(0);
                    return asm.close(true);
                } catch (Exception e) {
                    throw new RuntimeException("exception while trying to generate field access:", e);
                }
            }
        };
        assertReturn("intFieldStub", test, 31, new IntField(0x8000_0000));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Field(java.lang.reflect.Field) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) AMD64Assembler(org.graalvm.compiler.asm.amd64.AMD64Assembler) TargetDescription(jdk.vm.ci.code.TargetDescription) CompilationResult(org.graalvm.compiler.code.CompilationResult) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Example 9 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class BitOpsTest method tzcntqTest.

@Test
public void tzcntqTest() {
    if (tzcntSupported) {
        CodeGenTest test = new CodeGenTest() {

            @Override
            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
                AMD64Assembler asm = new AMD64Assembler(target);
                Register ret = registerConfig.getReturnRegister(JavaKind.Int);
                Register arg = asRegister(cc.getArgument(0));
                TZCNT.emit(asm, QWORD, ret, arg);
                asm.ret(0);
                return asm.close(true);
            }
        };
        assertReturn("longStub", test, 63, 0x8000_0000_0000_0000L);
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) AMD64Assembler(org.graalvm.compiler.asm.amd64.AMD64Assembler) TargetDescription(jdk.vm.ci.code.TargetDescription) CompilationResult(org.graalvm.compiler.code.CompilationResult) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Example 10 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class BitOpsTest method lzcntlTest.

@Test
public void lzcntlTest() {
    if (lzcntSupported) {
        CodeGenTest test = new CodeGenTest() {

            @Override
            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
                AMD64Assembler asm = new AMD64Assembler(target);
                Register ret = registerConfig.getReturnRegister(JavaKind.Int);
                Register arg = asRegister(cc.getArgument(0));
                LZCNT.emit(asm, DWORD, ret, arg);
                asm.ret(0);
                return asm.close(true);
            }
        };
        assertReturn("intStub", test, 31, 1);
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) AMD64Assembler(org.graalvm.compiler.asm.amd64.AMD64Assembler) TargetDescription(jdk.vm.ci.code.TargetDescription) CompilationResult(org.graalvm.compiler.code.CompilationResult) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Aggregations

TargetDescription (jdk.vm.ci.code.TargetDescription)41 CallingConvention (jdk.vm.ci.code.CallingConvention)14 Register (jdk.vm.ci.code.Register)14 RegisterConfig (jdk.vm.ci.code.RegisterConfig)12 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)11 CompilationResult (org.graalvm.compiler.code.CompilationResult)11 Test (org.junit.Test)11 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)10 AMD64Assembler (org.graalvm.compiler.asm.amd64.AMD64Assembler)10 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)8 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)7 LIRKind (org.graalvm.compiler.core.common.LIRKind)6 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)5 Field (java.lang.reflect.Field)4 BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)4 Value (jdk.vm.ci.meta.Value)3 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)3 HotSpotRegistersProvider (org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 DataSectionReference (jdk.vm.ci.code.site.DataSectionReference)2