Introduce IR and parser support for ML functions.
Representing function arguments is still TODO.
Supporting instructions other than return is also TODO.

PiperOrigin-RevId: 202570934
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index 08fe838..03871fc 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -21,6 +21,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/IR/CFGFunction.h"
+#include "mlir/IR/MLFunction.h"
 #include "mlir/IR/Module.h"
 #include "mlir/IR/Types.h"
 #include "mlir/Support/STLExtras.h"
@@ -151,10 +152,18 @@
   print(llvm::errs());
 }
 
+void MLStatement::print(raw_ostream &os) const {
+  //TODO
+}
+
+void MLStatement::dump() const {
+  print(llvm::errs());
+}
 void Function::print(raw_ostream &os) const {
   switch (getKind()) {
   case Kind::ExtFunc: return cast<ExtFunction>(this)->print(os);
   case Kind::CFGFunc: return cast<CFGFunction>(this)->print(os);
+  case Kind::MLFunc:  return cast<MLFunction>(this)->print(os);
   }
 }
 
@@ -167,6 +176,18 @@
   state.print();
 }
 
+void MLFunction::print(raw_ostream &os) const {
+  os << "mlfunc ";
+  // FIXME: should print argument names rather than just signature
+  printFunctionSignature(this, os);
+  os << " {\n";
+
+  for (auto *stmt : stmtList)
+    stmt->print(os);
+  os << "    return\n";
+  os << "}\n\n";
+}
+
 void Module::print(raw_ostream &os) const {
   for (auto *fn : functionList)
     fn->print(os);
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp
index 833c173..3af2a61 100644
--- a/lib/IR/Function.cpp
+++ b/lib/IR/Function.cpp
@@ -16,6 +16,7 @@
 // =============================================================================
 
 #include "mlir/IR/CFGFunction.h"
+#include "mlir/IR/MLFunction.h"
 #include "llvm/ADT/StringRef.h"
 using namespace mlir;
 
@@ -38,3 +39,11 @@
 CFGFunction::CFGFunction(StringRef name, FunctionType *type)
   : Function(name, type, Kind::CFGFunc) {
 }
+
+//===----------------------------------------------------------------------===//
+// MLFunction implementation.
+//===----------------------------------------------------------------------===//
+
+MLFunction::MLFunction(StringRef name, FunctionType *type)
+  : Function(name, type, Kind::MLFunc) {
+}
diff --git a/lib/IR/MLStatements.cpp b/lib/IR/MLStatements.cpp
new file mode 100644
index 0000000..26fa708
--- /dev/null
+++ b/lib/IR/MLStatements.cpp
@@ -0,0 +1,22 @@
+//===- MLStatements.cpp - MLIR MLStatement Instruction Classes ------------===//
+//
+// Copyright 2019 The MLIR Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// =============================================================================
+
+#include "mlir/IR/MLFunction.h"
+#include "mlir/IR/MLStatements.h"
+using namespace mlir;
+
+// TODO: classes derived from MLStatement