Search in sources :

Example 1 with LLVMAMD64Target

use of com.oracle.truffle.llvm.nodes.asm.support.LLVMAMD64Target in project sulong by graalvm.

the class AsmFactory method getTarget.

private LLVMAMD64Target getTarget(Type type, AsmOperand operand) {
    if (operand instanceof AsmRegisterOperand) {
        AsmRegisterOperand op = (AsmRegisterOperand) operand;
        FrameSlot frame = getRegisterSlot(op.getBaseRegister());
        int shift = op.getShift();
        assert type == op.getType();
        switch(((PrimitiveType) op.getType()).getPrimitiveKind()) {
            case I8:
                return new LLVMAMD64Target(frame, shift);
            case I16:
            case I32:
            case I64:
                return new LLVMAMD64Target(frame);
            default:
                throw new AsmParseException("unsupported operand type: " + op.getType());
        }
    } else if (operand instanceof AsmArgumentOperand) {
        AsmArgumentOperand op = (AsmArgumentOperand) operand;
        Argument info = argInfo.get(op.getIndex());
        if (info.isMemory()) {
            LLVMExpressionNode address = info.getAddress();
            if (type instanceof PointerType) {
                return new LLVMAMD64Target(address);
            }
            switch(((PrimitiveType) type).getPrimitiveKind()) {
                case I8:
                case I16:
                case I32:
                case I64:
                    return new LLVMAMD64Target(address);
                default:
                    throw new AsmParseException("unsupported operand type: " + type);
            }
        } else if (info.isRegister()) {
            FrameSlot frame = getRegisterSlot(info.getRegister());
            if (type instanceof PointerType || info.getType() instanceof PointerType) {
                return new LLVMAMD64Target(frame);
            }
            switch(((PrimitiveType) type).getPrimitiveKind()) {
                case I8:
                case I16:
                case I32:
                case I64:
                    return new LLVMAMD64Target(frame);
                default:
                    throw new AsmParseException("unsupported operand type: " + type);
            }
        } else {
            throw new AssertionError("this should not happen; " + info);
        }
    }
    throw new AsmParseException("unsupported operand type: " + operand);
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) LLVMAMD64Target(com.oracle.truffle.llvm.nodes.asm.support.LLVMAMD64Target)

Example 2 with LLVMAMD64Target

use of com.oracle.truffle.llvm.nodes.asm.support.LLVMAMD64Target in project sulong by graalvm.

the class AsmFactory method getRegisterTarget.

private LLVMAMD64Target getRegisterTarget(Type type, String name) {
    AsmRegisterOperand op = new AsmRegisterOperand(name);
    FrameSlot frame = getRegisterSlot(name);
    switch(((PrimitiveType) type).getPrimitiveKind()) {
        case I8:
            return new LLVMAMD64Target(frame, op.getShift());
        case I16:
        case I32:
        case I64:
            return new LLVMAMD64Target(frame);
        default:
            throw new AsmParseException("unsupported operand type");
    }
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) LLVMAMD64Target(com.oracle.truffle.llvm.nodes.asm.support.LLVMAMD64Target)

Aggregations

FrameSlot (com.oracle.truffle.api.frame.FrameSlot)2 LLVMAMD64Target (com.oracle.truffle.llvm.nodes.asm.support.LLVMAMD64Target)2 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)2 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)1 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)1