Allow 'constant' op to work with affineint, add some accessors, rearrange

testsuite a bit.

PiperOrigin-RevId: 205852871
This commit is contained in:
Chris Lattner 2018-07-24 10:41:30 -07:00 committed by jpienaar
parent 1b24c48b91
commit 6cab858405
8 changed files with 18 additions and 11 deletions

View File

@ -64,9 +64,13 @@ public:
/// Return the LLVMContext in which this type was uniqued.
MLIRContext *getContext() const { return context; }
/// Print the current type.
void print(raw_ostream &os) const;
void dump() const;
// Convenience predicates. This is only for primitive types, derived types
// should use isa/dyn_cast.
bool isAffineInt() const { return getKind() == Kind::AffineInt; }
bool isBF16() const { return getKind() == Kind::BF16; }
bool isF16() const { return getKind() == Kind::F16; }
bool isF32() const { return getKind() == Kind::F32; }
bool isF64() const { return getKind() == Kind::F64; }
// Convenience factories.
static IntegerType *getInteger(unsigned width, MLIRContext *ctx);
@ -76,6 +80,10 @@ public:
static PrimitiveType *getF32(MLIRContext *ctx);
static PrimitiveType *getF64(MLIRContext *ctx);
/// Print the current type.
void print(raw_ostream &os) const;
void dump() const;
protected:
explicit Type(Kind kind, MLIRContext *context)
: context(context), kind(kind), subclassData(0) {

View File

@ -43,7 +43,7 @@ const char *ConstantOp::verify() const {
return "requires a 'value' attribute";
auto *type = this->getType();
if (isa<IntegerType>(type)) {
if (isa<IntegerType>(type) || type->isAffineInt()) {
if (!isa<IntegerAttr>(value))
return "requires 'value' to be an integer for an integer result type";
return nullptr;

View File

@ -28,7 +28,8 @@ bb42: // CHECK: bb0:
// CHECK: dim xxx, 2 : sometype
%a = "dim"(%42){index: 2} : (tensor<4x4x?xf32>) -> affineint
%f = "Const"(){value: 1} : () -> f32
%f = "FIXMEConst"(){value: 1} : () -> f32
// CHECK: addf xx, yy : sometype
"addf"(%f, %f) : (f32,f32) -> f32
@ -40,9 +41,8 @@ bb42: // CHECK: bb0:
// CHECK-LABEL: cfgfunc @affine_apply() {
cfgfunc @affine_apply() {
bb0:
// TODO: Make constant work with affineint.
%i = "const"() {value: 0} : () -> affineint
%j = "const"() {value: 1} : () -> affineint
%i = "constant"() {value: 0} : () -> affineint
%j = "constant"() {value: 1} : () -> affineint
// CHECK: affine_apply map: (d0) -> ((d0 + 1))
%x = "affine_apply" (%i) { map: (d0) -> (d0 + 1) } :

View File

@ -37,8 +37,7 @@ bb:
cfgfunc @affine_apply_no_map() {
bb0:
// TODO Make constant work with affineint.
%i = "const"() {value: 0} : () -> affineint
%i = "constant"() {value: 0} : () -> affineint
%x = "affine_apply" (%i) { } : (affineint) -> (affineint) // expected-error {{'affine_apply' op requires an affine map.}}
return
}