Skip to content

Commit

Permalink
hl: Allow builtin dialect types in pointer arithmetic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko authored and xlauko committed Nov 16, 2023
1 parent 0afb014 commit a3a201f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/vast/Dialect/HighLevel/HighLevelOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "vast/Util/Warnings.hpp"

VAST_RELAX_WARNINGS
#include <mlir/IR/BuiltinDialect.h>
#include <mlir/IR/FunctionInterfaces.h>
#include <mlir/Interfaces/InferTypeOpInterface.h>
VAST_UNRELAX_WARNINGS
Expand Down
14 changes: 9 additions & 5 deletions include/vast/Dialect/HighLevel/HighLevelOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,12 @@ def CStyleCastOp : CastOp< "cstyle_cast" >;
def BuiltinBitCastOp : CastOp< "builtin_bitcast" >;

class IsPointerCompatible< string arg > : PredTypeTrait< "type can be added/subtracted to a pointer",
And< [IsIntegral< arg >.predicate,
Neg< IsShort< arg >.predicate >,
Neg< IsChar< arg >.predicate >,
Neg< IsBool< arg >.predicate >
Or < [And< [IsIntegral< arg >.predicate,
Neg< IsShort< arg >.predicate >,
Neg< IsChar< arg >.predicate >,
Neg< IsBool< arg >.predicate >
] >,
IsBuiltinType< arg >.predicate
] >
>;

Expand All @@ -609,7 +611,9 @@ class IsPointerAdditive< string lhs, string rhs, string res > : PredOpTrait< "is
>;

class PtrDiffLike< string lhs, string rhs, string res > : PredOpTrait< "is a subtraction of pointers",
And< [IsPointer< lhs >.predicate, IsPointer< rhs >.predicate, Or< [ IsLong< res >.predicate, CPred< "mlir::isa< mlir::IntegerType >($" # res # ".getType())" >] > ] >
And< [IsPointer< lhs >.predicate, IsPointer< rhs >.predicate,
Or< [ IsLong< res >.predicate, IsBuiltinType< res >.predicate] >
] >
>;

class IsAdditive< string lhs, string rhs, string res > : PredOpTrait< "is an additive operation (types match or are ptr and integral)", Or<[
Expand Down

0 comments on commit a3a201f

Please sign in to comment.