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