Use OperationState to simplify the create<Op> methods, move them out of line,
and simplify some other things.  Change ConstantIntOp to not match affine
integers, since we now have ConstantAffineIntOp.

PiperOrigin-RevId: 207756316
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index cb7560e..2f67c27 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -607,10 +607,10 @@
         if (intOp->getType()->isInteger(1)) {
           specialName << (intOp->getValue() ? "true" : "false");
         } else {
-          specialName << 'c' << intOp->getValue();
-          if (!intOp->getType()->isAffineInt())
-            specialName << '_' << *intOp->getType();
+          specialName << 'c' << intOp->getValue() << '_' << *intOp->getType();
         }
+      } else if (auto intOp = op->getAs<ConstantAffineIntOp>()) {
+        specialName << 'c' << intOp->getValue();
       }
     }
 
diff --git a/lib/IR/StandardOps.cpp b/lib/IR/StandardOps.cpp
index b67c12d..95d7931 100644
--- a/lib/IR/StandardOps.cpp
+++ b/lib/IR/StandardOps.cpp
@@ -227,12 +227,33 @@
   return "requires a result type that aligns with the 'value' attribute";
 }
 
-/// ConstantIntOp only matches values whose result type is an IntegerType or
-/// AffineInt.
+/// ConstantIntOp only matches values whose result type is an IntegerType.
 bool ConstantIntOp::isClassFor(const Operation *op) {
   return ConstantOp::isClassFor(op) &&
-         (isa<IntegerType>(op->getResult(0)->getType()) ||
-          op->getResult(0)->getType()->isAffineInt());
+         isa<IntegerType>(op->getResult(0)->getType());
+}
+
+OperationState ConstantIntOp::build(Builder *builder, int64_t value,
+                                    unsigned width) {
+  OperationState result(builder->getIdentifier("constant"));
+  result.attributes.push_back(
+      {builder->getIdentifier("value"), builder->getIntegerAttr(value)});
+  result.types.push_back(builder->getIntegerType(width));
+  return result;
+}
+
+/// ConstantAffineIntOp only matches values whose result type is AffineInt.
+bool ConstantAffineIntOp::isClassFor(const Operation *op) {
+  return ConstantOp::isClassFor(op) &&
+         op->getResult(0)->getType()->isAffineInt();
+}
+
+OperationState ConstantAffineIntOp::build(Builder *builder, int64_t value) {
+  OperationState result(builder->getIdentifier("constant"));
+  result.attributes.push_back(
+      {builder->getIdentifier("value"), builder->getIntegerAttr(value)});
+  result.types.push_back(builder->getAffineIntType());
+  return result;
 }
 
 void DimOp::print(OpAsmPrinter *p) const {