@@ -3896,6 +3896,86 @@ def FMinOp : BinaryFPToFPBuiltinOp<"fmin", "MinNumOp">;
38963896def FModOp : BinaryFPToFPBuiltinOp<"fmod", "FRemOp">;
38973897def PowOp : BinaryFPToFPBuiltinOp<"pow", "PowOp">;
38983898
3899+ //===----------------------------------------------------------------------===//
3900+ // Assume Operations
3901+ //===----------------------------------------------------------------------===//
3902+
3903+ def AssumeOp : CIR_Op<"assume"> {
3904+ let summary = "Tell the optimizer that a boolean value is true";
3905+ let description = [{
3906+ The `cir.assume` operation takes a single boolean prediate as its only
3907+ argument and does not have any results. The operation tells the optimizer
3908+ that the predicate's value is true.
3909+
3910+ This operation corresponds to the `__assume` and the `__builtin_assume`
3911+ builtin function.
3912+ }];
3913+
3914+ let arguments = (ins CIR_BoolType:$predicate);
3915+ let results = (outs);
3916+
3917+ let assemblyFormat = [{
3918+ $predicate `:` type($predicate) attr-dict
3919+ }];
3920+ }
3921+
3922+ def AssumeAlignedOp
3923+ : CIR_Op<"assume.aligned", [Pure, AllTypesMatch<["pointer", "result"]>]> {
3924+ let summary = "Tell the optimizer that a pointer is aligned";
3925+ let description = [{
3926+ The `cir.assume.aligned` operation takes two or three arguments.
3927+
3928+ When the 3rd argument `offset` is absent, this operation tells the optimizer
3929+ that the pointer given by the `pointer` argument is aligned to the alignment
3930+ given by the `align` argument.
3931+
3932+ When the `offset` argument is given, it represents an offset from the
3933+ alignment. This operation then tells the optimizer that the pointer given by
3934+ the `pointer` argument is always misaligned by the alignment given by the
3935+ `align` argument by `offset` bytes, a.k.a. the pointer yielded by
3936+ `(char *)pointer - offset` is aligned to the specified alignment.
3937+
3938+ The `align` argument is a constant integer represented as an integer
3939+ attribute instead of an SSA value. It must be a positive integer.
3940+
3941+ The result of this operation has the same value as the `pointer` argument,
3942+ but the optimizer has additional knowledge about its alignment.
3943+
3944+ This operation corresponds to the `__builtin_assume_aligned` builtin
3945+ function.
3946+ }];
3947+
3948+ let arguments = (ins CIR_PointerType:$pointer,
3949+ I64Attr:$alignment,
3950+ Optional<CIR_IntType>:$offset);
3951+ let results = (outs CIR_PointerType:$result);
3952+
3953+ let assemblyFormat = [{
3954+ $pointer `:` qualified(type($pointer))
3955+ `[` `alignment` $alignment (`,` `offset` $offset^ `:` type($offset))? `]`
3956+ attr-dict
3957+ }];
3958+ }
3959+
3960+ def AssumeSepStorageOp : CIR_Op<"assume.separate_storage", [SameTypeOperands]> {
3961+ let summary =
3962+ "Tell the optimizer that two pointers point to different allocations";
3963+ let description = [{
3964+ The `cir.assume.separate_storage` operation takes two pointers as arguments,
3965+ and the operation tells the optimizer that these two pointers point to
3966+ different allocations.
3967+
3968+ This operation corresponds to the `__builtin_assume_separate_storage`
3969+ builtin function.
3970+ }];
3971+
3972+ let arguments = (ins VoidPtr:$ptr1, VoidPtr:$ptr2);
3973+
3974+ let assemblyFormat = [{
3975+ $ptr1 `,` $ptr2 `:` qualified(type($ptr1)) attr-dict
3976+ }];
3977+ }
3978+
38993979//===----------------------------------------------------------------------===//
39003980// Branch Probability Operations
39013981//===----------------------------------------------------------------------===//
0 commit comments