Skip to content

Convert

convert

LLVMTarget dataclass

Bases: Target

Source code in xdsl/backend/llvm/convert.py
76
77
78
79
80
81
82
@dataclass(frozen=True)
class LLVMTarget(Target):
    name = "llvm"

    def emit(self, ctx: Context, module: ModuleOp, output: IO[str]) -> None:
        llvm_module = convert_module(module)
        print(llvm_module, file=output)

name = 'llvm' class-attribute instance-attribute

__init__() -> None

emit(ctx: Context, module: ModuleOp, output: IO[str]) -> None

Source code in xdsl/backend/llvm/convert.py
80
81
82
def emit(self, ctx: Context, module: ModuleOp, output: IO[str]) -> None:
    llvm_module = convert_module(module)
    print(llvm_module, file=output)

convert_module(module: ModuleOp) -> ir.Module

Convert an xDSL module to an LLVM module.

Source code in xdsl/backend/llvm/convert.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def convert_module(module: ModuleOp) -> ir.Module:
    """
    Convert an xDSL module to an LLVM module.
    """
    llvm_module = ir.Module()

    for op in module.ops:
        match op:
            case llvm.FuncOp():
                _convert_func(op, llvm_module)
            case _:
                raise NotImplementedError(
                    f"Conversion not implemented for op: {op.name}"
                )

    return llvm_module