MLIR
20.0.0git
|
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Support/IndentedOstream.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Target/Cpp/CppEmitter.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/ScopedHashTable.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
#include <stack>
#include <utility>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "translate-to-cpp" |
Functions | |
template<typename ForwardIterator , typename UnaryFunctor , typename NullaryFunctor > | |
LogicalResult | interleaveWithError (ForwardIterator begin, ForwardIterator end, UnaryFunctor eachFn, NullaryFunctor betweenFn) |
Convenience functions to produce interleaved output with functions returning a LogicalResult. More... | |
template<typename Container , typename UnaryFunctor , typename NullaryFunctor > | |
LogicalResult | interleaveWithError (const Container &c, UnaryFunctor eachFn, NullaryFunctor betweenFn) |
template<typename Container , typename UnaryFunctor > | |
LogicalResult | interleaveCommaWithError (const Container &c, raw_ostream &os, UnaryFunctor eachFn) |
static FailureOr< int > | getOperatorPrecedence (Operation *operation) |
Return the precedence of a operator as an integer, higher values imply higher precedence. More... | |
static bool | hasDeferredEmission (Operation *op) |
Determine whether expression op should be emitted in a deferred way. More... | |
static bool | shouldBeInlined (ExpressionOp expressionOp) |
Determine whether expression expressionOp should be emitted inline, i.e. More... | |
static LogicalResult | printConstantOp (CppEmitter &emitter, Operation *operation, Attribute value) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::ConstantOp constantOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::VariableOp variableOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::GlobalOp globalOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::AssignOp assignOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::LoadOp loadOp) |
static LogicalResult | printBinaryOperation (CppEmitter &emitter, Operation *operation, StringRef binaryOperator) |
static LogicalResult | printUnaryOperation (CppEmitter &emitter, Operation *operation, StringRef unaryOperator) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::AddOp addOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::DivOp divOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::MulOp mulOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::RemOp remOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::SubOp subOp) |
static LogicalResult | emitSwitchCase (CppEmitter &emitter, raw_indented_ostream &os, Region ®ion) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::SwitchOp switchOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::CmpOp cmpOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::ConditionalOp conditionalOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::VerbatimOp verbatimOp) |
static LogicalResult | printOperation (CppEmitter &emitter, cf::BranchOp branchOp) |
static LogicalResult | printOperation (CppEmitter &emitter, cf::CondBranchOp condBranchOp) |
static LogicalResult | printCallOperation (CppEmitter &emitter, Operation *callOp, StringRef callee) |
static LogicalResult | printOperation (CppEmitter &emitter, func::CallOp callOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::CallOp callOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::CallOpaqueOp callOpaqueOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::ApplyOp applyOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::BitwiseAndOp bitwiseAndOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::BitwiseLeftShiftOp bitwiseLeftShiftOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::BitwiseNotOp bitwiseNotOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::BitwiseOrOp bitwiseOrOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::BitwiseRightShiftOp bitwiseRightShiftOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::BitwiseXorOp bitwiseXorOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::UnaryPlusOp unaryPlusOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::UnaryMinusOp unaryMinusOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::CastOp castOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::ExpressionOp expressionOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::IncludeOp includeOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::LogicalAndOp logicalAndOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::LogicalNotOp logicalNotOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::LogicalOrOp logicalOrOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::ForOp forOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::IfOp ifOp) |
static LogicalResult | printOperation (CppEmitter &emitter, func::ReturnOp returnOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::ReturnOp returnOp) |
static LogicalResult | printOperation (CppEmitter &emitter, ModuleOp moduleOp) |
static LogicalResult | printFunctionArgs (CppEmitter &emitter, Operation *functionOp, ArrayRef< Type > arguments) |
static LogicalResult | printFunctionArgs (CppEmitter &emitter, Operation *functionOp, Region::BlockArgListType arguments) |
static LogicalResult | printFunctionBody (CppEmitter &emitter, Operation *functionOp, Region::BlockListType &blocks) |
static LogicalResult | printOperation (CppEmitter &emitter, func::FuncOp functionOp) |
static LogicalResult | printOperation (CppEmitter &emitter, emitc::FuncOp functionOp) |
static LogicalResult | printOperation (CppEmitter &emitter, DeclareFuncOp declareFuncOp) |
#define DEBUG_TYPE "translate-to-cpp" |
Definition at line 30 of file TranslateToCpp.cpp.
|
static |
Definition at line 459 of file TranslateToCpp.cpp.
References mlir::Region::op_begin(), and mlir::Region::op_end().
Referenced by printOperation().
|
static |
Return the precedence of a operator as an integer, higher values imply higher precedence.
Definition at line 73 of file TranslateToCpp.cpp.
|
static |
Determine whether expression op
should be emitted in a deferred way.
Definition at line 286 of file TranslateToCpp.cpp.
Referenced by shouldBeInlined().
|
inline |
Definition at line 65 of file TranslateToCpp.cpp.
References interleaveWithError().
Referenced by printFunctionArgs(), and printOperation().
|
inline |
Definition at line 58 of file TranslateToCpp.cpp.
References interleaveWithError().
|
inline |
Convenience functions to produce interleaved output with functions returning a LogicalResult.
This is different than those in STLExtras as functions used on each element doesn't return a string.
Definition at line 42 of file TranslateToCpp.cpp.
Referenced by interleaveCommaWithError(), and interleaveWithError().
|
static |
Definition at line 394 of file TranslateToCpp.cpp.
References mlir::Operation::getOperand().
Referenced by printOperation().
|
static |
Definition at line 626 of file TranslateToCpp.cpp.
Referenced by printOperation().
|
static |
Definition at line 323 of file TranslateToCpp.cpp.
References mlir::Operation::getLoc(), and mlir::Operation::getResult().
Referenced by printOperation().
|
static |
Definition at line 959 of file TranslateToCpp.cpp.
References mlir::Operation::getLoc(), and interleaveCommaWithError().
Referenced by printOperation().
|
static |
Definition at line 970 of file TranslateToCpp.cpp.
References mlir::Operation::getLoc(), mlir::Value::getType(), and interleaveCommaWithError().
|
static |
Definition at line 982 of file TranslateToCpp.cpp.
References mlir::WalkResult::advance(), mlir::Operation::emitError(), mlir::Operation::emitOpError(), mlir::Operation::getParentOp(), mlir::Operation::getResults(), mlir::raw_indented_ostream::indent(), mlir::PreOrder, shouldBeInlined(), mlir::WalkResult::skip(), mlir::raw_indented_ostream::unindent(), mlir::Operation::walk(), and mlir::WalkResult::wasInterrupted().
Referenced by printOperation().
|
static |
Definition at line 560 of file TranslateToCpp.cpp.
References mlir::Block::getArguments(), and mlir::Block::getSuccessor().
|
static |
Definition at line 580 of file TranslateToCpp.cpp.
References mlir::Block::getArguments(), mlir::raw_indented_ostream::indent(), and mlir::raw_indented_ostream::unindent().
|
static |
Definition at line 1136 of file TranslateToCpp.cpp.
References printFunctionArgs().
|
static |
Definition at line 429 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 701 of file TranslateToCpp.cpp.
|
static |
Definition at line 377 of file TranslateToCpp.cpp.
References mlir::Value::getDefiningOp(), and mlir::Operation::getResult().
|
static |
Definition at line 714 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 721 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 727 of file TranslateToCpp.cpp.
References printUnaryOperation().
|
static |
Definition at line 733 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 740 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 746 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 646 of file TranslateToCpp.cpp.
References printCallOperation().
|
static |
Definition at line 653 of file TranslateToCpp.cpp.
References mlir::Operation::emitOpError(), mlir::Operation::getLoc(), mlir::Operation::getOperand(), and interleaveCommaWithError().
|
static |
Definition at line 764 of file TranslateToCpp.cpp.
References mlir::Operation::getLoc(), mlir::Operation::getResult(), and mlir::Value::getType().
|
static |
Definition at line 496 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 528 of file TranslateToCpp.cpp.
|
static |
Definition at line 355 of file TranslateToCpp.cpp.
References printConstantOp().
|
static |
Definition at line 435 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 777 of file TranslateToCpp.cpp.
References shouldBeInlined().
|
static |
Definition at line 821 of file TranslateToCpp.cpp.
References mlir::Value::getDefiningOp(), mlir::Region::getOps(), mlir::raw_indented_ostream::indent(), shouldBeInlined(), and mlir::raw_indented_ostream::unindent().
|
static |
Definition at line 1095 of file TranslateToCpp.cpp.
References printFunctionArgs(), and printFunctionBody().
|
static |
Definition at line 371 of file TranslateToCpp.cpp.
|
static |
Definition at line 878 of file TranslateToCpp.cpp.
References mlir::Region::empty(), mlir::raw_indented_ostream::indent(), and mlir::raw_indented_ostream::unindent().
|
static |
Definition at line 790 of file TranslateToCpp.cpp.
|
static |
Definition at line 387 of file TranslateToCpp.cpp.
|
static |
Definition at line 803 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 809 of file TranslateToCpp.cpp.
References printUnaryOperation().
|
static |
Definition at line 815 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 441 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 447 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 936 of file TranslateToCpp.cpp.
|
static |
Definition at line 453 of file TranslateToCpp.cpp.
References printBinaryOperation().
|
static |
Definition at line 470 of file TranslateToCpp.cpp.
References emitSwitchCase(), mlir::raw_indented_ostream::indent(), and mlir::raw_indented_ostream::unindent().
|
static |
Definition at line 758 of file TranslateToCpp.cpp.
References printUnaryOperation().
|
static |
Definition at line 752 of file TranslateToCpp.cpp.
References printUnaryOperation().
|
static |
Definition at line 363 of file TranslateToCpp.cpp.
References printConstantOp().
|
static |
Definition at line 551 of file TranslateToCpp.cpp.
|
static |
Definition at line 639 of file TranslateToCpp.cpp.
References printCallOperation().
|
static |
Definition at line 1058 of file TranslateToCpp.cpp.
References printFunctionArgs(), and printFunctionBody().
|
static |
Definition at line 915 of file TranslateToCpp.cpp.
|
static |
Definition at line 949 of file TranslateToCpp.cpp.
|
static |
Definition at line 413 of file TranslateToCpp.cpp.
References mlir::Operation::getOperand().
Referenced by printOperation().
|
static |
Determine whether expression expressionOp
should be emitted inline, i.e.
as part of its user. This function recommends inlining of any expressions that can be inlined unless it is used by another expression, under the assumption that any expression fusion/re-materialization was taken care of by transformations run by the backend.
Definition at line 296 of file TranslateToCpp.cpp.
References mlir::Value::getUsers(), hasDeferredEmission(), mlir::Value::hasOneUse(), and mlir::Operation::hasTrait().
Referenced by printFunctionBody(), and printOperation().