From 25016dc4c6e5d2019fe286709547b34662531860 Mon Sep 17 00:00:00 2001 From: Nicolas Vasilache Date: Tue, 19 Feb 2019 10:27:04 -0800 Subject: [PATCH] [EDSC] Remove dead code in MLIREmitter.cpp cl/234609882 made EDSCs typed on construction (instead of typed on emission). This CL cleans up some leftover dead code. PiperOrigin-RevId: 234627105 --- mlir/lib/EDSC/MLIREmitter.cpp | 84 ----------------------------------- 1 file changed, 84 deletions(-) diff --git a/mlir/lib/EDSC/MLIREmitter.cpp b/mlir/lib/EDSC/MLIREmitter.cpp index 4868b3da8840..38cb9927c99f 100644 --- a/mlir/lib/EDSC/MLIREmitter.cpp +++ b/mlir/lib/EDSC/MLIREmitter.cpp @@ -45,90 +45,6 @@ using namespace mlir; using namespace mlir::edsc; using namespace mlir::edsc::detail; -// Factors out the boilerplate that is needed to build and answer the -// following simple question: -// Given a set of Value* `values`, how do I get the resulting op(`values`) -// -// This is a very loaded question and generally cannot be answered properly. -// For instance, an LLVM operation has many attributes that may not fit within -// this simplistic framing (e.g. overflow behavior etc). -// -// Still, MLIR is a higher-level IR and the Halide experience shows it is -// possible to build useful EDSCs with the right amount of sugar. -// -// To build EDSCs we need to be able to conveniently support simple operations -// such as `add` on the type system. This captures the possible behaviors. In -// the future, this should be automatically constructed from an abstraction -// that is common to the IR verifier, but for now we need to get off the ground -// manually. -// -// This is expected to be a "dialect-specific" functionality: certain dialects -// will not have a simple definition. Two such cases that come to mind are: -// 1. what does it mean to have an operator* on an opaque tensor dialect -// (dot, vector, hadamard, kronecker ?)-product; -// 2. LLVM add with attributes like overflow. -// This is all left for future consideration; in the meantime let's separate -// concerns and implement useful infrastructure without solving all problems at -// once. - -/// Returns the element type if the type is VectorType or MemRefType; returns -/// getType if the type is scalar. -static Type getElementType(const Value &v) { - if (auto vec = v.getType().dyn_cast()) { - return vec.getElementType(); - } - if (auto mem = v.getType().dyn_cast()) { - return mem.getElementType(); - } - return v.getType(); -} - -static bool isIndexElement(const Value &v) { - return getElementType(v).isIndex(); -} -static bool isIntElement(const Value &v) { - return getElementType(v).isa(); -} -static bool isFloatElement(const Value &v) { - return getElementType(v).isa(); -} - -static Value *add(FuncBuilder *builder, Location location, Value *a, Value *b) { - if (isIndexElement(*a)) { - auto *context = builder->getContext(); - auto d0 = getAffineDimExpr(0, context); - auto d1 = getAffineDimExpr(1, context); - auto map = AffineMap::get(2, 0, {d0 + d1}, {}); - return makeComposedAffineApply(builder, location, map, {a, b}); - } else if (isIntElement(*a)) { - return builder->create(location, a, b)->getResult(); - } - assert(isFloatElement(*a) && "Expected float element"); - return builder->create(location, a, b)->getResult(); -} - -static Value *sub(FuncBuilder *builder, Location location, Value *a, Value *b) { - if (isIndexElement(*a)) { - auto *context = builder->getContext(); - auto d0 = getAffineDimExpr(0, context); - auto d1 = getAffineDimExpr(1, context); - auto map = AffineMap::get(2, 0, {d0 - d1}, {}); - return makeComposedAffineApply(builder, location, map, {a, b}); - } else if (isIntElement(*a)) { - return builder->create(location, a, b)->getResult(); - } - assert(isFloatElement(*a) && "Expected float element"); - return builder->create(location, a, b)->getResult(); -} - -static Value *mul(FuncBuilder *builder, Location location, Value *a, Value *b) { - if (!isFloatElement(*a)) { - return builder->create(location, a, b)->getResult(); - } - assert(isFloatElement(*a) && "Expected float element"); - return builder->create(location, a, b)->getResult(); -} - static void printDefininingStatement(llvm::raw_ostream &os, const Value &v) { const auto *inst = v.getDefiningInst(); if (inst) {