Skip to content

Commit

Permalink
dialects: LLVM updates. (#1882)
Browse files Browse the repository at this point in the history
Some updates to the LLVM dialect, everything is retro-compatible:
- `llvm.call` can return something.
- `llvm.func` has a sym_visibility optional property.
  • Loading branch information
PapyChacal authored Dec 18, 2023
1 parent 2ee22ab commit 4d12962
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xdsl/dialects/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ class FuncOp(IRDLOperation):
function_type: LLVMFunctionType = prop_def(LLVMFunctionType)
CConv: CallingConventionAttr = prop_def(CallingConventionAttr)
linkage: LinkageAttr = prop_def(LinkageAttr)
sym_visibility = opt_prop_def(StringAttr)
visibility_: IntegerAttr[IntegerType] = prop_def(IntegerAttr[IntegerType])

def __init__(
Expand All @@ -1043,6 +1044,7 @@ def __init__(
linkage: LinkageAttr = LinkageAttr("internal"),
cconv: CallingConventionAttr = CallingConventionAttr("ccc"),
visibility: int | IntegerAttr[IntegerType] = 0,
sym_visibility: str | StringAttr | None = None,
body: Region | None = None,
):
if isinstance(sym_name, str):
Expand All @@ -1051,6 +1053,8 @@ def __init__(
visibility = IntegerAttr.from_int_and_width(visibility, 64)
if body is None:
body = Region([])
if isinstance(sym_visibility, str):
sym_visibility = StringAttr(sym_visibility)
super().__init__(
operands=[],
regions=[body],
Expand All @@ -1060,6 +1064,7 @@ def __init__(
"CConv": cconv,
"linkage": linkage,
"visibility_": visibility,
"sym_visibility": sym_visibility,
},
)

Expand Down Expand Up @@ -1202,9 +1207,10 @@ class CallOp(IRDLOperation):
args: VarOperand = var_operand_def()

callee: SymbolRefAttr = prop_def(SymbolRefAttr)
callee_type: LLVMFunctionType = prop_def(LLVMFunctionType)
callee_type: LLVMFunctionType | None = opt_prop_def(LLVMFunctionType)
fastmathFlags: FastMathAttr = prop_def(FastMathAttr)
CConv: CallingConventionAttr = prop_def(CallingConventionAttr)
returned = opt_result_def()

def __init__(
self,
Expand All @@ -1217,6 +1223,7 @@ def __init__(
):
if isinstance(callee, str):
callee = SymbolRefAttr(callee)
op_result_type = [return_type]
if return_type is None:
return_type = LLVMVoidType()
input_types = [
Expand All @@ -1231,6 +1238,7 @@ def __init__(
"fastmathFlags": fastmath,
"CConv": calling_convention,
},
result_types=op_result_type,
)


Expand Down

0 comments on commit 4d12962

Please sign in to comment.