summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
Commit message (Collapse)AuthorAgeFilesLines
...
* Enhance MLIRContext and operations with the ability to register diagnosticChris Lattner2019-03-295-9/+107
| | | | | | | | | | | | handlers and to feed them with errors and warnings produced by the compiler. Enhance Operation to be able to get its own MLIRContext on demand, simplifying some clients. Change the verifier to emit certain errors with the diagnostic handler. This is steps towards reworking the verifier and diagnostic propagation but is itself not particularly useful. More to come. PiperOrigin-RevId: 206948643
* Clean up and extend MLFuncBuilder to allow creating statements in the middle ↵Tatiana Shpeisman2019-03-294-6/+9
| | | | | | | | of a statement block. Rename Statement::getFunction() and StmtBlock()::getFunction() to findFunction() to make it clear that this is not a constant time getter. Fix b/112039912 - we were recording 'i' instead of '%i' for loop induction variables causing "use of undefined SSA value" error. PiperOrigin-RevId: 206884644
* Fix some issues where we weren't printing affine map references symbolically.Chris Lattner2019-03-291-2/+8
| | | | | | | | Two problems: 1) we didn't visit the types in ops correctly, and 2) the general "T" version of the OpAsmPrinter inserter would match things like MemRefType& and print it directly. PiperOrigin-RevId: 206863642
* Revise the AffineExpr printing logic to be more careful about paren emission.Chris Lattner2019-03-292-45/+70
| | | | | | | | | This is still (intentionally) generating redundant parens for nested tightly binding expressions, but I think that is reasonable for readability sake. This also print x-y instead of x-(y*1) PiperOrigin-RevId: 206847212
* Make MemRefType::getNumDynamicDims const.MLIR Team2019-03-291-1/+1
| | | | PiperOrigin-RevId: 206834416
* Adds a standard op for MLIR 'store' instruction.MLIR Team2019-03-291-3/+59
| | | | PiperOrigin-RevId: 206824609
* Use for statement directly as an operand instead of having it pretend to be ↵Tatiana Shpeisman2019-03-292-8/+6
| | | | | | an induction variable. PiperOrigin-RevId: 206759180
* Implement induction variables. Pretty print induction variable operands as ↵Tatiana Shpeisman2019-03-293-11/+53
| | | | | | | | | | %i<ssa value number>. Add support for future pretty printing of ML function arguments as %arg<ssa value number>. Induction variables are implemented by inheriting ForStmt from MLValue. ForStmt provides APIs that make this design decision invisible to the ForStmt users. This CL in combination with cl/206253643 resolves http://b/111769060. PiperOrigin-RevId: 206655937
* Add standard op for MLIR 'alloc' instruction (with parser and associated tests).MLIR Team2019-03-292-27/+108
| | | | | | Adds field to MemRefType to query number of dynamic dimensions. PiperOrigin-RevId: 206633162
* Improvements to Op trait implementation:Chris Lattner2019-03-291-2/+2
| | | | | | | | | - Generalize TwoOperands and TwoResults to NOperands and NResults, which can be used for any fixed N. - Rename OpImpl namespace to OpTrait, OpImpl::Base to OpBase, and TraitImpl to TraitBase to better reflect what these are. PiperOrigin-RevId: 206588634
* Change mlir-opt.cpp to take a list of passes to run, simplifying the driverChris Lattner2019-03-291-12/+12
| | | | | | | code. Change printing of affine map's to not print a space between the dim and symbol list. PiperOrigin-RevId: 206505419
* Prepare for implementation of TensorFlow passes:Chris Lattner2019-03-291-0/+38
| | | | | | | | | | - Sketch out a TensorFlow/IR directory that will hold op definitions and common TF support logic. We will eventually have TensorFlow/TF2HLO, TensorFlow/Grappler, TensorFlow/TFLite, etc. - Add sketches of a Switch/Merge op definition, including some missing stuff like the TwoResults trait. Add a skeleton of a pass to raise this form. - Beef up the Pass/FunctionPass definitions slightly, moving the common code out of LoopUnroll.cpp into a new IR/Pass.cpp file. - Switch ConvertToCFG.cpp to be a ModulePass. - Allow _ to start bare identifiers, since this is important for TF attributes. PiperOrigin-RevId: 206502517
* Finish parser/printer support for AffineMapOp, implement operand iterators onChris Lattner2019-03-292-37/+91
| | | | | | | VariadicOperands, tidy up some code in the asmprinter, fill out more verification logic in for LoadOp. PiperOrigin-RevId: 206443020
* Eliminate "primitive" types from being a thing, splitting them into FloatTypeChris Lattner2019-03-293-31/+56
| | | | | | | | | | | | | | and OtherType. Other type is now the thing that holds AffineInt, Control, eventually Resource, Variant, String, etc. FloatType holds the floating point types, and allows convenient query of isa<FloatType>(). This fixes issues where we allowed control to be the element type of tensor, memref, vector. At the same time, ban AffineInt from being an element of a vector/memref/tensor as well since we don't need it. I updated the spec to match this as well. PiperOrigin-RevId: 206361942
* Implement support for predecessor iterators on basic blocks, use them to printChris Lattner2019-03-292-1/+44
| | | | | | out predecessor information in the asmprinter. PiperOrigin-RevId: 206343174
* Add tf_control type and allow $ in bare-id.Jacques Pienaar2019-03-292-0/+7
| | | | | | | * Add tf_control as primitive type; * Allow $ in bare-id to allow attributes with $ (to make it trivially to mangle a TF attribute); PiperOrigin-RevId: 206342642
* Stmt visitors and walkers.Uday Bondhugula2019-03-293-9/+9
| | | | | | | | | | | | | | | | | | - Update InnermostLoopGatherer to use a post order traversal (linear time/single traversal). - Drop getNumNestedLoops(). - Update isInnermost() to use the StmtWalker. When using return values in conjunction with walkers, the StmtWalker CRTP pattern doesn't appear to be of any use. It just requires overriding nearly all of the methods, which is what InnermostLoopGatherer currently does. Please see FIXME/ENLIGHTENME comments. TODO: figure this out from this CL discussion. Note - Comments on visitor/walker base class are out of date; will update when this CL is finalized. PiperOrigin-RevId: 206340901
* Implement MLValue, statement operands, operation statement operands and ↵Tatiana Shpeisman2019-03-294-25/+118
| | | | | | values. ML functions now have full support for expressing operations. Induction variables, function arguments and return values are still todo. PiperOrigin-RevId: 206253643
* Implement basic block successor iterators. Rename BBDestination ->Chris Lattner2019-03-291-4/+4
| | | | | | | BasicBlockOperand to be more consistent with InstOperand. Rename getDestinations() to getBasicBlockOperands() to reduce confusion on their role. PiperOrigin-RevId: 206192327
* Enhance ConstantIntOp to work with AffineInt, move use/def list processing codeChris Lattner2019-03-291-2/+4
| | | | | | into a more logical header. PiperOrigin-RevId: 206175435
* Fix broken build: change switch cast to use llvm_unreachable.MLIR Team2019-03-291-1/+1
| | | | PiperOrigin-RevId: 206170570
* Implement the groundwork for predecessor/successor iterators on basic blocks.Chris Lattner2019-03-292-2/+47
| | | | | | | Give BasicBlock a use/def list, making references to them in TerminatorInst's into a type that maintains the list. PiperOrigin-RevId: 206166388
* Fix/clean up convoluted AffineBinaryOpExpr::get.Uday Bondhugula2019-03-291-21/+14
| | | | | | | | | The code for this has been convoluted. We shouldn't be doing a "*result = simplified" below at 703 since the simplified expression would have already been inserted by a simplify* method, whether it was a binary op expr or something else. PiperOrigin-RevId: 206114115
* Implement a proper function list in module, which auto-maintain the parentChris Lattner2019-03-294-6/+87
| | | | | | | | | pointer, and ensure that functions are deleted when the module is destroyed. This exposed the fact that MLFunction had no dtor, and that the dtor in CFGFunction was broken with cyclic references. Fix both of these problems. PiperOrigin-RevId: 206051666
* Fix FIXME's/TODOs:Chris Lattner2019-03-291-5/+9
| | | | | | | | | | | - Enhance memref type to allow omission of mappings and address spaces (implying a default mapping). - Fix printing of function types to properly recurse with printType so mappings are printed by name. - Simplify parsing of AffineMaps a bit now that we have isSymbolicOrConstant() PiperOrigin-RevId: 206039755
* Implement custom parser support for operations, enhance dim/addf to use it, ↵Chris Lattner2019-03-292-1/+69
| | | | | | | | | | and add a new load op. This regresses parser error recovery in some cases (in invalid.mlir) which I'll consider in a follow-up patch. The important thing in this patch is that the parse methods in StandardOps.cpp are nice and simple. PiperOrigin-RevId: 206023308
* Unique AffineDimExpr, AffineSymbolExpr, AffineConstantExpr, and allocate theseUday Bondhugula2019-03-291-9/+45
| | | | | | | | from the bump pointer allocator. - delete AffineExpr destructors. PiperOrigin-RevId: 205943807
* Sketch out loop unrolling transformation.Uday Bondhugula2019-03-291-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Implement a full loop unroll for innermost loops. - Use it to implement a pass that unroll all the innermost loops of all mlfunction's in a module. ForStmt's parsed currently have constant trip counts (and constant loop bounds). - Implement StmtVisitor based (Visitor pattern) Loop IVs aren't currently parsed and represented as SSA values. Replacing uses of loop IVs in unrolled bodies is thus a TODO. Class comments are sparse at some places - will add them after one round of comments. A cmd-line flag triggers this for now. Original: mlfunc @loops() { for x = 1 to 100 step 2 { for x = 1 to 4 { "Const"(){value: 1} : () -> () } } return } After unrolling: mlfunc @loops() { for x = 1 to 100 step 2 { "Const"(){value: 1} : () -> () "Const"(){value: 1} : () -> () "Const"(){value: 1} : () -> () "Const"(){value: 1} : () -> () } return } PiperOrigin-RevId: 205933235
* Adds VariadicOperands and VariadicResult traits to OperationImpl.MLIR Team2019-03-291-2/+13
| | | | | | Uses these in AffineApplyOp verification (with tests). PiperOrigin-RevId: 205921877
* Delete the destructors of attributes and types, since they are immortal.Chris Lattner2019-03-291-2/+1
| | | | | | Non-leaf classes can only mark them protected, but that is better than nothing. PiperOrigin-RevId: 205919901
* Expose custom asmprinter support to core operations and have them adopt it,Chris Lattner2019-03-293-57/+88
| | | | | | fixing the printing syntax for dim, constant, fadd, etc. PiperOrigin-RevId: 205908627
* [mlir] Implement conditional branchJames Molloy2019-03-293-11/+141
| | | | | | | | | This looks heavyweight but most of the code is in the massive number of operand accessors! We need to be able to iterate over all operands to the condbr (all live-outs) but also just the true/just the false operands too. PiperOrigin-RevId: 205897704
* Allow 'constant' op to work with affineint, add some accessors, rearrangeChris Lattner2019-03-291-1/+1
| | | | | | testsuite a bit. PiperOrigin-RevId: 205852871
* Scaffolding for convertToCFG pass that replaces all instances of ML ↵Tatiana Shpeisman2019-03-292-8/+19
| | | | | | functions with equivalent CFG functions. Traverses module MLIR, generates CFG functions (empty for now) and removes ML functions. Adds Transforms library and tests. PiperOrigin-RevId: 205848367
* Adds newly renamed "affine_apply" operation to StandardOps.MLIR Team2019-03-291-1/+18
| | | | | | Breaks "core operations" tests out into their own test file. PiperOrigin-RevId: 205848090
* [mlir] Fix a use-after-free iterator error found by asanJames Molloy2019-03-292-15/+17
| | | | | | | | While fixing this the parser-affine-map.mlir test started failing due to ordering of the printed affine maps. Even the existing CHECK-DAGs weren't enough to disambiguate; a partial match on one line precluded a total match on a following line. The fix for this was easy - print the affine maps in reference order rather than in DenseMap iteration order. PiperOrigin-RevId: 205843770
* Enhance the customizable "Op" implementations in a bunch of ways:Chris Lattner2019-03-293-6/+53
| | | | | | | | | | | | | | | | | | | | | | | | | - Op classes can now provide customized matchers, allowing specializations beyond just a name match. - We now provide default implementations of verify/print hooks, so Op classes only need to implement them if they're doing custom stuff, and only have to implement the ones they're interested in. - "Base" now takes a variadic list of template template arguments, allowing concrete Op types to avoid passing the Concrete type multiple times. - Add new ZeroOperands trait. - Add verification hooks to Zero/One/Two operands and OneResult to check that ops using them are correctly formed. - Implement getOperand hooks to zero/one/two operand traits, and getResult/getType hook to OneResult trait. - Add a new "constant" op to show some of this off, with a specialization for the constant case. This patch also splits op validity checks out to a new test/IR/invalid-ops.mlir file. This stubs out support for default asmprinter support. My next planned patch building on top of this will make asmprinter hooks real and will revise this. PiperOrigin-RevId: 205833214
* Vector types elementtype can be either PrimitiveType or IntegerType.Jacques Pienaar2019-03-292-5/+4
| | | | | | Change the type of elementType and remove the cast to PrimitiveType. PiperOrigin-RevId: 205698221
* [mlir] clang-formatJames Molloy2019-03-292-80/+77
| | | | | | Mostly whitespace changes, but this makes these files clang-format clean. PiperOrigin-RevId: 205697599
* Add operand support to the Instruction base class. Add setOperand methodsChris Lattner2019-03-292-0/+33
| | | | | | | | | | | to all the things. Fill out the OneOperand trait class with support for getting and setting operands, allowing DimOp to have a working get/setOperand() method. I'm not thrilled with the extra template argument on OneOperand, I'll will investigate removing that in a follow-on patch. PiperOrigin-RevId: 205679696
* Implement support for branch instruction operands.Chris Lattner2019-03-294-14/+84
| | | | PiperOrigin-RevId: 205666777
* Implement generic operand/result iterators that map through our implementationChris Lattner2019-03-292-40/+69
| | | | | | | | | details, returning things in terms of values (which is what most clients want). Implement support for operands and results on Operation, and simplify the asmprinter to use it. PiperOrigin-RevId: 205608853
* [mlir] Add basic block argumentsJames Molloy2019-03-293-7/+60
| | | | | | | | This patch adds support for basic block arguments including parsing and printing. In doing so noticed that `ssa-id-and-type` is undefined in the MLIR spec; suggested an implementation in the spec doc. PiperOrigin-RevId: 205593369
* Add support for operands to the return instructions, enhance verifier to ↵Chris Lattner2019-03-293-39/+144
| | | | | | report errors through the diagnostics system when invoked by the parser. It doesn't have perfect location info, but it is close enough to be testable. PiperOrigin-RevId: 205534392
* Add support for multiple results to the printer/parser, add supportChris Lattner2019-03-292-15/+61
| | | | | | | for forward references to the parser, add initial support for SSA use-list iteration and RAUW. PiperOrigin-RevId: 205484031
* Refactor the AsmParser to follow the pattern established in the parser:Chris Lattner2019-03-291-270/+274
| | | | | | | | | | | | there is now an explicit state class - which only has one instance per top level FooThing::print call. The FunctionPrinter's now subclass ModulePrinter so they can just call print on their types and other global stuff. This also makes the contract strict that the global FooThing::print calls are the public entrypoints and that the printer implementation is otherwise self contained. No Functionality Change. PiperOrigin-RevId: 205409317
* Teach the asmprinter to print out operands for OperationInst's. ThisChris Lattner2019-03-292-55/+108
| | | | | | | | | | is still limited in several ways, which i'll build out in subsequent patches. Rename the accessor for inst operands/results to make the Operand/Result versions of these more obscure, allowing getOperand/getResult to traffic in values (which is what - by far - most clients actually care about). PiperOrigin-RevId: 205408439
* Simplify affine binary op expression class hierarchyUday Bondhugula2019-03-295-97/+58
| | | | | | | | | | | | | | | - Drop sub-classing of affine binary op expressions. - Drop affine expr op kind sub. Represent it as multiply by -1 and add. This will also be in line with the math form when we'll need to represent a system of linear equalities/inequalities: the negative number goes into the coefficient of an affine form. (For eg. x_1 + (-1)*x_2 + 3*x_3 + (-2) >= 0). The folding simplification will transparently deal with multiplying the -1 with any other constants. This also means we won't need to simplify a multiply expression like in x_1 + (-2)*x_2 to a subtract expression (x_1 - 2*x_2) for canonicalization/uniquing. - When we print the IR, we will still pretty print to a subtract when possible. PiperOrigin-RevId: 205298958
* Rename isSymbolic to isSymbolicOrConstant to avoid confusion.Uday Bondhugula2019-03-292-9/+11
| | | | PiperOrigin-RevId: 205288794
* Parse ML function arguments, return statement operands, and for statement ↵Tatiana Shpeisman2019-03-292-1/+20
| | | | | | | | loop header. Loop bounds and presumed to be constants for now and are stored in ForStmt as affine constant expressions. ML function arguments, return statement operands and loop variable name are dropped for now. PiperOrigin-RevId: 205256208
OpenPOWER on IntegriCloud